-
Notifications
You must be signed in to change notification settings - Fork 28
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
Use the new HttpResponse that replaces ResponseData in web_poet #67
Conversation
Reference PR from web_poet: scrapinghub/web-poet#30
Codecov Report
@@ Coverage Diff @@
## master #67 +/- ##
=======================================
Coverage 95.96% 95.96%
=======================================
Files 9 9
Lines 372 372
=======================================
Hits 357 357
Misses 15 15
|
|
||
"""Build a ``web_poet.HttpResponse`` instance using a Scrapy ``Response``""" | ||
return [ | ||
HttpResponse( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HttpResponse( | |
web_poet.HttpResponse( |
response_data["url"], | ||
response_data["body"], | ||
status=response_data["status"], | ||
headers=HttpResponseHeaders.from_bytes_dict(response_data["headers"]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is HttpResponseHeaders.from_bytes_dict needed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kmike It's because Scrapy headers look like this:
scrapy_headers = {
b"Content-Encoding": [b"gzip", b"br"],
b"Content-Type": [b"text/html"],
b"content-length": b"648",
}
Reference for the motivation: scrapinghub/web-poet#33 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not wrong, here the result is not coming from Scrapy, it's a part of serialization / deserialization for cache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR looks good @BurnzZ!
Co-authored-by: Mikhail Korobov <[email protected]>
Reference PR from
web_poet
: scrapinghub/web-poet#30.This also uses the small enhancement in scrapinghub/web-poet#33.
Checklist before release:
setup.py
andtox.ini
that prevents breaking the CI on this PR