Skip to content
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

Proxy option not working #462

Open
shellking4 opened this issue Sep 1, 2022 · 1 comment
Open

Proxy option not working #462

shellking4 opened this issue Sep 1, 2022 · 1 comment

Comments

@shellking4
Copy link

shellking4 commented Sep 1, 2022

I have this curl request

curl -x "http://proxy-server.com:8001" -k "https://httpbin.org/ip"

The curl request is actually going through the proxy server and I'm getting at each hit a new ip address.

But when I try with HTTPoison it's not working as expected.

I tried these codes

HTTPoison.get!("https://www.httpbin.org/ip", [], [proxy: {"http://proxy-server.com"}])

HTTPoison.get!("https://www.httpbin.org/ip", [], [{:proxy, "http://proxy-server.com"}])

What am I doing wrong ?

@ShahneRodgers
Copy link
Contributor

I think HTTPoison.get!("https://www.httpbin.org/ip", [], [proxy: "http://proxy-server.com:8001"]) or HTTPoison.get!("http://www.httpbin.org/ip", [], [{:proxy, {"proxy-server.com", 8001}}]) should work.

As per the docs

:proxy - a proxy to be used for the request; it can be a regular url or a {Host, Port} tuple, or a {:socks5, ProxyHost, ProxyPort} tuple

So the issue with the first form is that you're giving it a tuple without splitting up the host / port part. The second isn't working because you haven't specified a port and HTTP defaults to port 80, not the port 8001 that you've told curl to use.

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

No branches or pull requests

2 participants