std.net.http.client
HTTP 1.1 client support.
Requests are sent by creating a Client
and using methods such as
Client.get
to create a Request
, which is then used for constructing the
request (e.g. by setting headers) and sending it. For example:
import std.net.http.client (Client)
import std.uri (Uri)
let client = Client.new
let uri = Uri.parse('https://example.com').or_panic
let req = client.get(uri)
let resp = req.send.or_panic
let body = ByteArray.new
# Read the entire response and panic upon encountering an error.
let _ = resp.body.read_all(body).or_panic
Types
ActiveConnection | A client connection available for sending requests and parsing responses. | |
Client | An HTTP client for sending requests and parsing their responses. | |
Error | An error produced by an HTTP client. | |
MultipartForm | A type for building a multipart/form-data form. | |
MultipartWriter | A type for writing data to a multipart/form-data stream. | |
Request | A type for building and sending a single HTTP request. | |
UrlEncodedForm | A type for building a URL encoded form. |