Module http

Module http 

Source
Expand description

HTTP client.

This module provides an HTTP client API that is backend agnostic. By default it uses the system curl command line utility with a simple cache, this can be replaced using the full API.

§Examples

Get some text:

let text = task::http::get_txt("https://httpbin.org/base64/SGVsbG8gV29ybGQ=").await?;
println!("{text}!");

§Full API

See zng_task::http for the full API.

Modules§

header
HTTP header types
method
The HTTP request method
uri
URI component of request and response lines

Structs§

Method
The Request Method (VERB)
Request
HTTP request.
Response
HTTP response.
StatusCode
An HTTP status code (status-code in RFC 9110 et al.).
Uri
The URI component of a request.

Functions§

cache_clean
Remove all cached entries, or just older ones if prune is enabled.
delete
Send a DELETE request to the uri.
get
Send a GET request to the uri.
get_bytes
Send a GET request to the uri and read the response as raw bytes.
get_json
Send a GET request to the uri and de-serializes the response.
get_txt
Send a GET request to the uri and read the response as a string.
head
Send a HEAD request to the uri.
post
Send a POST request to the uri with a given request body.
put
Send a PUT request to the uri with a given request body.
send
Send a custom Request.
set_request_default
Set the default values returned by Request::new.

Type Aliases§

Error
Any error during request or response.