HTTP request

The message a client sends to a server: a method, a target, a protocol version, headers, a blank line and an optional body.

In more detail

In GET /tasks?limit=2 HTTP/1.1, the method is GET, the target is the path plus query string, and the version comes last. Headers such as Host and Accept follow, one per line. Because the format is plain text in HTTP/1.1 you can type a request by hand and read exactly what was sent.

Examples

req, err := http.NewRequestWithContext(ctx, http.MethodGet, target.URL, nil)
Go: http.NewRequestWithContext(ctx, http.MethodGet, target.URL, nil)
In GET /health HTTP/1.1, GET is the method and /health the target; a Host header then names the site. In a packet capture these readable lines help separate an HTTP problem from a transport failure. Headers carry metadata such as the formats the client accepts.
m=GET t=/health host=example accept=text lists the method, target and two request headers.

Related terms

Taught in

References