一般情况下,服务器接收并处理客户端发过来的请求后会返回一个HTTP的响应消息。 HTTP响应也由四个部分组成,分别是:状态行、消息报头、空行和响应正文。 ![](https://box.kancloud.cn/427e62d8ae67cda8bb3b62b66c472fc5_683x305.jpg) ### HTTP Responses Header响应头 | Header | 解释 | 示例 | | --- | --- | --- | | Accept-Ranges | 表明服务器是否支持指定范围请求及哪种类型的分段请求 | Accept-Ranges: bytes | | Age | 从原始服务器到代理缓存形成的估算时间(以秒计,非负) | Age: 12 | | Allow | 对某网络资源的有效的请求行为,不允许则返回405 | Allow: GET, HEAD | | Cache-Control | 告诉所有的缓存机制是否可以缓存及哪种类型 | Cache-Control: no-cache | | Content-Encoding | web服务器支持的返回内容压缩编码类型。 | Content-Encoding: gzip | | Content-Language | 响应体的语言 | Content-Language: en,zh | | Content-Length | 响应体的长度 | Content-Length: 348 | | Content-Location | 请求资源可替代的备用的另一地址 | Content-Location: /index.htm | | Content-MD5 | 返回资源的MD5校验值 | Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ== | | Content-Range | 在整个返回体中本部分的字节位置 | Content-Range: bytes 21010-47021/47022 | | Content-Type | 返回内容的MIME类型 | Content-Type: text/html; charset=utf-8 | | Date | 原始服务器消息发出的时间 | Date: Tue, 15 Nov 2010 08:12:31 GMT | | ETag | 请求变量的实体标签的当前值 | ETag: “737060cd8c284d8af7ad3082f209582d” | | Expires | 响应过期的日期和时间 | Expires: Thu, 01 Dec 2010 16:00:00 GMT | | Last-Modified | 请求资源的最后修改时间 | Last-Modified: Tue, 15 Nov 2010 12:45:26 GMT | | Location | 用来重定向接收方到非请求URL的位置来完成请求或标识新的资源 | Location: http://www.zcmhi.com/archives/94.html | | Pragma | 包括实现特定的指令,它可应用到响应链上的任何接收方 | Pragma: no-cache | | Proxy-Authenticate | 它指出认证方案和可应用到代理的该URL上的参数 | Proxy-Authenticate: Basic | | refresh | 应用于重定向或一个新的资源被创造,在5秒之后重定向(由网景提出,被大部分浏览器支持) | Refresh: 5; url=http://www.zcmhi.com/archives/94.html | | Retry-After | 如果实体暂时不可取,通知客户端在指定时间之后再次尝试 | Retry-After: 120 | | Server | web服务器软件名称 | Server: Apache/1.3.27 (Unix) (Red-Hat/Linux) | | Set-Cookie | 设置Http Cookie | Set-Cookie: UserID=JohnDoe; Max-Age=3600; Version=1 | | Trailer | 指出头域在分块传输编码的尾部存在 | Trailer: Max-Forwards | | Transfer-Encoding | 文件传输编码 | Transfer-Encoding:chunked | | Vary | 告诉下游代理是使用缓存响应还是从原始服务器请求 | Vary: \* | | Via | 告知代理客户端响应是通过哪里发送的 | Via: 1.0 fred, 1.1 nowhere.com (Apache/1.1) | | Warning | 警告实体可能存在的问题 | Warning: 199 Miscellaneous warning | | WWW-Authenticate | 表明客户端请求实体应该使用的授权方案 | WWW-Authenticate: Basic |