oven-sh/bun · error · bun_http::Error
InvalidContentLength
Error message
InvalidContentLength
What it means
The Content-Length header value is invalid or inconsistent with the actual body. Fires when the declared length is negative, non-numeric, or conflicts with the bytes actually received on the body stream.
Solutions
- Verify the server sends a correct Content-Length header matching the actual body size
- For streaming responses, use chunked transfer encoding instead of a fixed Content-Length
- Check for proxies or middleware that modify the body without updating Content-Length
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/http/error.rs:60 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/25c8d07fe4500ca4.
Report an issue: GitHub.
Appendix: source
Thrown at src/http/error.rs:60
#[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")]
ShortRead,
#[error("WantRead")]View on GitHub (pinned to 8c5296ac45)