oven-sh/bun · error · bun_http::Error

InvalidHTTPResponse

Error message

InvalidHTTPResponse

What it means

The server's response is not a valid HTTP response. Fires when the status line, headers, or framing violate HTTP syntax rules so severely the response cannot be parsed at all (e.g., garbage bytes, missing status line).

Solutions

  1. Inspect the raw response bytes to determine what was actually returned
  2. Check if an HTTPS request was made to an HTTP port (or vice versa)
  3. Verify no intermediary proxy is returning non-HTTP data
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/http/error.rs:58 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16). Data as JSON: /api/errors/f1c88a5ce501797d. Report an issue: GitHub.

Appendix: source

Thrown at src/http/error.rs:58

    #[error("HTTP2Unsupported")]
    HTTP2Unsupported,
    #[error("ConnectionClosed")]
    ConnectionClosed,
    #[error("DNSResolveFailed")]
    DNSResolveFailed,
    #[error("ConnectionRefused")]
    ConnectionRefused,
    #[error("TooManyRedirects")]
    TooManyRedirects,
    #[error("HTTP3Unsupported")]
    HTTP3Unsupported,
    #[error("ResponseHeadersTooLarge")]
    ResponseHeadersTooLarge,
    #[error("UnrequestedUpgrade")]
    UnrequestedUpgrade,
    #[error("UnexpectedData")]
    UnexpectedData,
    #[error("InvalidHTTPResponse")]
    InvalidHTTPResponse,
    #[error("InvalidContentLength")]
    InvalidContentLength,
    #[error("UnsupportedTransferEncoding")]
    UnsupportedTransferEncoding,
    #[error("RequestBodyNotReusable")]
    RequestBodyNotReusable,
    #[error("UnsupportedRedirectProtocol")]
    UnsupportedRedirectProtocol,
    #[error("RedirectURLTooLong")]
    RedirectURLTooLong,
    #[error("RedirectURLInvalid")]
    RedirectURLInvalid,
    #[error("InvalidRedirectURL")]
    InvalidRedirectURL,
    #[error("UnexpectedRedirect")]
    UnexpectedRedirect,
    #[error("ShortRead")]

View on GitHub (pinned to 8c5296ac45)