The http module is experimental.

Represents an HTTP request. This extra level of indirection — as opposed to as, for instance, making it part of http.socket — makes it easier to map semantics such as HTTP pipelining w/o imposing even more confusing state machines.


new() → http.request


continue_required(req: http.request) → boolean

Check if the request represented by req requires a “100 (Continue) response” [1].

If you can properly process and reply the message without its body, you’re free to go. Otherwise, you should send a “100 (Continue) response” to ask for the message body from the HTTP client.

This feature was designed to decrease network traffic, by allowing servers to sooner reject messages that would be discarded anyway.

The name required is used instead supported, because an action from the server is required.

upgrade_desired(req: http.request) → boolean

Check if the client desires to initiate a protocol upgrade.

The desired protocols are present in the "upgrade" header as a comma-separated list.

You MUST NOT upgrade to a protocol listed in the "upgrade" header if this function returns false.

The upgrade desire can always be safely ignored.

The user MUST wait till the whole request is received before proceeding to the protocol upgrade.


method: string

The HTTP method/verb (e.g. "GET", "POST").

target: string

The HTTP request target (e.g. "/index.html", "").

headers: http.headers

The HTTP headers.

See also:

body: string

The HTTP body.

That’s a clunky abstraction actually. It’ll be replaced in a future release for a proper byte span abstraction (e.g. Go’s slices).

trailers: http.headers

The HTTP trailers.

See also:

1. Defined in RFC 7231, section 5.1.1.