Module traffic_writer
http and std only.Expand description
Middleware to write Http traffic in std format.
Can be useful for cli / debug purposes.
Built-in shared writers keep complete messages ordered through one output
task. Each message has capacity for one captured frame; a slow or long-lived
message therefore applies asynchronous backpressure to later body streams
instead of buffering their complete contents in memory. Use a per-message
writer when messages must be captured concurrently without sharing that
backpressure. In particular, a shared bidirectional body writer can stall a
full-duplex exchange when either peer waits for the other direction to make
progress; use PerMessageFileWriter or another independent writer for
such traffic.
That output task holds the scope it was built with until it ends. Each
capture is admitted when its message is served and is then written: it
holds the writer’s admission until its message is handed over. A cancel
starts the drain: the task keeps taking what pending captures send, and while
any is pending a newly served one is admitted too. Once the scope is
cancelled and no capture is pending, admission closes for good: the task
flushes what is queued and ends, and later captures are refused. A writer
kept around therefore never holds up a shutdown. At the hard phase the task
and its pending captures are dropped. Layers made with the writer’s constructors, or
with BidirectionalWriter::request_layer and
BidirectionalWriter::response_layer, admit captures this way; a layer
made with new around a built-in writer has no admission, so a capture
racing the cancel may be dropped.
Structs§
- Bidirectional
Writer - A writer that can write both requests and responses.
- DoNot
Write Request - Marker struct to indicate that the request should not be printed.
- DoNot
Write Response - Marker struct to indicate that the response should not be printed.
- PerMessage
File Writer - Writes every captured request and response to an independent file.
- Request
Writer Layer - Middleware to print Http request in std format.
- Request
Writer Service - Middleware to print Http request in std format.
- Response
Writer Layer - Layer that applies
ResponseWriterServicewhich prints the http response in std format. - Response
Writer Service - Middleware to print Http responses in std format.
Enums§
- Bidirectional
Message - The internal message type for the
BidirectionalWriter. - Writer
Mode - Http writer mode.
Traits§
- Request
Writer - A trait for writing http requests.
- Response
Writer - A trait for writing http responses.