fix: Pass verify parameter to Rust clients for TLS certificate validation#38
Merged
Conversation
…tion Previously, verify=False was only passed to HTTPTransport but the Rust _Client/_AsyncClient were created without this setting. When requests fell back to self._client.send() instead of using the transport, TLS certificate verification was still enabled. Changes: - Add verify parameter to Client::new_impl() and AsyncClient::new_impl() - Pass verify from Python Client/AsyncClient to Rust constructors - Use tls_danger_accept_invalid_certs() in Rust clients when verify=false - Update transport.rs to use non-deprecated tls_danger_accept_invalid_certs This fixes HTTPS requests to servers with self-signed certificates when using Client(verify=False) or AsyncClient(verify=False). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace extract() with cast() for URL type checking to avoid PyErr creation on type mismatch (client.rs, async_client.rs) - Add frozen attribute to immutable types URL and QueryParams to eliminate runtime borrow checking - Add freelists to hot-path types Response (64), Cookies (64), and QueryParams (128) to reduce allocation overhead - Add JSON buffer pre-allocation based on object size estimate - Use is_instance_of() for Headers/Cookies extraction to avoid PyErr creation on type mismatch All 1406 tests pass. Performance remains competitive with requestx being 77% faster than httpx in sync mode and 141% faster in async mode. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove the custom time_phase! macro and profiling module. External tools like py-spy, flamegraph, and tracing-flame provide better profiling capabilities without maintenance burden. Changes: - Delete src/profiling.rs (time_phase! macro, PhaseTimer, start_phase!) - Remove mod profiling from lib.rs - Remove unused import from client.rs - Remove profiling feature from Cargo.toml - Convert 7 time_phase! usages in async_client.rs to plain code blocks Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Design for making requestx.Client compatible with AI SDKs (OpenAI, Anthropic) by patching isinstance checks. Approved approach uses global type.__instancecheck__ patching to recognize requestx clients when checked against httpx.Client.
Add _patch_httpx_isinstance() to make requestx.Client pass isinstance checks against httpx.Client. Enables compatibility with AI SDKs (OpenAI, Anthropic) that validate http_client parameters. Changes: - Monkey-patch builtins.isinstance to recognize requestx clients - Fix AsyncClient.timeout property to store value locally - Detection uses class name + module name matching - Patched globally at import time All 7 SDK compatibility tests now pass.
Show OpenAI and Anthropic SDK integration with requestx.Client as http_client parameter. Demonstrates drop-in performance upgrade for AI SDK users.
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.
Summary
verify=Falsefor HTTPS requests to servers with self-signed certificatesverifyparameter from Python Client/AsyncClient to Rust_Client/_AsyncClientconstructorstls_danger_accept_invalid_certs()(non-deprecated API) in Rust clients whenverify=falsetransport.rsto use non-deprecatedtls_danger_accept_invalid_certsmethodTest plan
Client(verify=False)successfully connects to https://self-signed.badssl.com/AsyncClient(verify=False)successfully connects to https://self-signed.badssl.com/Client(verify=True)correctly rejects self-signed certificates🤖 Generated with Claude Code