Skip to content

Conversation

@feng19
Copy link

@feng19 feng19 commented Nov 14, 2025

fix: #200

@doawoo doawoo self-requested a review November 21, 2025 04:49
@doawoo doawoo added the enhancement New feature or request label Nov 21, 2025
Comment on lines +102 to +122
resp =
cond do
proxy = System.get_env("HTTP_PROXY") || System.get_env("http_proxy") ->
Log.info(:step, "Using HTTP_PROXY: #{proxy}")
URI.parse(proxy)

proxy = System.get_env("HTTPS_PROXY") || System.get_env("https_proxy") ->
Log.info(:step, "Using HTTPS_PROXY: #{proxy}")
URI.parse(proxy)

true ->
nil
end
|> case do
%{scheme: scheme, host: host, port: port} when scheme in ["http", "https"] ->
proxy = {String.to_atom(scheme), host, port, []}
Req.get!(url, raw: true, connect_options: [proxy: proxy])

_ ->
Req.get!(url, raw: true)
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this code is duplicated twice, maybe it would be best to move it into a function under the Util module, and have it return either URI.t() | nil -- then we can just pass that into the proxy key and do a single Req.get! call, so we don't need to have the cond piping into a case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP_PROXY support

2 participants