Sobes.tech
Junior

Tell me about the OPTIONS method in HTTP.

sobes.tech AI

Answer from AI

The OPTIONS method is used to describe the communication parameters for the target resource. It allows the client to determine which HTTP methods are allowed for the resource, which request headers can be sent, and which response headers can be received.

Usage:

  • Checking allowed methods (Allow header).
  • Determining available headers (Access-Control-Allow-Headers header in CORS).
  • Used in CORS mechanisms (pre-flight request).

Request example:

OPTIONS /resource HTTP/1.1
Host: example.com

Response example:

HTTP/1.1 200 OK
Allow: GET, POST, PUT, DELETE
Content-Length: 0