← index

[HTTP]Request

inherits Object · defined at net/http.qn:317

The request Builder. Convenience methods on [HTTP]Client cover the common cases; a library reaches for this to set a custom verb, headers, body, or insecure:. The setters return self so calls can be threaded.

Class methods

parseUrl:

Parse 'scheme://host[:port]/path' into #( scheme host port path ). Port defaults by scheme; path defaults to '/'. Query (if any) rides in path.

[HTTP]Request.parseUrl:'https://example.org/docs/intro?lang=qn'
"* -> #(https example.org 443 /docs/intro?lang=qn)

net/http.qn:337

resolveLocation: against:

Resolve a Location header against the request URL: an absolute URL is used as-is; '/path' is root-relative to the base's scheme://host:port; anything else is relative to the base path's directory.

[HTTP]Request.resolveLocation:'/login' against:'https://example.org/a/b'
"* -> https://example.org:443/login

net/http.qn:358

Instance methods

body

The normalized request body as an [HTTP]Body (or nil if none was set).

net/http.qn:401

body:

Set the body, normalizing a shortcut into an [HTTP]Body: a Map/List is JSON-encoded (Content-Type application/json), a String is its UTF-8 bytes, Bytes is taken as-is, and an already-built [HTTP]Body is used directly. The convenience [HTTP]Client.post: helpers flow through here, so post:url body:aMap auto-encodes.

net/http.qn:389

followRedirects:

Whether send follows 3xx redirects (default true); returns self.

net/http.qn:381

header: value:

Append one request header pair; returns self.

net/http.qn:375

headers:

Replace the header list with pairs — #(name value) each; returns self.

net/http.qn:377

init:

Internal: builder defaults — GET, no headers or body, TLS verified, redirects followed up to 10.

net/http.qn:320

insecure:

Skip TLS certificate verification (self-signed test hosts); returns self.

net/http.qn:379

internalSend

One request/response cycle (no redirect following): connect, send, read the head, and return an [HTTP]Response whose body is a stream-backed [HTTP]Body. The socket is NOT closed here — it stays open, owned by the body, and closes when the body is drained (.text/.json/.bytes), fully iterated (.chunks/.each:), .close'd, or GC-reaped. Throws (catchable) on connection errors or a malformed head; the stream is closed before re-raising.

net/http.qn:430

maxRedirects:

Cap the redirects send will follow before throwing (default 10); returns self.

net/http.qn:383

method:

Set the request verb (e.g. 'PUT'); returns self.

net/http.qn:373

nextRequestFor:

Build the next request for a redirect response: resolve its Location against this request's URL, carry over insecure/followRedirects/maxRedirects and the headers, and adjust the method/body per status. 307/308 preserve method+body; 303 (and a 301/302 from a non-GET/HEAD method) become a bodyless GET.

net/http.qn:521

requestBytes: path:

Serialize the request to Bytes for a given Host header value.

net/http.qn:404

send

Send the request, following redirects (3xx + Location) up to @maxRedirects when @followRedirects is set (the default). Each redirect response's body is discarded; exceeding the cap throws. With following off, the 3xx response is returned as-is.

net/http.qn:495