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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//! # xocomil
//!
//! A lightweight, zero-allocation HTTP/1.1 request parser and response writer.
//!
//! Supports the standard HTTP methods: GET, HEAD, POST, PUT, DELETE, PATCH,
//! and OPTIONS. Request parsing borrows directly from the caller's read
//! buffer, and response headers are serialized to a stack buffer — no heap
//! allocations on the hot path.
//!
//! ## Unsupported methods
//!
//! CONNECT and TRACE are intentionally omitted:
//!
//! - **TRACE** enables cross-site tracing (XST) attacks, allowing an
//! attacker to steal credentials from `Authorization` or `Cookie`
//! headers reflected in the response body. Most production servers
//! disable it.
//! - **CONNECT** requests proxy tunneling, which is out of scope for a
//! request parser — it changes the connection semantics entirely
//! (the server becomes a TCP relay).
//!
//! If you need either method, parse the method bytes directly from the
//! raw request line.
//!
//! ## Parsing requests
//!
//! ```
//! use xocomil::request::Request;
//! use xocomil::headers::RequestHeader;
//!
//! let raw = b"GET /index.html HTTP/1.1\r\nHost: example.com\r\n\r\n";
//! let req: Request = Request::parse(raw).unwrap();
//!
//! assert_eq!(req.path(), b"/index.html");
//!
//! // Type-safe header lookup (zero-cost, static dispatch)
//! assert_eq!(req.header(RequestHeader::Host), Some(&b"example.com"[..]));
//!
//! // Convert to &str on demand
//! assert_eq!(req.header_str("Host").unwrap(), Some("example.com"));
//! ```
//!
//! ## Writing responses
//!
//! ```
//! use xocomil::headers::{StatusCode, ResponseHeader};
//! use xocomil::response::Response;
//!
//! let mut output = Vec::new();
//!
//! Response::<16>::new(StatusCode::Ok)
//! .header(ResponseHeader::ContentType, b"text/plain").unwrap()
//! .write(&mut output, b"hello")
//! .unwrap();
//!
//! let response = String::from_utf8(output).unwrap();
//! assert!(response.starts_with("HTTP/1.1 200 OK\r\n"));
//! assert!(response.ends_with("hello"));
//! ```
pub
pub
pub
pub
pub
pub use ;
// Static assertions: all public types are Send + Sync.
const _: = ;