Solved invalid headers with Reqwest โ€” now looking to preserve header casing

โš“ Rust    ๐Ÿ“… 2025-10-23    ๐Ÿ‘ค surdeus    ๐Ÿ‘๏ธ 4      

surdeus

Iโ€™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:

  • reqwest doesnโ€™t seem to expose that configuration for clients, and

  • it looks like hyper hard-codes ignore_invalid_headers = false internally 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:

  1. Is there a supported way to enable ignore_invalid_headers in reqwestโ€™s client stack?

  2. If not, where exactly in hyper should I patch to set ignore_invalid_headers = true for HTTP/1 client connections?

  3. 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 of httparse?

Context

  • reqwest 0.12.x (which uses hyper 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

Read full topic

๐Ÿท๏ธ Rust_feed