Skip to content

Use of HTTP_PROXY env var in reqwest clients - #3455

Closed
orbli wants to merge 17 commits into
openai:mainfrom
orbli:feat/env-proxy-client
Closed

orbli wants to merge 17 commits into
openai:mainfrom
orbli:feat/env-proxy-client

Conversation

@orbli

@orbli orbli commented Sep 11, 2025

Copy link
Copy Markdown

What

  • Introduce codex_core::default_client::apply_env_proxy(..) honoring HTTPS_PROXY → HTTP_PROXY → ALL_PROXY.
  • Use codex_core::default_client::create_client() for OAuth/token flows in codex-login.
  • Apply env proxy to codex-ollama’s reqwest::Client::builder().

Touched files:

  • codex-rs/core/src/default_client.rs
  • codex-rs/login/src/server.rs
  • codex-rs/ollama/src/client.rs

Why

  • Enable Codex CLI to work in proxy-restricted environments without per-caller boilerplate.
  • Keep user agent and originator headers consistent across all HTTP clients.

How

  • New helper apply_env_proxy(builder) reads the first non-empty of HTTPS_PROXY, HTTP_PROXY, ALL_PROXY and applies reqwest::Proxy::all(..). Invalid values are ignored with a warning.
  • create_client() now passes its builder through apply_env_proxy while preserving default headers and UA.
  • Login/token calls and Ollama client construction now use the centralized client/builder.

User Impact

  • When proxy env vars are unset: no behavior change.
  • When set: Codex network calls route through the configured proxy.

Testing

  • Formatted with cargo fmt.
  • Targeted tests expected to pass; environment used here is network-restricted so I could not run cargo test to fetch deps. CI should validate.

Backward Compatibility

  • Fully backward compatible when env vars are unset or invalid (invalid proxy is ignored with a log warning).

Follow-ups (optional)

  • Consider supporting lowercase env variants (https_proxy, etc.) and NO_PROXY if desired.

CLA: I have read the CLA Document and I hereby sign the CLA

- Introduce apply_env_proxy(..) honoring HTTPS_PROXY/HTTP_PROXY/ALL_PROXY
- Use default client for login token exchange
- Apply proxy to ollama client builder

This centralizes proxy handling and preserves originator/User-Agent headers.

Signed-off-by: orb li <[email protected]>
@github-actions

github-actions Bot commented Sep 11, 2025 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@orbli

orbli commented Sep 11, 2025

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@orbli orbli changed the title Respect HTTPS_PROXY/HTTP_PROXY/ALL_PROXY in reqwest clients; centralize in codex-core Use of HTTP_PROXY env var in reqwest clients Sep 11, 2025
github-actions Bot added a commit that referenced this pull request Sep 12, 2025
@madmages

Copy link
Copy Markdown

waiting for it.

@shwangdev

Copy link
Copy Markdown

Really need this, can the team approve this ASAP?

@uikawayi

uikawayi commented Oct 14, 2025 via email

Copy link
Copy Markdown

@etraut-openai

Copy link
Copy Markdown
Contributor

Thanks for the contribution, and apologies for the slow response. We've received many PRs, and we don't have the bandwidth on the codex team to review all of them.

We've updated our contribution guidelines to clarify that we're currently accepting contributions for bugs and security fixes, but we're not generally accepting new features at this time. We need to make sure that all new features compose well with both existing and upcoming features and fit into our roadmap. If you would like to propose a new feature, please file or upvote an enhancement request in the issue tracker. We will generally prioritize new features based on community feedback.

@github-actions github-actions Bot locked and limited conversation to collaborators Oct 30, 2025
@openai openai unlocked this conversation Oct 30, 2025
youta7 added a commit to youta7/ta-codex that referenced this pull request Nov 10, 2025
swordfish444 pushed a commit to swordfish444/codex that referenced this pull request Feb 26, 2026
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.

5 participants