Skip to content

Commit 12eb537

Browse files
committed
Merge remote-tracking branch 'origin/main' into close-inactive-contexts
2 parents a609ae5 + f1004bd commit 12eb537

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.0.30
2+
current_version = 0.0.31
33
commit = True
44
tag = True
55

docs/changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# scrapy-playwright changelog
22

33

4+
### [v0.0.31](https://github.com/scrapy-plugins/scrapy-playwright/releases/tag/v0.0.31) (2023-08-28)
5+
6+
* Do not fail when getting referer header for debug log messages (#225)
7+
* Do not override headers with values from asset requests (#226)
8+
9+
410
### [v0.0.30](https://github.com/scrapy-plugins/scrapy-playwright/releases/tag/v0.0.30) (2023-08-17)
511

612
* Fix page_init_callback duplication (#222)

scrapy_playwright/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.0.30"
1+
__version__ = "0.0.31"

scrapy_playwright/handler.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -524,13 +524,8 @@ async def _request_handler(route: Route, playwright_request: PlaywrightRequest)
524524
self.browser_type_name, playwright_request, headers
525525
)
526526
)
527-
# the request that reaches the callback should contain the final headers
528-
headers.clear()
529-
headers.update(final_headers)
530-
del final_headers
531527

532-
# if the request is triggered by scrapy, not playwright
533-
original_playwright_method: str = playwright_request.method
528+
# if the current request corresponds to the original scrapy one
534529
if (
535530
playwright_request.url.rstrip("/") == url.rstrip("/")
536531
and playwright_request.is_navigation_request()
@@ -539,7 +534,13 @@ async def _request_handler(route: Route, playwright_request: PlaywrightRequest)
539534
overrides["method"] = method
540535
if body:
541536
overrides["post_data"] = body.decode(encoding)
537+
# the request that reaches the callback should contain the final headers
538+
headers.clear()
539+
headers.update(final_headers)
542540

541+
del final_headers
542+
543+
original_playwright_method: str = playwright_request.method
543544
try:
544545
await route.continue_(**overrides)
545546
if overrides.get("method"):

scrapy_playwright/headers.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@ async def use_scrapy_headers(
2323
scrapy_headers_str.setdefault("user-agent", playwright_headers.get("user-agent"))
2424

2525
if playwright_request.is_navigation_request():
26+
# if referer header is set via playwright_page_goto_kwargs
27+
if referer := playwright_headers.get("referer"):
28+
scrapy_headers_str.setdefault("referer", referer)
29+
30+
# otherwise it fails with playwright.helper.Error: NS_ERROR_NET_RESET
2631
if browser_type == "firefox":
27-
# otherwise this fails with playwright.helper.Error: NS_ERROR_NET_RESET
2832
scrapy_headers_str["host"] = urlparse(playwright_request.url).netloc
33+
2934
return scrapy_headers_str
3035

3136
# override user agent, for consistency with other requests

0 commit comments

Comments
 (0)