-
Notifications
You must be signed in to change notification settings - Fork 120
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
Process request headers #38
Conversation
Codecov Report
@@ Coverage Diff @@
## master #38 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 3 4 +1
Lines 185 203 +18
=========================================
+ Hits 185 203 +18
Continue to review full report at Codecov.
|
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.
Looks good to me, pending the documentation.
if crawler.settings.get("PLAYWRIGHT_PROCESS_REQUEST_HEADERS"): | ||
self.process_request_headers = load_object( | ||
crawler.settings["PLAYWRIGHT_PROCESS_REQUEST_HEADERS"] | ||
) | ||
else: | ||
self.process_request_headers = use_scrapy_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.
Shame, this could be a 1-liner in Scrapy 2.4+ 🙁
(technically also here, but I’m guessing you don’t want to have load_object
parse a string in the default scenario)
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.
Indeed, I'd like to avoid any (admittedly small) overhead if we already have the object.
This is a nice catch, I was planning on documenting the setting as accepting either paths or functions directly, but didn't remember that was only valid on Scrapy 2.4+. I'll be sure to mention that when I write the docs, thanks!
Partially address #36.
Allow to override the processing of request headers via the
PLAYWRIGHT_PROCESS_REQUEST_HEADERS
setting. For instance, setPLAYWRIGHT_PROCESS_REQUEST_HEADERS=scrapy_playwright.headers.use_playwright_headers
to use Playwright headers and ignore the ones coming from Scrapy.Names are subject to change, I'm open to suggestions.
Tasks: