spork/http/request
spork
function
/usr/local/lib/janet/spork/http.janet on line 801, column 1
(request method url &keys opts)
Make an HTTP request to a server. Returns a table containing
response information:
* `:head-size` - number of bytes in the http header
* `:headers` - table mapping header names to header values. Header
names are lowercase.
* `:connection` - the connection stream for the header.
* `:buffer` - the buffer instance that may contain extra bytes.
* `:status` - HTTP status code as an integer.
* `:message` - HTTP status message.
* `:url` - final resolved URL.
* `:body` - Bytes of the response body (nil if streaming to custom
sink or method is HEAD).
Options:
* `:body` - Request body content
* `:headers` - Request headers table
* `:stream-factory` - Function to create connection stream.
Defaults to net/connect. Signature: (stream-factory host port
stream-opts)
* `:stream-opts` - Options table passed to stream-factory
* `:sink` - Target to stream response body into (function, file, or
buffer)
* `:stream` - If true, returns the open response stream directly
without consuming body
* `:max-redirects` - Maximum number of 3xx redirects to follow
(default 0)