Coding With Fun
Home Docker Django Node.js Articles FAQ

HTTP's two common request methods, GET and POST


May 30, 2021 Article blog


Table of contents


HTTP's two common request methods, GET and POST

HTTP:HTTP Protocol (HyperText Transfer) for transferring hypertext from a World Wide Web server to a local browser. HTTP is a TCP/IP communication protocol that delivers data (HTML files, picture files, query results, etc.).

First, get method

When using the GET method, the query string (name or key value pair) is sent in the URL of the GET request:

/test/demo_form.php?name1=value1&name2=value2

说明

  • POST request will not be cached
  • POST request will not retain in the browser history
  • The URL requested by the POST cannot be collected as a bookmark.
  • POST request has no length requirements

In the HTTP method, the POST is more reliable to the background, and the post method package information is basically the same as the GET method, but the POST method does not send the information as the text string after the character is transmitted, but the information as oneSeparate messages.Servlet uses the dopost () method to handle this type of request.

Third, the difference between the GET method and the POST method

  • When the browser is retracted, the GET request is harmless, and the POST request will re-request once.
  • The GET request parameter is connected to the URL, and the POST request parameter is stored in the message main body (RequestBody)
  • GET requests because the browser has restrictions on the length of the URL (different browser length limits is different), and the POST request is not limited by the number of parameters because the parameter stores RequestBody
  • Since the GET request parameter is exposed to the URL, the security POST is more secure than Get.
  • GET Request Browser Active Cache, POST is not unless the active settings
  • GET request parameters save in the browser history, POST requests are not
  • GET request can only be used as a URL encoding, while POST requests can support multiple encoding methods
  • GET requests generates 1 TCP packet, POST requests generates 2 TCP packets
  • The browser sends the request header and data (DATA) together to the server when sending a GET request, and the server returns the 200 status code, and when the POST request is sent, the header will be sent to the server, the server returns 100, thenSend the DATA to the server, the server returns 200

illustrate:

  • GET requests can be cached
  • GET requests remain in the browser history
  • The URL requested by GET can be bookmarked
  • GET requests should not be used when working with sensitive data
  • GET requests have a length limit
  • GET requests should only be used to obtain data

The GET method is the default request method for passing information from the browser to the Web server, which produces a long string that appears in the browser's address bar. T he GET method has a size limit: you can only have a maximum of 1024 characters in the request string. S ervlet

Second, POST method

When using the POST method, the query string (name or key value pair) is resend by the HTTP message principal of the POST request: this type of request is processed using the doGet() method.

POST /test/demo_form.php HTTP/1.1
Host: runoob.com
name1=value1&name2=value2

illustrate

  • POST requests are not cached
  • POST requests are not retained in the browser history
  • The URL requested by POST cannot be bookmarked
  • There is no length requirement for POST requests

POST data transfer to the background in HTTP methods is more reliable, POST method packaging information is basically the same as GET method, but POST method is not information as URL? T he text string after the character is sent, but the information is sent as a separate message. Servlet handles this type of request using the doPost() method.

Third, the difference between the GET method and the POST method

  • Get requests are harmless when the browser rolls back, and POST requests are resubmitted once
  • The GET request parameter is connected behind the URL, while the POST request parameter is stored in the message body
  • GET requests have a limit on the number of parameters because the browser has a limit on url length (different browser length limits are different), while post requests have no limit on the number of parameters because they are stored within Requestbody
  • BECAUSE GET REQUEST PARAMETERS ARE EXPOSED TO URLS, POST IS MORE SECURE IN TERMS OF SECURITY THAN GET
  • GET requests that the browser actively cache (Cache), and POST does not, unless it is actively set
  • Get request parameters are saved in the browser history, and POST requests are not
  • GET requests can only be URL encoded, while POST requests can support multiple encoding methods
  • The GET request produces 1 Tcp packet and the POST request produces 2 Tcp packets
  • When the browser sends a GET request, it sends the request header and data to the server, which returns a 200 status code, while when sending a POST request, it sends Header to the server, the server returns 100, and then data to the server, which returns 200

Recommended good lessons: HTML micro-class, HTML-CSS basic combat, HTML5 new features live