Skip to content
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

Added error handling for the case when Brotli is not imported scrapy#4697 #5480

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KishanPipariya
Copy link

@KishanPipariya KishanPipariya commented Apr 15, 2022

I added the necessary error generation. Are any further changes required?

Closes: #4697

@KishanPipariya KishanPipariya marked this pull request as ready for review April 15, 2022 06:31
@wRAR
Copy link
Member

wRAR commented Apr 15, 2022

I don't think it should be ImportError and I'm also not 100% sure it should be an exception at all (but actually running a callback here is not that useful as it certainly won't get the correctly decompressed response).

@codecov
Copy link

codecov bot commented Apr 15, 2022

Codecov Report

Merging #5480 (54c14b9) into master (8c3e5a2) will decrease coverage by 0.20%.
The diff coverage is 50.00%.

@@            Coverage Diff             @@
##           master    #5480      +/-   ##
==========================================
- Coverage   88.77%   88.57%   -0.21%     
==========================================
  Files         163      163              
  Lines       10666    10668       +2     
  Branches     1818     1819       +1     
==========================================
- Hits         9469     9449      -20     
- Misses        922      942      +20     
- Partials      275      277       +2     
Impacted Files Coverage Δ
scrapy/downloadermiddlewares/httpcompression.py 90.00% <50.00%> (-2.65%) ⬇️
scrapy/robotstxt.py 75.30% <0.00%> (-22.23%) ⬇️
scrapy/core/downloader/__init__.py 90.97% <0.00%> (-1.51%) ⬇️

@KishanPipariya
Copy link
Author

What could be an appopriate response by the program?

@KishanPipariya
Copy link
Author

What kind of response should the user receive?

@Gallaecio
Copy link
Member

Could you also address the 1st bullet point of #4697?

I imagine we should create a boolean self._can_decode_br in __init__, and then in process_request checking if the Accept-Encoding header exists in the request, and self._can_decode_br is False, and br is one of the encodings in the header. If so, we log a warning.

I am also thinking that, instead of raising an exception if the response is br-encoded, we could remove br from Accept-Encoding in process_response, in addition to logging a warning (that would now also indicate the automatic drop of the unsupported encoding from the header).

@KishanPipariya
Copy link
Author

Will try to implement your suggestions
Thanks for the help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warn about br handling if brotlipy is not installed
3 participants