首页
随机
最近更改
特殊页面
社群首页
参数设置
关于WHY42
免责声明
WHY42
搜索
用户菜单
登录
欢迎来到Riguz的小站!这是一个私人wiki,用来记录一些我的笔记。
查看“︁HTTP/1.1”︁的源代码
←
HTTP/1.1
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
Http1.1最初定义在[https://datatracker.ietf.org/doc/html/rfc2616 Hypertext Transfer Protocol -- HTTP/1.1]中,后面被[https://datatracker.ietf.org/doc/html/rfc7230 Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing]废除,因此当前HTTP1.1协议实际上包括: * [https://datatracker.ietf.org/doc/html/rfc7230 RFC7230]:Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing * [https://datatracker.ietf.org/doc/html/rfc7231 RFC7231]:Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content * [https://datatracker.ietf.org/doc/html/rfc7232 RFC7232]:Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests * [https://datatracker.ietf.org/doc/html/rfc7233 RFC7233]:Hypertext Transfer Protocol (HTTP/1.1): Range Requests * [https://datatracker.ietf.org/doc/html/rfc7234 RFC7234]:Hypertext Transfer Protocol (HTTP/1.1): Caching * [https://datatracker.ietf.org/doc/html/rfc7235 RFC7235]:Hypertext Transfer Protocol (HTTP/1.1): Authentication = 概要 = <pre> GET /hello.txt HTTP/1.1 User-Agent: curl/7.16.3 libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3 Host: www.example.com Accept-Language: en, mi </pre> <pre> HTTP/1.1 200 OK Date: Mon, 27 Jul 2009 12:28:53 GMT Server: Apache Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT ETag: "34aa387-d-1568eb00" Accept-Ranges: bytes Content-Length: 51 Vary: Accept-Encoding Content-Type: text/plain Hello World! My payload includes a trailing CRLF. </pre> = HTTP消息格式 = <syntaxhighlight lang="python"> HTTP-message = start-line *( header-field CRLF ) CRLF [ message-body ] </syntaxhighlight> 程序首先读取start-line以及header,然后根据header里面的内容决定是否含有body。body则按照长度读取定长字节。 == start-line == <syntaxhighlight lang="python"> start-line = request-line / status-line request-line = method SP request-target SP HTTP-version CRLF status-line = HTTP-version SP status-code SP reason-phrase CRLF </syntaxhighlight> 其中: * HTTP中并未直接定义request-line的长度限制,倘若超过服务端实现所支持的长度,则建议返回501(Not implemented) * HTTP建议request-line支持至少8000字符长 * 若request-target超过服务器预期则必须返回414 (URI Too Long) ==header-field== <syntaxhighlight lang="python"> header-field = field-name ":" OWS field-value OWS field-name = token field-value = *( field-content / obs-fold ) field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] field-vchar = VCHAR / obs-text obs-fold = CRLF 1*( SP / HTAB ) </syntaxhighlight> [[Category:Network]]
返回
HTTP/1.1
。