Request methods for HTTP options

Source: Internet
Author: User

The HTTP request method is not only get and post, but is most commonly used. According to the RFC2616 standard (current http/1.1), there are generally 8 ways to do this: OPTIONS,, POST, PUT, DELETE, Trace, and connect. Summarize:

OPTIONS: The request is intended to send a "probe" request to determine what constraints must be applied to a request for a target address (such as what HTTP method should be used and the custom request header), and then send a real request based on its constraints. For example, the HTTP method used for pre-check (preflight) requests for cross-domain resources is the options.

Official definition

The Options method is a feature option that is used to request that the resource identified by the Request-uri be used in the request/response communication process. In this way, the client can decide what necessary action to take on the resource, or understand the performance of the server, before taking a specific resource request.

The response of the request method cannot be cached.

If the options request contains a body (with content-length or transfer-encoding present), you must have content-type to specify the media type. Although the usage of this body is not defined in the specification, future extensions of HTTP may use it to query more detailed information on the server. Servers that do not support this extension can ignore the request body.

If the URI is an asterisk ("*"), the options request will attempt to apply to the server instead of a specified resource. Because the server's communication options are often dependent on resources, this "*" request can only be used as a "ping" or "no-op" method, or to test the performance of the server. For example, to test the http/1.1 agent.

If the URI is not an asterisk, it can only be used to obtain the options available in the resource communication.

The resulting 200 response should contain a header field that indicates an optional feature that the server implements and applies to the resource, such as allow, and may also include extensions that the specification has not yet defined. If there is a response body, you should include information about the communication options. This specification does not define this body format, but may be defined in future extensions of Htto. You can use content negotiation to select the appropriate response format. If there is no response body, the response must contain content-length and the value is "0".

The max-forwards of the request header is used to request a specific proxy. When the agent receives an options request that allows the URI to be forwarded, check the max-forwards. If the Max-forwards value is 0, the message cannot be forwarded; Instead, the agent responds with its own communication options. If Max-forwards is a positive integer, the proxy forwards the request by a value minus 1. If there is no max-forwards in the request, the forwarded request will not be available.

Nutshell

The options request method has two main uses:

1. Get the HTTP request method supported by the server; It is also a common method used by hackers.

2, to check the performance of the server. For example, when Ajax makes cross-domain requests, an HTTP options request header is sent to the resource of another domain name to determine whether the actual request is secure.

The DELETE Method

HTTP provides a Delete method that corresponds to the Put method. A delete request will require that the content removed from the Web server be specified as the resource portion of the request row.

The only interesting thing about the Delete method is that when you receive a response that is identified as a $ OK, that does not mean that the specified resource has been deleted. That simply means that the server has received a command to delete the resource. This exception allows for human intervention for security reasons.

(ext.) HTTP request Method options

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.