Expand description
Core HTTP protocol abstractions and implementations.
This module provides the fundamental building blocks for HTTP protocol handling, including request/response processing, body streaming, and error handling. The design focuses on providing clean abstractions while maintaining high performance and memory efficiency.
§Architecture
The protocol module is organized into several key components:
-
Message Handling ([
message
]): Core message types and payload processingMessage
: Represents either headers or payload chunksPayloadItem
: Handles individual payload chunks and EOFPayloadSize
: Tracks payload size information
-
Request Processing ([
request
]): Request header handlingRequestHeader
: Wraps HTTP request headers with additional functionality
-
Response Processing ([
response
]): Response header handlingResponseHead
: Type alias for response headers before body attachment
-
Body Streaming (
body
): Efficient body handling implementation- [
ReqBody
]: Consumer side implementinghttp_body::Body
- [
ReqBodySender
]: Producer side for streaming body chunks
- [
-
Error Handling ([
error
]): Comprehensive error typesHttpError
: Top-level error typeParseError
: Request parsing errorsSendError
: Response sending errors
§Design Goals
-
Memory Efficiency
- Stream request/response bodies instead of buffering
- Implement proper backpressure mechanisms
-
Clean Abstractions
- Provide intuitive interfaces for protocol handling
- Hide implementation complexity from consumers
-
Protocol Correctness
- Ensure proper HTTP protocol compliance
- Handle edge cases and error conditions gracefully
-
Performance
- Minimize allocations and copies
- Support concurrent processing where beneficial
§Example Usage
The protocol module is typically used through the connection layer rather than directly. However, understanding its components is crucial for implementing custom handlers or extending functionality.
See individual module documentation for specific usage examples.
Modules§
- body
- HTTP request body handling implementation.
Structs§
- Request
Header - Represents an HTTP request header.
Enums§
- Http
Error - The top-level error type for HTTP operations
- Message
- Represents a HTTP message that can either be a header or payload.
- Parse
Error - Errors that occur during HTTP request parsing
- Payload
Item - Represents an item in the HTTP message payload stream.
- Payload
Size - Represents the size information of an HTTP payload.
- Send
Error - Errors that occur during HTTP response generation and sending
Type Aliases§
- Response
Head - Type alias for HTTP response headers.