Skip to content

common: honor HTTP_PROXY/HTTPS_PROXY env vars in http client#21752

Open
texasich wants to merge 1 commit intoggml-org:masterfrom
texasich:fix/proxy-env-vars-http-client
Open

common: honor HTTP_PROXY/HTTPS_PROXY env vars in http client#21752
texasich wants to merge 1 commit intoggml-org:masterfrom
texasich:fix/proxy-env-vars-http-client

Conversation

@texasich
Copy link
Copy Markdown

Fixes #21694

What

common_http_client() builds the httplib client but never checks standard proxy environment variables, so any download that goes through this path (e.g. -hf flag, model presets) silently fails in environments that require a proxy.

How

After constructing the client, read HTTPS_PROXY/https_proxy for https:// URLs and HTTP_PROXY/http_proxy for http:// ones (scheme-specific takes precedence). If set and parseable, pass it to cli.set_proxy() and optionally cli.set_proxy_basic_auth(). Malformed proxy URLs are caught and silently ignored so nothing breaks for callers without a proxy configured.

Reuses the existing common_http_parse_url() to handle auth credentials embedded in the proxy URL (e.g. http://user:pass@proxy:3128).

Notes

  • NO_PROXY/no_proxy bypass list not implemented yet; can be added as follow-up
  • ALL_PROXY not checked; HTTPS_PROXY and HTTP_PROXY cover the common case
  • std::getenv is available via <cstdlib> already pulled in by httplib.h

common_http_client() was ignoring standard proxy env vars, causing
downloads via -hf and similar flags to fail silently in environments
behind an HTTP proxy (corporate networks, air-gapped infra, etc.).

Checks HTTPS_PROXY/https_proxy for https:// URLs and HTTP_PROXY/http_proxy
for http:// URLs, in that order. If a proxy URL is set and parseable,
passes it to httplib's set_proxy() and set_proxy_basic_auth() as
appropriate. Malformed proxy URLs are silently ignored so existing
callers aren't affected.

Fixes ggml-org#21694
@texasich texasich requested a review from a team as a code owner April 11, 2026 01:06
@ggml-gh-bot
Copy link
Copy Markdown

ggml-gh-bot bot commented Apr 11, 2026

Hi @texasich, thanks for your contribution!

Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:

  • Multiple open PRs from a new contributor: We limit new contributors (those without a previously merged PR) to 1 open PR at a time. You currently have 2 open PRs.

Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below.

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.

Misc. bug: Remote download fails behind proxy with -hf flag

1 participant