The difference between the get and post requests for IOS HTTP requests

Source: Internet
Author: User

From the surface of the meaning of the Get and post the difference get is to get data, post is to send data. This is a misunderstanding. In fact, both can be, in the iOS send request to the server can take parameters.

So how did these misconceptions come about? Let's take a look at the HTTP explanation.

Generally in the browser to enter the URL access to resources are through the Get method, in the form submission, you can specify the way to submit the method is get or post, the default is get commit
HTTP defines different ways to interact with the server, with 4 basic methods, namely Get,post,put,delete
URL full name is a resource descriptor, we can think: a URL address, which is used to describe a network of resources, and HTTP get,post,put,delete corresponding to this resource, change, increase, delete 4 operations. Here, everyone should have a general understanding, get is generally used to get/query resource information, and post is generally used to update the resource information (personally think this is the essence of get and post, but also the intention of the Protocol designer, other differences are specific manifestations of the difference).

Learn more about the difference between the two of them:

1. Get uses URL or cookie to pass the parameter. And the post puts the data in the body.

2. Get URLs are limited in length, then the post data can be very large.

3. Post is safer than get because the data is not visible on the address bar.

These are also a bit of a misunderstanding, like the synchronization request must be slow?

How does get and post relate to data transfer?

Get and post are defined by the HTTP protocol. In the HTTP protocol, method and data (URL, Body, Header) are two orthogonal concepts, that is, there is no correlation between the method used and how the application layer's data is transmitted .

HTTP is not required, if the method is the post data will be placed in the body. There is no requirement that if the method is get, the data (parameters) must be placed in the URL instead of being placed in the body.

So, where does the idea of the internet spread widely? I found a similar description in the HTML standard. This is consistent with the online spread of the statement. However, this is only a convention for the use of the HTTP protocol by the HTML standard. How can it be the difference between get and post?

Also, modern Web servers support requests that contain the body in get. Although this request may not be issued from the browser, but now the Web server is not only for the browser, has completely exceeded the scope of the HTML server.

Does the HTTP protocol have no limit on the length of Get and post?

The HTTP protocol explicitly states that neither the HTTP header nor the body has a length requirement. There are two reasons for the limitation of URL length:

1. Browser. It is said that the early browser will limit the length of the URL. It is said that IE will limit the length of the URL to 2048 characters characters (spread very wide, and many colleagues agree). But I tried it myself, and I constructed a 90K URL to access live.com through IE9, which is normal. Things on the internet, even on Wikipedia, can't be trusted.

2. Server. The URL is long and is a burden on server processing. There is not much data for a session, and now if someone maliciously constructs a few m-sized URLs and keeps accessing your server. The maximum number of concurrent servers will obviously drop. Another way to attack is to tell the server content-length is a very large number, and then only to the server to send a little data, hey, the server you are silly to wait to go. Even if you have a timeout setting, this deliberate secondary access timeout can also make the server suffer. In view of this, most servers for security, stability considerations, the URL length will be added restrictions. However, this restriction is for all HTTP requests and is not related to get or post.

This seems to be a bit of a listen.

3. For safety-unsafe speaking.

Get

The so-called security means that the operation is used to obtain information rather than modify information. In other words, get requests generally should not have side effects. That is, it simply gets the resource information, just like a database query, without modification, adding data without affecting the state of the resource.
* Note: The meaning of security here is simply non-modification information.

The security of post is higher than the security of get. Note: The security described here is not the same concept as the "security" mentioned in get above. The meaning of "security" above is simply not to make data changes, and the meaning of security here is the meaning of true security, such as: submit data through get, user name and password will appear in plaintext on the URL, because (1) the login page may be cached by the browser, (2) Other people to view the browser's history, Then other people can get your account number and password, in addition, using get to submit data may also cause Cross-site request forgery attack.

You see the difference?


The difference between the get and post requests for IOS HTTP requests

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.