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
Support Content-Length header in responses #5034
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5034 +/- ##
==========================================
- Coverage 88.01% 87.78% -0.23%
==========================================
Files 158 158
Lines 9726 9768 +42
Branches 1433 1438 +5
==========================================
+ Hits 8560 8575 +15
- Misses 911 935 +24
- Partials 255 258 +3
|
To do this without relying on private parts of the Twisted API, I think we would need to basically copy the whole Before I go that way, I’ll try the upstream approach: send a patch to Twisted to stop skipping connection headers. If they are OK with that, we would only need to mention this in the documentation (connection headers in HTTP1.1 require Twisted N.N.N, and are otherwise stripped). |
Upstream issue: https://twistedmatrix.com/trac/ticket/10126 I have a patch ready locally, only need to update test expectations, but I don’t know how to run the tests 😅 |
Pull request sent upstream: twisted/twisted#1561 |
Twisted doesn't really need to change for this, nor does Scrapy need to copy the whole client implementation. Instead, Scrapy can check the response object for the |
I see https://twistedmatrix.com/documents/21.2.0/api/twisted.web.iweb.IResponse.html#length states that the field contains the expected length. |
I’ve just created #5057 to handle this on the Scrapy side using the public Twisted API. @exarkun Should we close twisted/twisted#1561 and https://twistedmatrix.com/trac/ticket/10126 ? While I still see no good reason to strip connection headers from responses, I cannot think of real-life scenarios where the other connection headers are relevant, or where the position of the |
I reckon it should be closed, yes, unless there is another use-case to consider. |
Fixes #5009
To do: