Common HTTP methods

Source: Internet
Author: User

Method Describe Whether the body is included
GET Get a copy of a document from the server Whether
HEAD Get the header of the response message from the server only Whether
POST Send data to the server that needs to be processed Is
PUT Store the principal part of the request on the server Is
TRACE Tracking of messages that may go through a proxy server to the server Whether
OPTIONS Decide which methods can be executed on the server Whether
DELETE Delete a document from the server Whether

Note: Not all servers implement these methods. Some servers also implement their own unique HTTP methods, called extension methods.

get: Get can be said to be the most common, it is essentially sending a request to get a resource on the server. Resources are returned to the client through a set of HTTP headers and rendering data (such as HTML text, or pictures or videos). In a GET request, the rendering data is never included.

Head: The head and get essence are the same, except that the head does not contain the rendering data, but only the HTTP header information. Some people may find this method useless, but that is not the case. Imagine a business scenario: to determine whether a resource exists, we usually use get, but the head here is more explicit.

PUT: This method is relatively rare. This is not supported by HTML forms. In essence, put and post are very similar, are sending data to the server, but there is an important difference between them, put usually specifies the location of the resources, and post is not, post data storage location by the server itself. For example, a url,/addblog for submitting a blog post. If put, the submitted URL will be "/addblog/abc123" like this, where abc123 is the address of the blog post. If you use post, the address will be communicated to the client by the server after submission. Most blogs are like this at the moment. Obviously, the put and post uses are not the same. The specific use depends on the current business scenario.

Delete: Deletes a resource. This is mostly rare, but there are some places like Amazon's S3 cloud service that use this method to delete resources.

POST: Submit data to the server. This method is widely used, and almost all of the current submissions are done by this.

OPTIONS: This method is interesting, but rarely used. It is used to get the methods supported by the current URL. If the request succeeds, it contains a header named "Allow" in the HTTP header, which is the supported method, such as "GET, POST."

TRACE: Requests the server to echo received request information, mainly for testing and diagnostics, so it is safe.

The above seven methods, we can with the database of crud additions and deletions to the operation corresponding to:

Create:put
Read:get
Update:post
Delete:delete

Head, get, options, and trace are considered safe methods because they only obtain resources from the server and do not make any modifications to the server, but the head, get, and options are not secure on the client side, and post affects the resources on the server.

Get does not modify server data, but the Get method passes the user's input through a URL request; The head only gets the header of the message, but the data is passed through the URL. This is not secure for the client.

The trace method must be secure for the server and client side

Common HTTP methods

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.