-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
urllib sets wrong Content-Length
for pseudo files on Linux
#93296
Comments
urllib.request.FileHandler.open_local_file
sets Content-length: 0
for non-empty pseudo filesContent-Length
for pseudo files on Linux
I'm not sure this really is a bug. What would you expect? |
I would expect a value of |
Header |
AFAIK, a similar discrepancy can happen if the file changes while it's being prepared/sent.
The situation is the same as when a HTTP server sends a mismatched Content-Length, except here it's the kernel, not a server. It's up to you to handle it. IMO, this is not an issue. If there are no objections, I'll close in a month. |
This is interesting, it used to return no content, but that was changed in 2016 curl/curl#681 (comment)
As a user I'd expect a server to handle known cases, but I don't insist on keeping the issue open. |
Bug report
A value of the
Content-length
header returned byurllib.request.FileHandler.open_local_file
may mismatch the length of data on Linux.This happens when a file from a special file system (e.g., procfs or sysfs) is requested.
open_local_file
relies onst_size
;st_size
is equal to zero for pseudo files on Linux.cpython/Lib/urllib/request.py
Lines 1506 to 1511 in 8a0d9a6
Example
Your environment
The text was updated successfully, but these errors were encountered: