http
Types
| Type | Description |
|---|---|
Client |
An HTTP client. |
Error |
A transport or protocol failure. |
Event |
One item of a Server-Sent Events stream. |
Response |
An HTTP response. |
Status |
A response whose status is outside 200..=299. |
Functions
get url … -> Response
Makes a GET request through a fresh stateless client.
head, delete, options, trace and connect do the same for their own
verbs, and take the same arguments. See
Client.get for the arguments and
Client for what each option means.
Parameters
| Name | Type | Description |
|---|---|---|
url |
(Str | url.Url) |
URL to request. |
:headers? |
Dict[Value, Value] |
Request headers. |
:query? |
Dict[Value, Value] |
Query parameters. |
:status? |
(:IGNORE: | "IGNORE") |
Pass :IGNORE: to return the response even when
its status is outside 200..=299. |
Example
get[R] url block … -> R
Makes a GET request through a fresh stateless client and calls block with
the response. The response is closed when block returns.
Parameters
| Name | Type | Description |
|---|---|---|
url |
(Str | url.Url) |
URL to request. |
:headers? |
Dict[Value, Value] |
Request headers. |
:query? |
Dict[Value, Value] |
Query parameters. |
:status? |
(:IGNORE: | "IGNORE") |
Pass :IGNORE: to return the response even when
its status is outside 200..=299. |
block |
((Response) -> R) |
Called with the Response. |
post url … -> Response
Makes a POST request through a fresh stateless client.
put and patch do the same for their own verbs, and take the same
arguments. See Client.post for the arguments and
Client for what each option means.
Parameters
| Name | Type | Description |
|---|---|---|
url |
(Str | url.Url) |
URL to request. |
:body? |
(Str | Bin) |
Request body. |
:json? |
json.Encodable |
Request body, JSON-serialized. |
:lines? |
Iterable[Value] |
Request body streamed with a newline after each element. |
:multipart? |
Iterable[Dict[{name: Str, ...}]] |
Multipart form parts. |
:headers? |
Dict[Value, Value] |
Request headers. |
:query? |
Dict[Value, Value] |
Query parameters. |
:status? |
(:IGNORE: | "IGNORE") |
Pass :IGNORE: to return the response even when
its status is outside 200..=299. |
Example
post[R] url block … -> R
Makes a POST request through a fresh stateless client and calls block
with the response. The response is closed when block returns.
Parameters
| Name | Type | Description |
|---|---|---|
url |
(Str | url.Url) |
URL to request. |
:body? |
(Str | Bin) |
Request body. |
:json? |
json.Encodable |
Request body, JSON-serialized. |
:lines? |
Iterable[Value] |
Request body streamed with a newline after each element. |
:multipart? |
Iterable[Dict[{name: Str, ...}]] |
Multipart form parts. |
:headers? |
Dict[Value, Value] |
Request headers. |
:query? |
Dict[Value, Value] |
Query parameters. |
:status? |
(:IGNORE: | "IGNORE") |
Pass :IGNORE: to return the response even when
its status is outside 200..=299. |
block |
((Response) -> R) |
Called with the Response. |