In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "what is the difference between get request and post request in http", the content is simple and clear, and I hope it can help you solve your doubts. Let me lead you to study and learn this article "what is the difference between get request and post request in http".
A brief introduction
1. HTTP standard includes these two methods in order to achieve different purposes. POST is used to create a resource, and the content of the resource is incorporated into the content requested by the HTTP. For example, processing order forms, adding new rows of data to the database, and so on.
2. When the request has no side effects (such as searching), the GET method can be used; when the request has side effects (such as adding data rows), the POST method can be used. A more practical problem is that the GET method can produce a very long URL, which may exceed the URL length limit imposed by some browsers and servers.
Hang according to specific needs
1. Use the POST method if any of the following conditions are met:
The result of the request has persistent side effects, such as adding new rows of data to the database.
If you use the GET method, the data collected on the form may make the URL too long.
The data to be transmitted is not 7-bit ASCII encoding.
2. Use the GET method if any of the following conditions are met:
The request is to find resources, and the HTML form data is only used to help with the search.
The result of the request has no persistent side effects.
The total length of the collected data and input field names in the HTML form does not exceed 1024 characters.
The difference between GET and POST
GET is harmless when the browser rollback, and POST submits the request again.
The URL address generated by GET can be Bookmark, but POST cannot.
The GET request will be actively cache by the browser, while the POST will not, unless set manually.
GET requests can only be encoded with url, while POST supports multiple encodings.
The GET request parameters will be fully preserved in the browser history, while the parameters in POST will not be retained.
The parameters passed by the GET request in the URL are limited in length, while the post does not.
For the data type of the parameter, GET accepts only ASCII characters, while POST has no restrictions.
GET is less secure than POST because parameters are directly exposed to the URL, so they cannot be used to pass sensitive information.
The GET parameter is passed through URL, and the POST is placed in Request body.
Essential Analysis of GET and POST
What are GET and POST?
In the HTTP protocol, there are two ways to send requests.
What is HTTP?
HTTP is a protocol based on TCP/IP about how data communicates on the World wide Web.
The underlying layer of HTTP is TCP/IP. So the underlying layer of GET and POST is also TCP/IP, that is, GET/POST is a TCP link. GET and POST can do the same thing. You have to add request body to GET and url parameter to POST, which is technically feasible.
In my world of the World wide Web, TCP is like a car. We use TCP to transport data. It is very reliable and never loses a few pieces. But if the road is full of cars that look exactly the same, the world looks like a mess. Cars delivering dispatches may be blocked by cars full of goods in front of them, and the whole transportation system will surely be paralyzed. In order to prevent this from happening, the traffic rule HTTP was born. HTTP sets several service categories for motor transportation, such as GET, POST, PUT, DELETE, etc. HTTP stipulates that when executing a GET request, the car should be labeled as GET (set method to GET), and the transmitted data should be placed on the roof (url) to facilitate recording. If it is requested by POST, label the car with the POST label and put the goods in the car. Of course, you can also secretly hide some goods in the car during GET, but this is very dishonorable; you can also put some data on the roof during POST, which makes people feel silly. HTTP is just a code of conduct, and TCP is the basis of how GET and POST are implemented.
However, we can only see that HTTP requires the transmission channel (url or requrest body) of GET and POST parameters. Where do the restrictions on parameter size in the Standard answer come from?
In my world of the World wide Web, there is another important role: transportation companies. Different browsers (initiating http requests) and servers (accepting http requests) are different shipping companies. In theory, though, you can pile goods indefinitely on the roof of the car (with unlimited parameters in url). But shipping companies are not stupid, loading and unloading also have high costs, they will limit the volume of single transport to control the risk, too much data is a great burden on browsers and servers. The industry's unwritten rule is that (most) browsers usually limit the length of url to 2K bytes, while (most) servers handle a maximum of 64K url. The excess will not be dealt with. If you use GET service to hide data secretly in request body, different servers will handle it differently. Some servers will help you unload and read the data, while others will ignore it directly. So, although GET can carry request body, there is no guarantee that it will be received.
Well, now you know, GET and POST are essentially TCP links, and there's no difference. However, due to the rules of HTTP and browser / server restrictions, they reflect some differences in the application process.
There is another big difference between GET and POST. To put it simply:
GET generates one TCP packet; POST generates two TCP packets.
The long one said:
For requests in GET mode, the browser sends out both http header and data, and the server responds to 200 (returns data)
For POST, the browser sends header first, the server responds to 100continue, the browser sends data, and the server responds to 200ok (return data).
In other words, GET only needs a car trip to deliver the goods, while POST has to make two trips, the first one, to say to the server, "Hey, I'm going to deliver a shipment later, you open the door to meet me", and then deliver it back.
Because POST takes two steps and takes a little more time, it seems that GET is more effective than POST. Therefore, the Yahoo team recommends replacing POST with GET to optimize the performance of the website. But this is a pit! You need to be careful when jumping in. Why?
Both GET and POST have their own semantics and cannot be easily mixed.
According to the research, when the network environment is good, the difference between the time of sending one packet and the time of sending two packets can be ignored. In the case of poor network environment, the TCP of two packets has great advantages in verifying packet integrity.
Not all browsers send packets twice in POST, but only once in Firefox.
These are all the contents of the article "what are the differences between get requests and post requests in http?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.