-
Notifications
You must be signed in to change notification settings - Fork 0
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
[UPX-6] Replace requests with httpx #5
Conversation
WalkthroughThe changes update the project's dependencies and testing framework by replacing the Changes
Sequence Diagram(s)sequenceDiagram
participant U as UTApi
participant X as httpx Client
participant S as Server
U->>X: Initiate HTTP request
X->>S: Send request
S-->>X: Return HTTP response
X-->>U: Provide response
U->>U: Handle exceptions (raise httpx.HTTPError)
sequenceDiagram
participant T as Test Suite
participant U as UTApi
participant R as respx Mock Router
participant X as httpx Client
T->>U: Call API method
U->>X: Send HTTP request
R->>X: Intercept request & supply mock response
X-->>U: Return mocked response
U-->>T: Deliver result
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
bae87ee
to
945e9e2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
tests/test_client.py (1)
72-72
: Remove debug print statement.The print statement
print(type(respx_mock))
appears to be a debugging artifact and should be removed.- print(type(respx_mock))
upyloadthing/client.py (1)
116-128
: Consider adding timeout configuration for httpx client.While the migration to httpx is correct, it's recommended to configure timeouts explicitly to prevent hanging requests. httpx provides comprehensive timeout controls.
with httpx.Client() as client: if data is None: response = client.request( - method=method, url=url, headers=headers + method=method, url=url, headers=headers, + timeout=httpx.Timeout(10.0, connect=5.0) ) elif has_files: response = client.request( - method=method, url=url, headers=headers, files=data + method=method, url=url, headers=headers, files=data, + timeout=httpx.Timeout(30.0, connect=5.0) # Longer timeout for file uploads ) else: response = client.request( - method=method, url=url, headers=headers, json=data + method=method, url=url, headers=headers, json=data, + timeout=httpx.Timeout(10.0, connect=5.0) )
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
poetry.lock
is excluded by!**/*.lock
📒 Files selected for processing (3)
pyproject.toml
(2 hunks)tests/test_client.py
(10 hunks)upyloadthing/client.py
(3 hunks)
🔇 Additional comments (3)
tests/test_client.py (1)
68-222
: LGTM! Test suite successfully migrated to respx.The migration from responses to respx is complete and well-implemented:
- All test functions correctly use the @respx.mock() decorator
- Type hints added for respx_mock parameter
- Test coverage remains comprehensive
🧰 Tools
🪛 Gitleaks (8.21.2)
165-165: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
pyproject.toml (2)
11-17
: LGTM! Dependencies successfully updated.The migration from requests to httpx is properly reflected in the dependencies:
- Removed requests and requests-toolbelt
- Added httpx with appropriate version constraint
- Updated test dependencies from responses to respx
Also applies to: 24-30
16-16
:✅ Verification successful
Verify httpx version constraint.
Let's verify that we're using the latest stable version of httpx.
🌐 Web query:
What is the latest stable version of httpx?
💡 Result:
The latest stable versions of
httpx
depend on which specific package you're referring to:For Python's HTTPX client library (encode/httpx):
- Version:
0.28.1
- Release Date: December 6th, 2024[1][5]
- Key changes:
- Deprecated SSL configuration parameters (
verify
as string argument andcert
)[1]- Removed deprecated
proxies
andapp
arguments[1]- Improved URL percent escaping based on WHATWG spec[1]
For ProjectDiscovery's network scanner (projectdiscovery/httpx):
- Version:
v1.6.10
- Release Date: October 20th, 2024[7]
- Key updates:
- Fixed probe functionality with JSON/CSV outputs[7]
- Added screenshot idle configuration support[7]
- CPU optimization via fastdialer v0.3 update[7]
These are two distinct projects sharing the same name but serving different purposes:
- The Python library focuses on HTTP client functionality
- The Go-based tool specializes in network reconnaissance and scanning
Always verify which package you're using through context clues like programming language (Python vs Go) or documentation references[5][7].
Citations:
- 1: https://github.com/encode/httpx/releases
- 2: https://pypi.org/project/httpx/0.23.2/
- 3: https://pub.dev/packages/httpx/versions
- 4: https://formulae.brew.sh/formula/httpx
- 5: https://pypi.org/project/httpx/
- 6: https://readthedocs.org/projects/httpx/
- 7: https://github.com/projectdiscovery/httpx/releases
- 8: https://www.npmjs.org/package/@httpx/stable-hash
- 9: https://www.python-httpx.org/http2/
HTTPX Dependency Version Confirmed
After verifying that the latest stable version of Python's HTTPX client is 0.28.1, the dependency specification in your
pyproject.toml
(i.e.,"httpx (>=0.28.1,<0.29.0)"
) is accurate and up-to-date.
Replace requests HTTP client library with httpx for HTTP operations
Switches the HTTP client implementation from requests to httpx for making HTTP requests. This change modernizes the HTTP client layer while maintaining similar functionality with async-compatible tooling.
Changes
Impact
Summary by CodeRabbit
Chores
Refactor
Tests