ringline_http/error.rs
1use std::io;
2
3use ringline_h2::H2Error;
4
5/// Errors produced by the HTTP client.
6#[derive(Debug, thiserror::Error)]
7pub enum HttpError {
8 /// The connection was closed unexpectedly.
9 #[error("connection closed")]
10 ConnectionClosed,
11
12 /// HTTP/2 framing error.
13 #[error("h2 error: {0}")]
14 H2(#[from] H2Error),
15
16 /// I/O error.
17 #[error("io error: {0}")]
18 Io(#[from] io::Error),
19
20 /// Invalid URL or path.
21 #[error("invalid url: {0}")]
22 InvalidUrl(String),
23
24 /// Response parsing error.
25 #[error("parse error")]
26 Parse,
27
28 /// Parsed message is syntactically valid but rejected on semantic
29 /// grounds — e.g., conflicting `Transfer-Encoding` + `Content-Length`
30 /// (RFC 9112 §6.3 request smuggling defense), multiple `Content-Length`
31 /// headers with different values, header values containing CR/LF/NUL,
32 /// or unsupported transfer codings.
33 #[error("invalid message: {0}")]
34 InvalidMessage(String),
35
36 /// A configured resource cap (max header section, max body, max chunk,
37 /// max trailer, max decompressed size) was exceeded.
38 #[error("max size exceeded: {0}")]
39 MaxSizeExceeded(String),
40
41 /// Request timed out.
42 #[error("timeout")]
43 Timeout,
44
45 /// H2 flow control blocked and could not be resolved.
46 #[error("flow control error")]
47 FlowControl,
48
49 /// All connections in a pool failed.
50 #[error("all connections failed")]
51 AllConnectionsFailed,
52
53 /// Protocol error (unexpected event, bad state).
54 #[error("protocol error: {0}")]
55 Protocol(String),
56
57 /// Decompression error.
58 #[error("decompression error: {0}")]
59 Decompress(String),
60}