HTTP HTTP requests Basic request format


Example

In HTTP 1.1, a minimal HTTP request consists of a request line and a Host header:

GET /search HTTP/1.1 \r\n
Host: google.com \r\n
\r\n

The first line has this format:

Method Request-URI HTTP-Version CRLF

Method should be a valid HTTP method; one of [1][2]:

  • OPTIONS
  • GET
  • HEAD
  • POST
  • PUT
  • DELETE
  • PATCH
  • TRACE
  • CONNECT

Request-URI indicates either the URI or the path to the resource that the client is requesting. It can be either:

  • a fully-qualified URI, including scheme, host, (optional) port and path; or
  • a path, in which case the host must be specified in the Host header

HTTP-Version indicates the version of the HTTP protocol the client is using. For HTTP 1.1 requests this must always be HTTP/1.1.

The request line ends with a carriage return—line feed pair, usually represented by \r\n.