Skip to main content

Module response

Module response 

Source
Expand description

HTTP/1.1 响应序列化器

将 CanonicalResponse 序列化为 HTTP/1.1 线路格式字节 (RFC 7230 §3)。

§格式

HTTP/1.1 {status_code} {reason_phrase}\r\n
{Header-Name}: {Header-Value}\r\n
...
\r\n
{body}

§设计

  • 零堆分配热路径:写入调用方提供的 &mut Vec<u8>
  • 自动补全 Content-Length(若缺失且 body 非空)
  • CRLF 注入防护:拒绝包含 \r\n 的头部值(二次校验,上游已拦截)
  • RFC 7230 §3.2.4 严格合规:头部字段名仅允许 token 字符

Structs§

Http1ResponseEncoder
HTTP/1.1 响应序列化器

Enums§

ResponseSerializeError
响应序列化错误