micro_http/codec/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! HTTP codec module for encoding and decoding HTTP messages
//!
//! This module provides functionality for streaming HTTP message processing,
//! including request decoding and response encoding. It uses a state machine
//! pattern to handle both headers and payload data efficiently.
//!
//! # Architecture
//!
//! The codec module is organized into several components:
//!
//! - Request handling:
//!   - [`RequestDecoder`]: Decodes incoming HTTP requests
//!   - Header parsing via [`header`] module
//!   - Payload decoding via [`body`] module
//!
//! - Response handling:
//!   - [`ResponseEncoder`]: Encodes outgoing HTTP responses
//!   - Header encoding via [`header`] module
//!   - Payload encoding via [`body`] module
//!
//! # Example
//!
//! ```no_run
//! use micro_http::codec::{RequestDecoder, ResponseEncoder};
//! use tokio_util::codec::{Decoder, Encoder};
//! use bytes::BytesMut;
//!
//! // Decode incoming request
//! let mut decoder = RequestDecoder::new();
//! let mut request_buffer = BytesMut::new();
//! let request = decoder.decode(&mut request_buffer);
//!
//! // Encode outgoing response
//! let mut encoder = ResponseEncoder::new();
//! let mut response_buffer = BytesMut::new();
//! // ... encode response ...
//! ```
//!
//! # Features
//!
//! - Streaming processing of HTTP messages
//! - Support for chunked transfer encoding
//! - Content-Length based payload handling
//! - Efficient header parsing and encoding
//! - State machine based processing

mod body;
mod header;
mod request_decoder;
mod response_encoder;

pub use request_decoder::RequestDecoder;
pub use response_encoder::ResponseEncoder;