稍微做了一些修改,删了一些觉得无用的话。
Host:客户端指定自己想访问的http服务器的域名/IP 地址和端口号。
总结以下5条。
1.host字段可以是域名,也可以是ip地址。host字段域名/ip后可以跟端口号,如Host: www.6san.com:8080
2.host可以由程序自定义,某些程序为了防止运营商或防火墙拦截会定义虚假host
3.http1.1中host字段可以是空值,http1.0中可以缺失host字段
4.http响应头中不包含host字段,所以wireshark中http.host过滤到的都是请求包
5.因为http头中的host字段可以由程序自定义,所以host字段的值就会有很多特殊情况,如包含多个’/’字符的HOST头信息,结尾含有”.”等
http头中可以没有host字段吗?
在http 1.1中不能缺失host字段,如果缺失, 服务器返回400 bad request,http1.1中不能缺失host字段,但host字段可以是空值。
在http 1.0中可以缺失host字段。
RFC 2616中关于host字段的说明如下:
A client MUST include a Host header field in all HTTP/1.1 request
messages . If the requested URI does not include an Internet host
name for the service being requested,
be given with an empty value. An HTTP/1.1 proxy MUST ensure that any
request message it forwards does contain an appropriat
field that identifies
Internet-b
status code to any HTTP/1.1 request message which lacks a Host header
field.