-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Extract shared HTTP transport into codex-http-client #31323
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
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| # codex-client | ||
|
|
||
| Generic transport layer that wraps HTTP requests, retries, and streaming primitives without any Codex/OpenAI awareness. | ||
| Higher-level request policy layered on `codex-http-client` without any Codex/OpenAI API awareness. | ||
|
|
||
| - Defines `HttpTransport` and a default `ReqwestTransport` plus thin `Request`/`Response` types. | ||
| - Provides retry utilities (`RetryPolicy`, `RetryOn`, `run_with_retry`, `backoff`) that callers plug into for unary and streaming calls. | ||
| - Supplies the `sse_stream` helper to turn byte streams into raw SSE `data:` frames with idle timeouts and surfaced stream errors. | ||
| - Consumed by higher-level crates like `codex-api`; it stays neutral on endpoints, headers, or API-specific error shapes. | ||
| - Defines the request telemetry callback used by higher-level clients. | ||
| - Re-exports the low-level HTTP types temporarily so consumers can migrate to `codex-http-client` incrementally. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,49 +1,13 @@ | ||
| mod chatgpt_cloudflare_cookies; | ||
| mod chatgpt_hosts; | ||
| mod custom_ca; | ||
| mod default_client; | ||
| mod error; | ||
| mod outbound_proxy; | ||
| mod request; | ||
| mod retry; | ||
| mod sse; | ||
| mod telemetry; | ||
| mod transport; | ||
|
|
||
| pub use crate::chatgpt_cloudflare_cookies::with_chatgpt_cloudflare_cookie_store; | ||
| pub use crate::chatgpt_hosts::is_allowed_chatgpt_host; | ||
| pub use crate::custom_ca::BuildCustomCaTransportError; | ||
| /// Test-only subprocess hook for custom CA coverage. | ||
| /// | ||
| /// This stays public only so the `custom_ca_probe` binary target can reuse the shared helper. It | ||
| /// is hidden from normal docs because ordinary callers should use | ||
| /// [`build_reqwest_client_with_custom_ca`] instead. | ||
| #[doc(hidden)] | ||
| pub use crate::custom_ca::build_reqwest_client_for_subprocess_tests; | ||
| pub use crate::custom_ca::build_reqwest_client_with_custom_ca; | ||
| pub use crate::custom_ca::maybe_build_rustls_client_config_with_custom_ca; | ||
| pub use crate::default_client::CodexHttpClient; | ||
| pub use crate::default_client::CodexRequestBuilder; | ||
| pub use crate::error::StreamError; | ||
| pub use crate::error::TransportError; | ||
| pub use crate::outbound_proxy::BuildRouteAwareHttpClientError; | ||
| pub use crate::outbound_proxy::ClientRouteClass; | ||
| pub use crate::outbound_proxy::OutboundProxyConfig; | ||
| pub use crate::outbound_proxy::RouteFailureClass; | ||
| pub use crate::outbound_proxy::build_reqwest_client_for_route; | ||
| pub use crate::request::EncodedJsonBody; | ||
| pub use crate::request::PreparedRequestBody; | ||
| pub use crate::request::Request; | ||
| pub use crate::request::RequestBody; | ||
| pub use crate::request::RequestCompression; | ||
| pub use crate::request::Response; | ||
| pub use crate::retry::RetryOn; | ||
| pub use crate::retry::RetryPolicy; | ||
| pub use crate::retry::backoff; | ||
| pub use crate::retry::run_with_retry; | ||
| pub use crate::sse::sse_stream; | ||
| pub use crate::telemetry::RequestTelemetry; | ||
| pub use crate::transport::ByteStream; | ||
| pub use crate::transport::HttpTransport; | ||
| pub use crate::transport::ReqwestTransport; | ||
| pub use crate::transport::StreamResponse; | ||
| pub use codex_http_client::HttpClient as CodexHttpClient; | ||
| pub use codex_http_client::RequestBuilder as CodexRequestBuilder; | ||
| pub use codex_http_client::*; |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| load("//:defs.bzl", "codex_rust_crate") | ||
|
|
||
| codex_rust_crate( | ||
| name = "http-client", | ||
| compile_data = glob(["tests/fixtures/**"]), | ||
| crate_name = "codex_http_client", | ||
| ) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| [package] | ||
| edition.workspace = true | ||
| license.workspace = true | ||
| name = "codex-http-client" | ||
| version.workspace = true | ||
|
|
||
| [dependencies] | ||
| bytes = { workspace = true } | ||
| codex-utils-rustls-provider = { workspace = true } | ||
| futures = { workspace = true } | ||
| http = { workspace = true } | ||
| opentelemetry = { workspace = true } | ||
| reqwest = { workspace = true, features = ["json", "rustls-tls-native-roots", "stream"] } | ||
| rustls = { workspace = true } | ||
| rustls-native-certs = { workspace = true } | ||
| rustls-pki-types = { workspace = true } | ||
| serde = { workspace = true, features = ["derive"] } | ||
| serde_json = { workspace = true } | ||
| thiserror = { workspace = true } | ||
| tokio = { workspace = true, features = ["macros", "rt", "time", "sync"] } | ||
| tracing = { workspace = true } | ||
| tracing-opentelemetry = { workspace = true } | ||
| zstd = { workspace = true } | ||
|
|
||
| [target.'cfg(any(target_os = "windows", target_os = "macos"))'.dependencies] | ||
| sha2 = { workspace = true } | ||
|
|
||
| [target.'cfg(target_os = "macos")'.dependencies] | ||
| system-configuration = { workspace = true } | ||
|
|
||
| [target.'cfg(target_os = "windows")'.dependencies] | ||
| windows-sys = { version = "0.52", features = [ | ||
| "Win32_Foundation", | ||
| "Win32_Networking_WinHttp", | ||
| ] } | ||
|
|
||
| [lints] | ||
| workspace = true | ||
|
|
||
| [dev-dependencies] | ||
| codex-utils-cargo-bin = { workspace = true } | ||
| opentelemetry_sdk = { workspace = true } | ||
| pretty_assertions = { workspace = true } | ||
| rcgen = { workspace = true } | ||
| tempfile = { workspace = true } | ||
| tracing-subscriber = { workspace = true } | ||
|
|
||
| [lib] | ||
| doctest = false |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # codex-http-client | ||
|
|
||
| Low-level HTTP transport shared by Codex crates. | ||
|
|
||
| - Defines the request, response, streaming, and transport types used for outbound HTTP calls. | ||
| - Owns the `reqwest` implementation, custom CA handling, and ChatGPT Cloudflare cookie policy. | ||
| - Resolves system, PAC/WPAD, environment, and direct proxy routes for supported clients. | ||
|
|
||
| Higher-level retry, SSE, and request telemetry policy remains in `codex-client`. |
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
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
2 changes: 1 addition & 1 deletion
2
codex-rs/codex-client/src/chatgpt_hosts.rs → codex-rs/http-client/src/chatgpt_hosts.rs
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
2 changes: 1 addition & 1 deletion
2
codex-rs/codex-client/src/custom_ca.rs → codex-rs/http-client/src/custom_ca.rs
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.