http头中的host字段详解
2016-04-13 02:36
561 查看
Host:客户端指定自己想访问的http服务器的域名/IP 地址和端口号。
今天同事问了一个问题引发了我对http头中host字段的详细思考,总结了以下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, then the Host header field MUST be given with an empty value. An HTTP/1.1 proxy MUST ensure that any request message it forwards does contain
an appropriate Host header field that identifies the service being requested by the proxy. All Internet-based HTTP/1.1 servers MUST respond with a 400 (Bad Request) status code
to any HTTP/1.1 request message which lacks a Host header field.
今天同事问了一个问题引发了我对http头中host字段的详细思考,总结了以下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, then the Host header field MUST be given with an empty value. An HTTP/1.1 proxy MUST ensure that any request message it forwards does contain
an appropriate Host header field that identifies the service being requested by the proxy. All Internet-based HTTP/1.1 servers MUST respond with a 400 (Bad Request) status code
to any HTTP/1.1 request message which lacks a Host header field.
相关文章推荐
- Linux基础网络设置
- iOS开发之网络编程篇二:Get,Post请求差异及用法
- qperf测量网络带宽和延迟
- 安装完Android Studio出现Internal error. Please report to https://code.google.com/p/android/issues
- iOS开发之网络编程篇一:网络开发基本概念介绍
- Http会话cookie session
- VMware虚拟机上网络连接(network type)的三种模式--bridged、host-only、NAT
- VMware虚拟机网络详解(包括多网卡)
- 生产环境常见的HTTP状态码列表
- TCP协议疑难杂症全景解析
- HttpURLConnection请求返回数据乱码!
- HttpURLConnection(代码实现http请求)
- 网络营销团队怎么留住人才 企业文化建设很重要
- TCP 的那些事儿
- Muduo网络库源码分析(三)线程间使用eventfd通信和EventLoop::runInLoop系列函数
- IOS学习 网络NSURLSession JSON文件解析、本地服务器启动、MAC混编
- http authorization basic请求代码示例
- 用 Redis 轻松实现秒杀系统---双十一和12306的瞬时网络爆发访问
- http://kanglecjr.iteye.com/blog/1071199
- http://www.cnblogs.com/dolphin0520/p/3949310.html