Rust

response

Module

The outgoing response: status, headers and cookies set by the application, sent once through Response::send (or streamed with Response::chunk); what reaches the connection is recorded as a Wire.

Contents

2 submodules, and what the module defines itself.

use utopia_http::Cookie;
Rust
pub struct Cookie

A cookie added with Response::add_cookie. None means not given.

use utopia_http::Response;
Rust
pub struct Response

An outgoing response.

The application sets the status, headers and cookies, then sends the body once (or in chunks); later sends are ignored.

Also implements Clone, Default.
use utopia_http::Wire;
Rust
pub struct Wire

The response on the wire: the status, headers, cookies and body bytes the response has sent so far.

use utopia_http::reason;
Rust
pub fn reason(code: u16) -> Option<&'static str>

The reason phrase of a status code, or None for a code the response does not accept.

Rust
pub type Body = http_body_util::combinators::BoxBody<Bytes, std::convert::Infallible>

A hyper response body: a buffer, or the frames a streamed response sends.

Rust
pub const CHARSET_UTF8: &str = "UTF-8"

The UTF-8 charset name, for Response::set_content_type.

Rust
pub const CHUNK_SIZE: usize = 2_000_000

Bodies larger than this many bytes are written in chunks.

response::content_type

Own page

Common content types.

Rust
pub const HTML: &str = "text/html"

text/html.

Rust
pub const IMAGE: &str = "image/*"

image/*: any image.

Rust
pub const IMAGE_BMP: &str = "image/bmp"

image/bmp.

Rust
pub const IMAGE_GIF: &str = "image/gif"

image/gif.

Rust
pub const IMAGE_ICON: &str = "image/x-icon"

image/x-icon.

Rust
pub const IMAGE_JPEG: &str = "image/jpeg"

image/jpeg.

Rust
pub const IMAGE_PNG: &str = "image/png"

image/png.

Rust
pub const IMAGE_SVG: &str = "image/svg+xml"

image/svg+xml.

Rust
pub const IMAGE_WEBP: &str = "image/webp"

image/webp.

Rust
pub const JAVASCRIPT: &str = "text/javascript"

text/javascript.

Rust
pub const JSON: &str = "application/json"

application/json.

Rust
pub const TEXT: &str = "text/plain"

text/plain.

Rust
pub const XML: &str = "text/xml"

text/xml.

response::same_site

Own page

The SameSite values of a cookie.

Rust
pub const LAX: &str = "Lax"

Lax: sent with same-site requests and top-level navigations.

Rust
pub const NONE: &str = "None"

None: sent with cross-site requests.

Rust
pub const STRICT: &str = "Strict"

Strict: sent with same-site requests only.