Skip to main content

Module traffic_writer

Module traffic_writer 

Available on crate features 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§

BidirectionalWriter
A writer that can write both requests and responses.
DoNotWriteRequest
Marker struct to indicate that the request should not be printed.
DoNotWriteResponse
Marker struct to indicate that the response should not be printed.
PerMessageFileWriter
Writes every captured request and response to an independent file.
RequestWriterLayer
Middleware to print Http request in std format.
RequestWriterService
Middleware to print Http request in std format.
ResponseWriterLayer
Layer that applies ResponseWriterService which prints the http response in std format.
ResponseWriterService
Middleware to print Http responses in std format.

Enums§

BidirectionalMessage
The internal message type for the BidirectionalWriter.
WriterMode
Http writer mode.

Traits§

RequestWriter
A trait for writing http requests.
ResponseWriter
A trait for writing http responses.