Solved invalid headers with Reqwest โ now looking to preserve header casing
โ Rust ๐ 2025-10-23 ๐ค surdeus ๐๏ธ 4Iโm integrating with an old SMSC server that sends non-standard HTTP headers like:
-ERROR : ERROR
This obviously violates HTTP syntax, so reqwest (via hyper โ httparse) fails to parse the response. Iโve confirmed that httparse has an ignore_invalid_headers configuration flag, and newer versions of hyper expose an ignore_invalid_headers(true) option on the HTTP/1 Builder.
However:
-
reqwestdoesnโt seem to expose that configuration for clients, and -
it looks like
hyperhard-codesignore_invalid_headers = falseinternally for its client path.
My goal is to make reqwest (or hyper) ignore invalid headers โ e.g., skip lines like -ERROR : ERROR โ just for this project, without forking too much code.
So my questions are:
-
Is there a supported way to enable
ignore_invalid_headersinreqwestโs client stack? -
If not, where exactly in
hypershould I patch to setignore_invalid_headers = truefor HTTP/1 client connections? -
Is there a recommended approach for handling malformed headers from legacy systems like this โ perhaps via a custom connector, proxy, or a local
[patch.crates-io]override ofhttparse?
Context
-
reqwest 0.12.x(which useshyper 1.x) -
The SMSC returns valid HTTP status lines and body but includes malformed header lines like
-ERROR : ERROR.
Any insight into the cleanest or most maintainable way to make reqwest tolerant to such legacy responses would be appreciated.
4 posts - 2 participants
๐ท๏ธ Rust_feed