-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
set HttpCompressionMiddleware priority to 810 #1895
Comments
@kmike , did you consider moving
|
@redapple it turns out this is not really related to CookiesMiddleware; scrapy-splash doesn't use it to handle cookies in the end, and handles cookies using a custom . scrapy-splash uses original JSON response.body to set response.status, response.headers, response.url and a new response.body. Any other downloader middleware which wants to return a new response based on current response body must be put closer to Engine side than HttpCompressionMiddleware. Currently it means that RedirectMiddleware and CookiesMiddleware won't process such adjusted responses. |
As full-responses from transport layer are sent to the first middleware -- downloader-side, it does makes sense to have an uncompressed response to process soon enough.
|
Currently DOWNLOADER_MIDDLEWARE options looks like this:
I encountered a case where this order causes problems: I want to add custom headers to response based on its contents (load cookies from JSON response body and handle them using standard CookiesMiddleware). But because
CookiesMiddleware.process_response
is called beforeHttpCompressionMiddleware.process_response
this is not possible with a default middleware order - body is not uncompressed yet.This change will move HttpCompressionMiddleware after RedirectMiddleware (i.e. responses will be decompressed prior to redirect handling); it means Scrapy can do a bit more work for redirect responses. I don't think this is a problem because 301, 302, 303, 307 responses shouldn't have bodies.
The text was updated successfully, but these errors were encountered: