Introduction to the 8 request types of the HTTP protocol

Eight methods or "actions" are defined in the HTTP protocol to indicate different operations on the resources specified by the Request-URI. The details are as follows: 

OPTIONS: Returns the HTTP request methods supported by the server for a specific resource. The functionality of the server can also be tested by sending a '*' request to the web server. 
HEAD: Ask the server for a response consistent with the GET request, but the response body will not be returned. This method makes it possible to obtain meta-information contained in response headers without having to transmit the entire response content. 
GET: Make a request to a specific resource. 
POST: Submit data to the specified resource for processing requests (such as submitting a form or uploading a file). Data is included in the request body. POST requests may result in the creation of new resources and/or the modification of existing resources. 
PUT: Upload its latest content to the specified resource location. 
DELETE: Requests the server to delete the resource identified by the Request-URI. 
TRACE: echoes the request received by the server, mainly for testing or diagnosis. 

CONNECT: The HTTP/1.1 protocol is reserved for proxy servers that can change the connection to pipe mode.

   Although there are 8 HTTP request methods, we commonly use get and post in practical applications, and other request methods can also be implemented indirectly through these two methods.

Introduction of GET, POST and HEAD in HTTP protocol 
2008-05-10 14:15 
GET: Request the specified page information and return the entity body. 
HEAD: Only the header of the page is requested. 
POST: Requests the server to accept the specified document as a new subordinate entity to the identified URI. 
PUT: Data sent from the client to the server replaces the contents of the specified document. 
DELETE: Request the server to delete the specified page. 
OPTIONS: Allows clients to view server performance. 
TRACE: Request the server to return the resulting content in the entity body part of the response. 
PATCH: The entity contains a table that describes the differences from the original content represented by the URI. 
MOVE: Requests the server to move the specified page to another network address. 
COPY: Request the server to copy the specified page to another network address. 
LINK: Request the server to establish a link relationship. 
UNLINK: disconnect the link relationship. 
WRAPPED: Allows clients to send wrapped requests. 
Extension-mothed: Additional methods can be added without changing the protocol. 


GET: Request the specified page information and return the entity body. 
 HEAD: Only the header of the page is requested. 
 POST: Requests the server to accept the specified document as a new subordinate entity to the identified URI.  





       HTTP defines different methods for interacting with a server, the most basic being GET and POST. In fact GET works for most requests, while POST is reserved for updating the site only. According to the HTTP specification, GET is used for information retrieval and should be safe and idempotent. By safe is meant that the operation is used to obtain information rather than modify it. In other words, GET requests should generally not have side effects. Idempotent means that multiple requests to the same URL should return the same result. The full definition is not as strict as it might seem. Fundamentally, the goal is that when a user opens a link, she can be confident that the resource has not changed from her perspective. For example, the front page of a news site is constantly updated. Although the second request returns a different batch of news, the operation is still considered safe and idempotent because it always returns the current news. vice versa. POST requests are not so easy. POST represents a request that may change a resource on the server. Still taking the news site as an example, the reader's comment on the article should be implemented through a POST request, because the site is different after the comment is submitted (for example, a comment appears under the article); 
when the FORM is submitted, if no Method is specified, the default For a GET request, the data submitted in the Form will be appended to the url, separated from the url by ?. Alphanumeric characters are sent as they are, but spaces are converted to "+" signs, and other symbols are converted to %XX, where XX is the ASCII (or ISO Latin-1) value of the symbol in hexadecimal. The data submitted by the GET request is placed in the HTTP request protocol header, while the data submitted by POST is placed in the entity data; 
the data submitted by the GET method can only have a maximum of 1024 bytes, while the POST does not have this limitation.    

What is the difference between using "post" and "get" in a  form?

In a form, you can use post or get. They are all legal values ​​for method. However, there are at least two differences in the use of post and get methods: 
1. The Get method passes the user's input through a URL request. Post method through another form. 
2. When submitting in Get mode, you need to use Request.QueryString to get the value of the variable. When submitting in Post mode, you must access the submitted content through Request.Form.  
Study the code below carefully. You can feel it by running it: 

code 
<!--Only the Method attribute is different between the two Forms-->
<FORM ACTION="getpost.asp" METHOD="get">
<INPUT TYPE="text" NAME="Text" VALUE="Hello World"></INPUT> 
<INPUT TYPE="submit" VALUE="Method=Get"></INPUT> 
</FORM> 
<BR> 
<FORM ACTION="getpost.asp" METHOD="post ">
<INPUT TYPE="text" NAME="Text" VALUE="Hello World"></INPUT> 
<INPUT TYPE="submit" VALUE="Method=Post"></INPUT> 
</FORM> 

<BR > 
<BR> 

<% If Request.QueryString(“Text”) <> ““ Then %> 
The string passed by the get method is: “<B><%= Request. 


Prompt  to submit data through the get method, which may bring security problems. Like a landing page. When submitting data via the get method, the username and password will appear on the URL. If:  1. The login page can be cached by the browser;  2. Others can access the client's machine. 




















Then, others can read the account and password of the customer from the browser's history. So, in some cases, the get method can bring serious security problems. 
It is recommended 
to use the post method in Form. 



If the request is made with the HEAD method, the server returns only the response header, not the requested document. The HEAD method is commonly used in some search engines 

------------------- -------------------------------------------------- ------------------------------------------------ 

GET: Request the specified page information and return the entity body. 
HEAD: Only the header of the page is requested. 
POST: Requests the server to accept the specified document as a new subordinate entity to the identified URI. 
PUT: Data sent from the client to the server replaces the contents of the specified document. 
DELETE: Request the server to delete the specified page. 
OPTIONS: Allows clients to view server performance. 
TRACE: Request the server to return the resulting content in the entity body part of the response. 
PATCH: The entity contains a table that describes the differences from the original content represented by the URI. 
MOVE: Requests the server to move the specified page to another network address. 
COPY: Request the server to copy the specified page to another network address. 
LINK: Request the server to establish a link relationship. 
UNLINK: disconnect the link relationship. 
WRAPPED: Allows clients to send wrapped requests. 
Extension-mothed: Additional methods can be added without changing the protocol. 

For example: 
GET /index.html HTTP/1.1 
Accept: text/plain /*plain ASCII text file*/ 
Accept: text/html /*HTML text file*/ 
User-Agent:Mozilla/4.5(WinNT) 
indicates that the browser uses The Get method requests document/index.html. The browser is only allowed to receive plain ASCII text files and HTML text files, and the engine it uses is Mozilla/4.5 (Netscape). 

When the server responds, the information in its status line is the HTTP version number, status code, and a brief description explaining the status code. The 5 types of status codes are listed in detail: 
① Client error 
100 Continue 
101 Exchange protocol 
② Success 
200 OK 
201 Created 
202 Received 
203 Non-authentication information 
204 No content 
205 Reset content 
206 Partial content 
③ Redirect 
300 Multiple choice 
301 Permanent transfer 
302 Temporary transfer 
303 See other 
304 Not Modified (Not Modified) 
305 Use proxy 
④ Client side error 
400 Bad Request 
401 Unauthenticated 
402 Charge Required 
403 Forbidden 
404 Not Found 
405 Method Not Allowed 
406 Not Accepted 
407 Proxy Authentication Required 
408 Request Timeout 
409 Conflict 
410 Failed 
411 Length Required 
412 Condition Failed 
413 The request entity is too large  414  The
request URI is too long  415  The  media
type  is  not  supported  Use telnet to log in to port 80, the same method is used in HTTP/1.1, you will find that there is no display, the following supplementary explanation)  telnet www.fudan.edu.cn 80  HEAD / HTTP/1.1  host:www.fudan.edu.cn / *This line is the input content*/  HTTP/1.1 501 Method Not Implemented 











Date: Web, 01 Nov 2000 07:12:29 GMT /*当前的日期/时间*/ 
Server: Apache/1.3.12 (Unix) /*Web服务器信息*/ 
Allow: GET, HEAD, OPTION, TRACE /*支持的方法类型*/ 
Connection: close  
Connect-Type: Text/html; charset=iso-8859-1/*连接的媒体类型*/ 

<!DOCTYPE HTML PUBLIG "-//IETF//DTD HTML 2.0//EN"> 
<HTML><HEAD> 
<TITLE>501 Method 
Not Implemented</TITLE> 
</HEAD><BODY> 
<H1>Method Not Implemented</H1> 
head to /inde 
x.html not supported.<P> 
Invalid method in request head / htp/1.1<P> 
<HR> 
<ADDRESS> 
Apache/1.3.12 Server at www.fudan.edu.cn Port 80</ADDRESS> 
</BODY></HTML> Last Modified : The last modification time of the requested document. 
The content of the entity header can also include: 

Expires : The expiration time of the requested document. 
Connect-length: The length of the document data. 
WWW-authenricate: Notifies the client of the required authentication information.  
Connect-encoding: Indicates whether to use compression technology. 
Transfer-encoding : Indicates the type of encoding transformation used. 

With the development of the Internet, the next-generation HTTP protocol HTTP-ng is already in the pipeline. It will provide better security and faster speed. The improvement points are: strong modularity, high network efficiency, and security. Better and simpler structure.

 

Reference link: https://www.cnblogs.com/liangxiaofeng/p/5798607.html 

 

 
 

Eight methods or "actions" are defined in the HTTP protocol to indicate different operations on the resources specified by the Request-URI. The details are as follows: 

OPTIONS: Returns the HTTP request methods supported by the server for a specific resource. The functionality of the server can also be tested by sending a '*' request to the web server. 
HEAD: Ask the server for a response consistent with the GET request, but the response body will not be returned. This method makes it possible to obtain meta-information contained in response headers without having to transmit the entire response content. 
GET: Make a request to a specific resource. 
POST: Submit data to the specified resource for processing requests (such as submitting a form or uploading a file). Data is included in the request body. POST requests may result in the creation of new resources and/or the modification of existing resources. 
PUT: Upload its latest content to the specified resource location. 
DELETE: Requests the server to delete the resource identified by the Request-URI. 
TRACE: echoes the request received by the server, mainly for testing or diagnosis. 

CONNECT: The HTTP/1.1 protocol is reserved for proxy servers that can change the connection to pipe mode.

   Although there are 8 HTTP request methods, we commonly use get and post in practical applications, and other request methods can also be implemented indirectly through these two methods.

Introduction of GET, POST and HEAD in HTTP protocol 
2008-05-10 14:15 
GET: Request the specified page information and return the entity body. 
HEAD: Only the header of the page is requested. 
POST: Requests the server to accept the specified document as a new subordinate entity to the identified URI. 
PUT: Data sent from the client to the server replaces the contents of the specified document. 
DELETE: Request the server to delete the specified page. 
OPTIONS: Allows clients to view server performance. 
TRACE: Request the server to return the resulting content in the entity body part of the response. 
PATCH: The entity contains a table that describes the differences from the original content represented by the URI. 
MOVE: Requests the server to move the specified page to another network address. 
COPY: Request the server to copy the specified page to another network address. 
LINK: Request the server to establish a link relationship. 
UNLINK: disconnect the link relationship. 
WRAPPED: Allows clients to send wrapped requests. 
Extension-mothed: Additional methods can be added without changing the protocol. 


GET: Request the specified page information and return the entity body. 
 HEAD: Only the header of the page is requested. 
 POST: Requests the server to accept the specified document as a new subordinate entity to the identified URI.  





       HTTP defines different methods for interacting with a server, the most basic being GET and POST. In fact GET works for most requests, while POST is reserved for updating the site only. According to the HTTP specification, GET is used for information retrieval and should be safe and idempotent. By safe is meant that the operation is used to obtain information rather than modify it. In other words, GET requests should generally not have side effects. Idempotent means that multiple requests to the same URL should return the same result. The full definition is not as strict as it might seem. Fundamentally, the goal is that when a user opens a link, she can be confident that the resource has not changed from her perspective. For example, the front page of a news site is constantly updated. Although the second request returns a different batch of news, the operation is still considered safe and idempotent because it always returns the current news. vice versa. POST requests are not so easy. POST represents a request that may change a resource on the server. Still taking the news site as an example, the reader's comment on the article should be implemented through a POST request, because the site is different after the comment is submitted (for example, a comment appears under the article); 
when the FORM is submitted, if no Method is specified, the default For a GET request, the data submitted in the Form will be appended to the url, separated from the url by ?. Alphanumeric characters are sent as they are, but spaces are converted to "+" signs, and other symbols are converted to %XX, where XX is the ASCII (or ISO Latin-1) value of the symbol in hexadecimal. The data submitted by the GET request is placed in the HTTP request protocol header, while the data submitted by POST is placed in the entity data; 
the data submitted by the GET method can only have a maximum of 1024 bytes, while the POST does not have this limitation.    

What is the difference between using "post" and "get" in a  form?

In a form, you can use post or get. They are all legal values ​​for method. However, there are at least two differences in the use of post and get methods: 
1. The Get method passes the user's input through a URL request. Post method through another form. 
2. When submitting in Get mode, you need to use Request.QueryString to get the value of the variable. When submitting in Post mode, you must access the submitted content through Request.Form.  
Study the code below carefully. You can feel it by running it: 

code 
<!--Only the Method attribute is different between the two Forms-->
<FORM ACTION="getpost.asp" METHOD="get">
<INPUT TYPE="text" NAME="Text" VALUE="Hello World"></INPUT> 
<INPUT TYPE="submit" VALUE="Method=Get"></INPUT> 
</FORM> 
<BR> 
<FORM ACTION="getpost.asp" METHOD="post ">
<INPUT TYPE="text" NAME="Text" VALUE="Hello World"></INPUT> 
<INPUT TYPE="submit" VALUE="Method=Post"></INPUT> 
</FORM> 

<BR > 
<BR> 

