Skip to content

Commit be87523

Browse files
committed
Return proper headers for download
1 parent 243d2f3 commit be87523

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

scrapy_playwright/handler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import logging
33
import platform
44
from contextlib import suppress
5-
from dataclasses import dataclass
5+
from dataclasses import dataclass, field as dataclass_field
66
from ipaddress import ip_address
77
from time import time
88
from typing import Awaitable, Callable, Dict, Optional, Tuple, Type, TypeVar, Union
@@ -105,6 +105,7 @@ class Download:
105105
suggested_filename: str = ""
106106
exception: Optional[Exception] = None
107107
response_status: int = 200
108+
headers: dict = dataclass_field(default_factory=dict)
108109

109110
def __bool__(self) -> bool:
110111
return bool(self.body) or bool(self.exception)
@@ -436,6 +437,7 @@ async def _download_request_with_page(
436437
url=download.url,
437438
status=download.response_status,
438439
body=download.body,
440+
headers=Headers(download.headers),
439441
request=request,
440442
flags=["playwright"],
441443
)
@@ -477,6 +479,7 @@ async def _handle_download(dwnld: PlaywrightDownload) -> None:
477479

478480
async def _handle_response(response: PlaywrightResponse) -> None:
479481
download.response_status = response.status
482+
download.headers = await response.all_headers()
480483
download_started.set()
481484

482485
page_goto_kwargs = request.meta.get("playwright_page_goto_kwargs") or {}

0 commit comments

Comments
 (0)