Rust

message

Module

Requests, responses, their headers and bodies.

Contents

use utopia_client::Headers;
Rust
pub struct Headers

HTTP header fields in order, each name with its values.

Names compare case-insensitively and keep the spelling they were first added with; they are sent as spelled. Setting a field replaces it and moves it last; adding to one appends values in place.

use utopia_client::Request;
Rust
pub struct Request

An HTTP request: method, URI, headers and body.

Rust
use utopia_client::Request;

let request = Request::new("POST", "https://api.example.com/users")?
    .header("Content-Type", "application/json")?
    .body(r#"{"name":"Ada"}"#);
assert_eq!(request.uri().host(), "api.example.com");
assert_eq!(request.headers().line("content-type"), "application/json");
use utopia_client::Response;
Rust
pub struct Response

An HTTP response: protocol version, status, reason phrase, headers and body.

A response with a 4xx or 5xx status is still a response, not an error. A streamed response carries an empty body: its bytes went to the sink.

use utopia_client::Body;
Rust
pub enum Body

A request body.

Also implements From.