To make an OPTIONS request with Curl, you must pass the -X OPTIONS command-line parameter to the Curl. Browsers send OPTIONS requests when making a CORS request to another origin. The OPTIONS request does not return any data. All information is returned in the response headers. In this Curl OPTIONS request example, we send an OPTIONS request to the ReqBin echo URL. Click Run to execute the Curl OPTIONS request online and see the results.
Curl is a command-line tool available for Linux, Windows, and macOS and a cross-platform library (libcurl) that can be used with almost any application. Curl supports over 25+ protocols, including HTTP, HTTPS, FTP, and SFTP. Curl has built-in support for SSL, certificate validation, HTTP Cookies, and user authentication.
What is HTTP OPTIONS?
The HTTP OPTIONS method is one of the nine standard Hypertext Transfer Protocol (HTTP) request methods used to describe communication options for the target resource. The HTTP OPTIONS method represents a request for information about the communication options available on the request/response chain identified by the Request-URI. The HTTP OPTIONS method allows the client to determine the options or requirements associated with a resource, or the capabilities of a server, without implying a resource action or initiating a resource retrieval. Responses to the OPTIONS method are not cacheable. The HTTP OPTIONS method is defined as idempotent, which means that multiple identical OPTIONS requests should have the same effect as a single request. When you send data to a different domain for security reasons, browsers usually send a 'preflight' HTTP OPTIONS request to the target server before sending the data there.
What is CORS?
Sending an HTTP OPTIONS request with Curl
Although the CORS specification does not define the use of the request body, future HTTP extensions may use the OPTIONS request body to make more detailed requests to the server. If the target server does not support expanding the OPTIONS request body, it can dismiss the request body.
Curl OPTIONS Request Syntax
The general form of the Curl command for sending a OPTIONS request is as follows:
Curl OPTIONS Syntax
curl -X OPTIONS [URL]
Curl OPTIONS Request Example
An example of sending an OPTIONS request to the ReqBin echo URL using the -X OPTIONS command-line option:
Curl OPTIONS Example
curl -X OPTIONS https://reqbin.com/echo
Generate Code Snippets for Curl OPTIONS Request Example