Java code for OPTIONS Request ExampleThis Java code snippet was generated automatically for the OPTIONS Request example.
<< Back to the OPTIONS Request example
What is HTTP?
Hypertext Transfer Protocol (HTTP) is an application-level data transfer protocol that transfers data between HTTP clients (browsers and mobile apps) and a server. The HTTP protocol uses a client-server architecture to transfer data. The client application sends a request to the server, where the server processes the client's request and sends a response back to the client. Each HTTP message consists of a request string, HTTP headers, and a message body.
What is the OPTIONS request method used for?
The HTTP OPTIONS request is used to describe communication options for the target resource. Browsers send HTTP OPTIONS requests to find out the HTTP methods and other options supported by the webserver. The HTTP OPTIONS method is defined as idempotent, which means that multiple identical OPTIONS requests must have the same effect as a single request. If you want to change the data on the server, use the POST, PUT, PATCH, or DELETE methods.
OPTIONS Request Example
The following is an example of sending the OPTIONS request to the ReqBin echo URL:
What is CORS?
Cross-Origin Resource Sharing (CORS) is a security mechanism based on HTTP headers that allow the server to specify any other source that the browser should receive resources or send data. OPTIONS request is a pre-flight request, part of CORS. CORS is a way for the server to check if a request is coming from an allowed source and tell the browser not to block it. CORS implementation was due to single-origin policy constraints. The same-origin policy restricts resources to interact only with resources located in the same domain.