<% If Request.QueryString(“Text”) <> ““ Then %> 
The string passed by the get method is: “<B><%= Request. 


Prompt  to submit data through the get method, which may bring security problems. Like a landing page. When submitting data via the get method, the username and password will appear on the URL. If:  1. The login page can be cached by the browser;  2. Others can access the client's machine. 




















Then, others can read the account and password of the customer from the browser's history. So, in some cases, the get method can bring serious security problems. 
It is recommended 
to use the post method in Form. 



If the request is made with the HEAD method, the server returns only the response header, not the requested document. The HEAD method is commonly used in some search engines 

------------------- -------------------------------------------------- ------------------------------------------------ 

GET: Request the specified page information and return the entity body. 
HEAD: Only the header of the page is requested. 
POST: Requests the server to accept the specified document as a new subordinate entity to the identified URI. 
PUT: Data sent from the client to the server replaces the contents of the specified document. 
DELETE: Request the server to delete the specified page. 
OPTIONS: Allows clients to view server performance. 
TRACE: Request the server to return the resulting content in the entity body part of the response. 
PATCH: The entity contains a table that describes the differences from the original content represented by the URI. 
MOVE: Requests the server to move the specified page to another network address. 
COPY: Request the server to copy the specified page to another network address. 
LINK: Request the server to establish a link relationship. 
UNLINK: disconnect the link relationship. 
WRAPPED: Allows clients to send wrapped requests. 
Extension-mothed: Additional methods can be added without changing the protocol. 

For example: 
GET /index.html HTTP/1.1 
Accept: text/plain /*plain ASCII text file*/ 
Accept: text/html /*HTML text file*/ 
User-Agent:Mozilla/4.5(WinNT) 
indicates that the browser uses The Get method requests document/index.html. The browser is only allowed to receive plain ASCII text files and HTML text files, and the engine it uses is Mozilla/4.5 (Netscape). 

When the server responds, the information in its status line is the HTTP version number, status code, and a brief description explaining the status code. The 5 types of status codes are listed in detail: 
① Client error 
100 Continue 
101 Exchange protocol 
② Success 
200 OK 
201 Created 
202 Received 
203 Non-authentication information 
204 No content 
205 Reset content 
206 Partial content 
③ Redirect 
300 Multiple choice 
301 Permanent transfer 
302 Temporary transfer 
303 See other 
304 Not Modified (Not Modified) 
305 Use proxy 
④ Client side error 
400 Bad Request 
401 Unauthenticated 
402 Charge Required 
403 Forbidden 
404 Not Found 
405 Method Not Allowed 
406 Not Accepted 
407 Proxy Authentication Required 
408 Request Timeout 
409 Conflict 
410 Failed 
411 Length Required 
412 Condition Failed 
413 The request entity is too large  414  The
request URI is too long  415  The  media
type  is  not  supported  Use telnet to log in to port 80, the same method is used in HTTP/1.1, you will find that there is no display, the following supplementary explanation)  telnet www.fudan.edu.cn 80  HEAD / HTTP/1.1  host:www.fudan.edu.cn / *This line is the input content*/  HTTP/1.1 501 Method Not Implemented 











Date: Web, 01 Nov 2000 07:12:29 GMT /*当前的日期/时间*/ 
Server: Apache/1.3.12 (Unix) /*Web服务器信息*/ 
Allow: GET, HEAD, OPTION, TRACE /*支持的方法类型*/ 
Connection: close  
Connect-Type: Text/html; charset=iso-8859-1/*连接的媒体类型*/ 

<!DOCTYPE HTML PUBLIG "-//IETF//DTD HTML 2.0//EN"> 
<HTML><HEAD> 
<TITLE>501 Method 
Not Implemented</TITLE> 
</HEAD><BODY> 
<H1>Method Not Implemented</H1> 
head to /inde 
x.html not supported.<P> 
Invalid method in request head / htp/1.1<P> 
<HR> 
<ADDRESS> 
Apache/1.3.12 Server at www.fudan.edu.cn Port 80</ADDRESS> 
</BODY></HTML> Last Modified : The last modification time of the requested document. 
The content of the entity header can also include: 

Expires : The expiration time of the requested document. 
Connect-length: The length of the document data. 
WWW-authenricate: Notifies the client of the required authentication information.  
Connect-encoding: Indicates whether to use compression technology. 
Transfer-encoding : Indicates the type of encoding transformation used. 

With the development of the Internet, the next-generation HTTP protocol HTTP-ng is already in the pipeline. It will provide better security and faster speed. The improvement points are: strong modularity, high network efficiency, and security. Better and simpler structure.

 

Reference link: https://www.cnblogs.com/liangxiaofeng/p/5798607.html 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325077029&siteId=291194637