Skip to content

fix: Pass verify parameter to Rust clients for TLS certificate validation#38

Merged
wuqunfei merged 23 commits into
mainfrom
feature/v5-fully-compatible-version
Feb 25, 2026
Merged

fix: Pass verify parameter to Rust clients for TLS certificate validation#38
wuqunfei merged 23 commits into
mainfrom
feature/v5-fully-compatible-version

Conversation

@wuqunfei
Copy link
Copy Markdown
Member

@wuqunfei wuqunfei commented Feb 7, 2026

Summary

  • Fix verify=False for HTTPS requests to servers with self-signed certificates
  • Pass verify parameter from Python Client/AsyncClient to Rust _Client/_AsyncClient constructors
  • Use tls_danger_accept_invalid_certs() (non-deprecated API) in Rust clients when verify=false
  • Update transport.rs to use non-deprecated tls_danger_accept_invalid_certs method

Test plan

  • Verified Client(verify=False) successfully connects to https://self-signed.badssl.com/
  • Verified AsyncClient(verify=False) successfully connects to https://self-signed.badssl.com/
  • Verified Client(verify=True) correctly rejects self-signed certificates
  • All 1406 tests pass in tests_requestx/
  • All 1406 tests pass in tests_httpx/

🤖 Generated with Claude Code

wuqunfei and others added 23 commits February 6, 2026 22:37
…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.
@wuqunfei wuqunfei merged commit 5a71447 into main Feb 25, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant