Skip to content

Commit 10f7cce

Browse files
committed
fix: use HttpHeaders type in Scrapy integration
1 parent 8cd2f2c commit 10f7cce

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ repos:
1313
language: system
1414
pass_filenames: false
1515

16-
- id: unit-tests
17-
name: Run unit tests
18-
entry: make unit-tests
19-
language: system
20-
pass_filenames: false
21-
2216
- id: check-changelog-entry
2317
name: Check changelog entry
2418
entry: make check-changelog-entry

src/apify/scrapy/requests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
) from exc
1717

1818
from crawlee import Request as CrawleeRequest
19+
from crawlee._types import HttpHeaders
1920
from crawlee._utils.crypto import crypto_random_object_id
2021
from crawlee._utils.requests import compute_unique_key, unique_key_to_request_id
2122

@@ -79,7 +80,7 @@ def to_apify_request(scrapy_request: Request, spider: Spider) -> CrawleeRequest
7980

8081
# Convert Scrapy's headers to a dictionary and store them in the apify_request
8182
if isinstance(scrapy_request.headers, Headers):
82-
apify_request.headers = dict(scrapy_request.headers.to_unicode_dict())
83+
apify_request.headers = HttpHeaders(scrapy_request.headers.to_unicode_dict())
8384
else:
8485
Actor.log.warning(
8586
f'Invalid scrapy_request.headers type, not scrapy.http.headers.Headers: {scrapy_request.headers}'

0 commit comments

Comments
 (0)