-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTP/1.0 responses missing Content-Length #56277
Comments
I noticed this bug because I was using Nginx as a reverse proxy in front of a Node.js process. Nginx, by default, proxies all requests upsteam as HTTP/1.0. (This behavior can be overridden using Nginx's As a sidenote, omitting the
From https://www.ra.ethz.ch/cdstore/www8/data/2136/pdf/pd1.pdf |
I guess no one is going to object to a pull request but sending Content-Length is at best a marginal improvement because that's only possible when the response size is known upfront. Node can't send Transfer-Encoding headers to http/1.0 clients, so your nginx proxy would still be serving up responses without Content-Length. |
The problem is that It is precisely the lack of chunked encoding that makes a |
Is the lack of Content-Length actually causing issues for you or is it just something you noticed? Because you're going to have to deal with responses without it anyway so what exactly do you gain when some include it? |
It is my clients, not me, that has to deal with my responses, so I like to include a I worked around the problem by configuring Nginx to send HTTP/1.1 requests to Node.js, so this is no longer causing any issues for me. But because it took me several hours to diagnose, I felt I had a duty to report it as inconsistent behavior. If fixing it is too hard, others might at least find this issue when they search. |
Version
v22.10.0
Platform
Subsystem
http
What steps will reproduce the bug?
Start a simple HTTP server.
Send it an HTTP/1.0 request using cURL.
How often does it reproduce? Is there a required condition?
Consistently reproducible.
What is the expected behavior? Why is that the expected behavior?
I would expect the response to include a
Content-Length
header.What do you see instead?
The response does not include a
Content-Length
header.Additional information
If we instead send an HTTP/1.1 request (either with or without
Keep-Alive
), theContent-Length
header is included.This seems strange. I would expect to see a
Content-Length
header regardless of whether the request was HTTP/1.0 or HTTP/1.1.Attaching a debugger, the HTTP/1.0 request triggers the former clause and the HTTP/1.1 request triggers the latter clause in the following HTTP server code.
node/lib/_http_outgoing.js
Lines 553 to 559 in 2cd385e
The text was updated successfully, but these errors were encountered: