Small knowledge, big challenge! This paper is participating in theEssentials for programmers”Creative activities.

Translate: www.tcpipguide.com/free/t_HTTP…

The request line

The starting line of all HTTP packets is called the request line in the request message. The request line has three purposes:

  1. Indicates the command/action that the client wants to perform
  2. States on which resource the action should be performed
  3. The HTTP version that the client is using

The syntax for the request line should look like this:

<METHOD> <request-uri> <HTTP-VERSION>
Copy the code

METHOD (METHOD)

METHOD is the type of operation that the client expects the server to take, always specified in uppercase letters. HTTP/1.1 defines eight methods, of which GET, HEAD and POST are widely used. They are called “methods” rather than “commands” because the HTTP standard uses object-oriented programming terminology.

Request URL (Request URI)

A request URI is a Uniform Resource Identifier used to request an applicable resource, although a URI can theoretically refer to a Uniform Resource Locator (URL) or a Uniform Resource Name (URN), But today URIs are almost always HTTP urls that follow the standard syntax rules of Web urls.

Suppose the user enters a URL like this:

http://www.myfavoritewebsite.com:8080/chatware/chatroom.php
Copy the code

We obviously don’t need to send “HTTP:” to the server. Client will get the rest of the information and segmentation, therefore the URI is designated as “/ chatware chatroom. PHP”, the host will include “www.myfavoritewebsite.com:8080”. So the request starts like this:

GET/chatware/chatroom. HTTP / 1.1 PHP Host: www.myfavoritewebsite.com:8080Copy the code

The exception to this rule is when making a request to a proxy server. In this case, the request is made with the full URL in its original form so that the agent can process it as the original client would. The request looks like this:

GET http://www.myfavoritewebsite.com:8080/chatware/chatroom.php HTTP / 1.1Copy the code

Finally, there is a special case where you can use an asterisk instead of a real URL. This is for the OPTIONS method, which does not need to specify resources. (Nominally, the asterisk indicates that the method points to the server itself.)

HTTP Version

Http-version tells the server what VERSION the client is using so that the server knows how to interpret the request and what to send to the client and what not to send in the response. Versions are sent in uppercase letters such as “HTTP/1.1”

That’s all for this article. Feel free to like and comment