fix(httpx): Handle cookies correctly on every request path - #2179
Open
Mantisus wants to merge 3 commits into
Open
fix(httpx): Handle cookies correctly on every request path#2179Mantisus wants to merge 3 commits into
Mantisus wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates HttpxHttpClient to unify cookie handling across request paths (including redirects and proxies) and adjusts header generation so the default “browser-like” headers come from a single sampled profile. It also reshuffles/extends unit tests to validate cookie behavior across clients and introduces a deprecation warning for HeaderGenerator.get_common_headers().
Changes:
- Reworked
HttpxHttpClientrequest construction and transport behavior to rebuildCookieheaders per hop and to keep cookie state inSession(including when proxying). - Updated header generation to request a consistent set of headers from
HeaderGenerator.get_specific_headers()(single profile sample) and added tests around this. - Consolidated cookie/session tests across HTTP clients and added proxy + redirect coverage; deprecated
get_common_headers()with a warning and updated tests accordingly.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/http_clients/test_impit.py | Removes Impit-specific cookie/session tests that were moved to shared HTTP client test coverage. |
| tests/unit/http_clients/test_httpx.py | Adds Httpx-specific tests for same-origin logic, proxy-kwarg behavior, and header sampling behavior. |
| tests/unit/http_clients/test_http_clients.py | Adds shared cookie/session behavior tests across all HTTP clients, including proxy scenarios. |
| tests/unit/fingerprint_suite/test_header_generator.py | Updates test to assert the new deprecation warning for get_common_headers(). |
| src/crawlee/http_clients/_httpx.py | Implements unified cookie handling across request paths (redirects + proxies), refactors request building, and optimizes generated header selection. |
| src/crawlee/fingerprint_suite/_header_generator.py | Marks get_common_headers() as deprecated and emits a DeprecationWarning. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
HttpxHttpClientsends a request.HttpxHttpClient.Testing