http method: GET contrast POST "JAVA:SPRINGMVC: Basics: HTTP Protocol ()

Source: Internet
Author: User

Http://www.w3school.com.cn/tags/html_ref_httpmethods.asp

The two most common HTTP methods are: GET and POST.

—————————————————————————————————

What is HTTP?

The Hypertext Transfer Protocol (HTTP) is designed to ensure communication between the client and the server.

HTTP works as a request-response protocol between the client and the server.

A Web browser might be a client, and a network application on a computer might be a server-side.

Example: the client (browser) submits an HTTP request to the server, and the server returns a response to the client. The response contains status information about the request and What might be requested .

—————————————————————————————————

Two methods of HTTP request: GET and POST

In the request-response between the client and the server, the two most commonly used methods are: GET and POST.

    • GET -requests data from the specified resource.
    • POST -submits the data to be processed to the specified resource

GET method

Note that the query string (name/value pair) is sent in the URL of the GET request:

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

Some additional comments about the GET request:

    • Get requests can be cached
    • GET requests remain in browser history
    • Get requests can be bookmark-Favorites
    • GET requests should not be used when handling sensitive data
    • Get request has a length limit
    • GET requests should only be used to retrieve data

POST method

Note that the query string (name/value pair) is sent in the HTTP message body of the POST request:

Post/test/demo_form.asp http/1.1

Host:w3schools.com

Name1=value1&name2=value2

Some additional comments about the POST request:

    • POST requests are not cached
    • POST requests are not persisted in browser history
    • POST cannot be bookmarked
    • POST request has no requirement for data length

—————————————————————————————————

Compare GET to POST

The following table compares the two HTTP methods: GET and POST.

Contrast Item surface

GET

POST

Back button/refresh

harmless

data will be resubmitted (the browser should tell the user that the data will be resubmitted).

bookmarks

favorites bookmark

not bookmark

cache

can be cached

cannot be cached

encoding type

application/x-www-form-urlencoded

application/x-www-form-urlencoded or Multipart/form-data. Use multiple encodings for binary data.

history

limitations on data length

Yes. When the data is sent, the GET method adds data to the URL; url is limited (the maximum URL length is 2048 characters) .

unrestricted.

Restrictions on data types

only ASCII characters are allowed.

there is no limit. Binary data is also allowed.

security

never use GET when sending passwords or other sensitive information!

post is more secure than GET because parameters are not saved in the browser history or Web server logs.

Visibility of

The data is visible to everyone in the URL.

The data is not displayed in the URL.

Other HTTP Request Methods

Some other HTTP request methods are listed in the following table:

Method

Describe

HEAD

Same as GET, but returns only the HTTP header and does not return the document body.

PUT

Uploads the specified URI representation.

DELETE

Deletes the specified resource.

OPTIONS

Returns the HTTP methods supported by the server.

CONNECT

Convert the request connection to a transparent TCP/IP channel.

http method: GET contrast POST "JAVA:SPRINGMVC: Basics: HTTP Protocol ()

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.