HTTP权威指南_摘录

以下内容是摘录自《HTTP 权威指南》(HTTP The Definitive Guide),目前没有中文版,可在google中阅读部分章节。有兴趣想购买的可以在亚马逊上购买:RMB 323.5

书中详细介绍了网络基础、HTTP的架构、HTTP的安全/认证、编码和国际化等。(最后截取了百度首页与谷歌首页的请求以供分析)

table {border-collapse:collapse; border:none !important; margin:20px 0 !important; display:block;} th, td {border:1px solid #ddd; padding:5px;} th {background-color:#dde; border:1px solid #ccc; color:#36c;} tr:hover {background-color:#eee;} caption {text-align:left; font-size:18px; padding: 5px 0;} pre {margin:30px;}

Media type

Description

text/html

Entity body is an HTML document

text/plain

Entity body is a document in plain text

image/gif

Entity body is an image of type GIF

image/jpeg

Entity body is an image of type JPEG

audio/x-wav

Entity body contains WAV sound data

model/vrml

Entity body is a three-dimensional VRML model

application/vnd.ms-powerpoint

Entity body is a Microsoft PowerPoint presentation

multipart/byteranges

Entity body has multiple parts, each containing a different range (in bytes) of the full document

message/http

Entity body contains a complete HTTP message (see TRACE)

Content-encoding value

Description

gzip

Indicates that the GNU zip encoding was applied to the entity.

compress

Indicates that the Unix file compression program has been run on the entity.

deflate

Indicates that the entity has been compressed into the zlib format

identity

Indicates that no encoding has been performed on the entity. When a Content-Encoding header is not present, this can be assumed.

Directive

Message type

Description

no-cache

Request

Do not return a cached copy of the document without first revalidating it with the server.

no-store

Request

Do not return a cached copy of the document. Do not store the response from the server.

max-age

Request

The document in the cache must not be older than the specified age.

max-stale

Request

The document may be stale based on the server-specified expiration information, but it must not have been expired for longer than the value in this directive.

min-fresh

Request

The document's age must not be more than its age plus the specified amount. In other words, the response must be fresh for at least the specified amount of time.

no-transform

Request

The document must not be transformed before being sent.

only-if-cached

Request

Send the document only if it is in the cache, without contacting the origin server.

public

Response

Response may be cached by any cache.

private

Response

Response may be cached such that it can be accessed only by a single client.

no-cache

Response

If the directive is accompanied by a list of header fields, the content may be cached and served to clients, but the listed header fields must first be removed. If no header fields are specified, the cached copy must not be served without revalidation with the server.

no-store

Response

Response must not be cached.

no-transform

Response

Response must not be modified in any way before being served.

must-revalidate

Response

Response must be revalidated with the server before being served.

proxy-revalidate

Response

Shared caches must revalidate the response with the origin server before serving. This directive can be ignored by private caches.

max-age

Response

Specifies the maximum length of time the document can be cached and still considered fresh.

s-max-age

Response

Specifies the maximum age of the document as it applies to shared caches (overriding the max-age directive, if one is present). This directive can be ignored by private caches.

Request type

Validator

Description

If-Modified-Since

Last-Modified

Send a copy of the resource if the version that was last modified at the time in your previous Last-Modified response header is no longer the latest one.

If-Unmodified-Since

Last-Modified

Send a copy of the resource only if it is the same as the version that was last modified at the time in your previous Last-Modified response header.

If-Match

ETag

Send a copy of the resource if its entity tag is the same as that of the one in your previous ETag response header.

If-None-Match

ETag

Send a copy of the resource if its entity tag is different from that of the one in your previous ETag response header

Header

Description

ETag

Unique identifier for each instance of a document. Sent by the server in the response; used by clients in subsequent requests in If-Match and If-None-Match headers.

If-None-Match

Request header sent by the client, asking the server for a document if and only if the client's version of the document is different from the server's.

A-IM

Client request header indicating types of instance manipulations accepted.

IM

Server response header specifying the type of instance manipulation applied to the response. This header is sent when the response code is 226 IM Used.

Delta-Base

Server response header that specifies the ETag of the base document used for generating the delta (should be the same as the ETag in the client request's If-None-Match header).

Type

Description

vcdiff

Delta using the vcdiff algorithm

diffe

Delta using the Unix diff -e command

gdiff

Delta using the gdiff algorithm

gzip

Compression using the gzip algorithm

deflate

Compression using the deflate algorithm

range

Used in a server response to indicate that the response is partial content as the result of a range selection

identity

Used in a client request's A-IM header to indicate that the client is willing to accept an identity instance manipulation

Header

Description

Accept

Used to tell the server what media types are okay to send

Accept-Language

Used to tell the server what languages are okay to send

Accept-Charset

Used to tell the server what charsets are okay to send

Accept-Encoding

Used to tell the server what encodings are okay to send

Accept header

Entity header

Accept(ex:image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*)

Content-Type(ex:text/html)

Accept-Language(ex:zh-cn)

Content-Language(ex:fr, de, zh-cn)

Accept-Charset(ex:iso-8859-1, *, utf-8)

Content-Type(ex:;charet=utf-8)

Accept-Encoding(ex:gzip, deflate)

Content-Encoding(ex:gzip)

(Request-Line)	GET / HTTP/1.1
Accept	image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*
Accept-Encoding	gzip, deflate
Accept-Language	zh-cn
Connection	Keep-Alive
Cookie	PREF=ID=314fbae1650bde00:FF=2:LD=zh-CN:NW=1:TM=1320735923:LM=1320735923:S=oSSPDnEPbXYbWbsp
Host	www.google.com.hk
User-Agent	Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; QQDownload 677; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; InfoPath.2; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)


(Status-Line)	HTTP/1.1 200 OK
Cache-Control	private, max-age=0
Content-Encoding	gzip
Content-Type	text/html; charset=UTF-8
Date	Tue, 08 Nov 2011 07:05:23 GMT
Expires	-1
Server	gws
Set-Cookie	NID=52=xxxxxxxxxxxxxx; expires=Wed, 09-May-2012 07:05:23 GMT; path=/; domain=.google.com.hk; HttpOnly
Transfer-Encoding	chunked
X-Frame-Options	SAMEORIGIN
X-XSS-Protection	1; mode=block
(Request-Line)	GET / HTTP/1.1
Accept	*/*
Accept-Encoding	gzip, deflate
Accept-Language	zh-cn
Connection	Keep-Alive
Cookie	BAIDUID=CEDBBF526CC8742529C8FDDA98EA859F:FG=1
Host	www.baidu.com
User-Agent	Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; QQDownload 677; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; InfoPath.2; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)


(Status-Line)	HTTP/1.1 200 OK
Cache-Control	private
Connection	Keep-Alive
Content-Encoding	gzip
Content-Length	3092
Content-Type	text/html;charset=gb2312
Date	Tue, 08 Nov 2011 07:07:31 GMT
Expires	Tue, 08 Nov 2011 07:07:31 GMT
Server	BWS/1.0

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏landv

杨格门锁 YGSLockSDK V3.3酒管软件接口_99v

27390
来自专栏一只程序汪的自我修养

手把手教你用.NET Core写爬虫

自从上一个项目58HouseSearch从.NET迁移到.NET core之后,磕磕碰碰磨蹭了一个月才正式上线到新版本。

394120
来自专栏我是攻城师

2015年240个数据库引擎排名参考

535100
来自专栏java相关

SpringBoot集成redis缓存

19530
来自专栏java闲聊

SSM,第一天基于Maven的SSM整合,依赖关系搭建

43850
来自专栏自由而无用的灵魂的碎碎念

启动Myeclipse报错“Failed to create the Java Virtual Machine”的解决办法

我安装的是Myeclipse 10.7.1。装上好久没用,今天启动突然报错:Failed to create the Java Virtual Machine。...

14130
来自专栏Python自动化测试

python接口测试之http请求

python的强大之处在于提供了很多的标准库,这些标准库可以直接调用,本节部分,重点学习和总结在接口测试中Python的Http请求的库的学习。

56330
来自专栏DeveWork

通过.htaccess 让WordPress 的上传文件夹更安全

WordPress本身的架构就很安全,但是我们可以做一些优化,让WordPress 更安全。WordPress的图片等文件的上传路径默认是wp-content/...

24490
来自专栏杨建荣的学习笔记

数据库日志中一条"异常"信息所包含的细节(r6笔记第18天)

今天在梳理服务器的信息的时候,发现有一台服务器没有设置crontab作业,一般的服务器中可能会需要一些定时的任务来触发一些备份,清理等等工作。 因为这是一台备库...

32850
来自专栏移动开发之家

从Android到React Native开发(二、通信与模块实现)

4、从Android到React Native开发(四、打包流程和发布为Maven库)

13050

扫码关注云+社区

领取腾讯云代金券