Skip to content
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

Drop the Set-Cookie header #132

Merged
merged 8 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion scrapy_zyte_api/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ class ZyteAPIMixin:
# Zyte API already decompresses the HTTP Response Body. Scrapy's
# HttpCompressionMiddleware will error out when it attempts to
# decompress an already decompressed body based on this header.
"content-encoding"
"content-encoding",
# Cookies should be fetched from experimental.responseCookies only, the
# Set-Cookie header may define cookies from the main HTTP response that
# were overriden later on, e.g. during browser rendering.
"set-cookie",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should remove headers when httpResponseBody = True.

}

def __init__(self, *args, raw_api_response: Optional[Dict] = None, **kwargs):
Expand Down
1 change: 1 addition & 0 deletions tests/test_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ def test_response_headers_removal(api_response, cls):
"""
additional_headers = [
{"name": "Content-Encoding", "value": "gzip"},
{"name": "Set-Cookie", "value": "a=b"},
{"name": "X-Some-Other-Value", "value": "123"},
]
raw_response = api_response()
Expand Down