HTTP request method Pros and cons comparison

Source: Internet
Author: User

HTTP defines different ways to interact with the server, and the most basic method is GET and POST.

GET

Pros:3 All Together (interface, link, data) can be viewed in the browser, the implementation is simple. All information attached is behind the address
Cons: Clear text, poor confidentiality, submit data via get, user name and password will appear in plaintext on the URL. File operation is not convenient

The get mode is a more common method. Generally do not submit a large amount of data, are get way to request the Web page, compared to the volume of post data is large. You can see a variety of URLs followed by the id=**,uid=**,action=**,do=**,pn=2 class, like in Baidu when searching the address bar. The data is appended to the URL (that is, the data is placed in the HTTP protocol header) to split the URL and transmit the data, and the parameters are connected &. Sometimes the browser will re-encode the data in the address bar, mainly on the Chinese characters, such as Baidu?wd=%d7%d4%bc%ba, followed by the "own " GBK code.

POST

Advantages: Ciphertext, good confidentiality, file class easy to operate, will not appear in the back ? Bjngh

Cons: Unable to view inside the browser, to achieve complex

Post submits the data is placed in the packet of the HTTP packet, theget way to submit the data can only be 1024 bytes, theoretically post No limit

Difference:Get is generally used to get /query resource information, while post is typically used to update resource information. To summarize,GET is a request to send data to the server, and Post is a request to submit data to the service, in the form (form), themethod defaults to "get", essentially,get and Post is just a different sending mechanism, not one that receives a send.

So we usually do this.
1, request the server and support GET, also support POST
2, write code before debugging interface when we use GET
3. When we actually start to write code, we use POST

Synchronous

Advantages: Simple, no need to go agent method

Disadvantage: Thread card dead, waiting for a long time, especially when the network condition is poor, the user experience is poor, such as TCP communication, the server will wait for the client connection, theaccept method is synchronous, only when the user's request to come, will continue to execute down, Or else you'll be stuck here. Preferably with multi-threaded use, the front of the VC under the Chat tool when the communication part of a separate open a thread, the main thread continues to run to the layout interface. When there is data arriving, the message can be sent.

Asynchronous

Advantage: thread does not snap to death

Cons: trouble to take the proxy method so we generally use asynchronous, synchronous when we can manually open a thread, so it will not be the owner of the thread in the synchronization request, so that the live thread will not be stuck.

There are four ways to combine them: synchronous get, synchronous post, asynchronous get, asynchronous post.

HTTP request method Pros and cons comparison

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.