From 929b5d104788d7053eb7f3e1d48066e64da5aec8 Mon Sep 17 00:00:00 2001 From: Kenneth Cruz Date: Wed, 11 May 2022 11:34:15 +1000 Subject: [PATCH] `playwright_request.headers["user-agent"]` was not replaced for some reason, so return a new dict instance with replaced `user-agent` --- scrapy_playwright/headers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scrapy_playwright/headers.py b/scrapy_playwright/headers.py index d8906231..d450db3a 100644 --- a/scrapy_playwright/headers.py +++ b/scrapy_playwright/headers.py @@ -30,7 +30,10 @@ async def use_scrapy_headers( # override user agent, for consistency with other requests if headers.get("user-agent"): - playwright_request.headers["user-agent"] = headers["user-agent"] + return { + **playwright_request.headers, + "user-agent": headers["user-agent"], + } return playwright_request.headers