A Request-lineZero or more header (General|Request|Entity) fields followed by CRLFAn empty line (i.e., a line with nothing preceding the CRLF) indicating the end of the header fieldsOptionally a message-body
Request-Line = Method SP Request-URI SP HTTP-Version CRLF
SN | 方法和说明 |
1 | GET
GET 方法用于使用给定的 URI 从给定的服务器检索信息。使用 GET 的请求应该只检索数据,对数据没有其他影响。
|
2 | HEAD
与 GET 相同,但它只传输状态行和标题部分。
|
3 | POST
POST 请求用于使用 HTML 表单向服务器发送数据,例如客户信息、文件上传等。
|
4 | PUT
用上传的内容替换目标资源的所有当前表示。
|
5 | DELETE
删除由 URI 给出的目标资源的所有当前表示。
|
6 | CONNECT
建立到由给定 URI 标识的服务器的隧道。
|
7 | OPTIONS
描述目标资源的通信选项。
|
8 | TRACE
执行消息环回测试以及目标资源的路径。
|
Request-URI = "*" | absoluteURI | abs_path | authority
SN | 方法和说明 |
1 | 星号 * 用于 HTTP 请求不适用于特定资源,而是适用于服务器本身,并且仅在所使用的方法不一定适用于资源时才允许使用。例如:
OPTIONS * HTTP/1.1
|
2 | absoluteURI 用于向代理发出 HTTP 请求。请求代理从有效缓存转发请求或服务,并返回响应。例如:
GET http://www.w3.org/pub/WWW/TheProject.html HTTP/1.1
|
3 | Request-URI 最常见的形式是用于标识源服务器或网关上的资源。例如,希望直接从源服务器检索资源的客户端将创建到主机"www.w3.org"的端口 80 的 TCP 连接并发送以下行:
GET/pub/WWW/TheProject.html HTTP/1.1
Host: www.w3.org
注意绝对路径不能为空;如果原始 URI 中不存在,则必须以"/"(服务器根目录)形式给出。
|
GET /hello.htm HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.tutorialspoint.com
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
POST /cgi-bin/process.cgi HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.tutorialspoint.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
licenseID=string&content=string&/paramsXML=string
POST /cgi-bin/process.cgi HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT) Host: www.tutorialspoint.com Content-Type: text/xml; charset=utf-8 Content-Length: length Accept-Language: en-us Accept-Encoding: gzip, deflate Connection: Keep-Alive <?xml version="1.0" encoding="utf-8"?> <string xmlns="http://clearforest.com/">string</string>