Http 简明教程
HTTP - Requests
HTTP 客户端以请求消息的形式向服务器发送 HTTP 请求,其中包含以下格式:
An HTTP client sends an HTTP request to a server in the form of a request message which includes following format:
A Request-line
Zero or more header (General|Request|Entity) fields followed by CRLF
An empty line (i.e., a line with nothing preceding the CRLF)
indicating the end of the header fields
Optionally a message-body
以下部分解释了 HTTP 请求消息中使用的每个实体。
The following sections explain each of the entities used in an HTTP request message.
Request-Line
请求行以方法标记开头,后跟请求 URI 和协议版本,并以 CRLF 结尾。各元素之间由空格 SP 字符分隔。
The Request-Line begins with a method token, followed by the Request-URI and the protocol version, and ending with CRLF. The elements are separated by space SP characters.
Request-Line = Method SP Request-URI SP HTTP-Version CRLF
下面讨论请求行中提到的各个部分。
Let’s discuss each of the parts mentioned in the Request-Line.
Request Method
请求 method 指示对由给定的 Request-URI 识别的资源执行的方法。该方法区分大小写,并且始终应大写提及。下表列出了 HTTP/1.1 中支持的所有方法。
The request method indicates the method to be performed on the resource identified by the given Request-URI. The method is case-sensitive and should always be mentioned in uppercase. The following table lists all the supported methods in HTTP/1.1.
S.N. |
Method and Description |
1 |
*GET*The GET method is used to retrieve information from the given server using a given URI. Requests using GET should only retrieve data and should have no other effect on the data. |
2 |
*HEAD*Same as GET, but it transfers the status line and the header section only. |
3 |
*POST*A POST request is used to send data to the server, for example, customer information, file upload, etc. using HTML forms. |
4 |
*PUT*Replaces all the current representations of the target resource with the uploaded content. |
5 |
*DELETE*Removes all the current representations of the target resource given by URI. |
6 |
*CONNECT*Establishes a tunnel to the server identified by a given URI. |
7 |
*OPTIONS*Describe the communication options for the target resource. |
8 |
*TRACE*Performs a message loop back test along with the path to the target resource. |