liveBook · Manning

Response

As explained in Rust Servers, Services, and Apps

An HTTP response message is the protocol-formatted message a server sends to an HTTP client in response to a request.

An HTTP response message is represented as a Rust HttpResponse containing a protocol version, status code, status description, optional headers, and an optional body. The structure can be converted into the well-formed text an HTTP client receives. section 2.3.2

Serialized 404 response

A response with status 404, Content-Type text/html, and body “Item was shipped on 21st Dec 2020” becomes an HTTP/1.1 status line followed by headers, Content-Length: 33, a blank line, and the body.

How Rust Servers, Services, and Apps covers it

How deep it goes
Implements response fields, defaults, constructors, getters, serialization, stream writing, and unit tests.
Examples
Uses 200 and 404 responses, an order-shipping body, default HTML headers, exact wire strings, and Cargo test output.
What it assumes
Assumes Rust structs, traits, lifetimes, and TCP byte streams while teaching response representation and serialization.
What you can do after
Build it from scratch as a Rust response type, serialize it, send it through a writable stream, and test its exact output.
How it connects
Connects HTTP request messages, TCP byte streams, serialization, Rust traits, and Rust lifetimes.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Rust Servers, Services, and Apps. The section links point to the parts of the book it draws on.