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

Getting bad options when trying to fetch URL using proxy #147

Closed
Zabrane opened this issue Sep 10, 2023 · 2 comments
Closed

Getting bad options when trying to fetch URL using proxy #147

Zabrane opened this issue Sep 10, 2023 · 2 comments

Comments

@Zabrane
Copy link

Zabrane commented Sep 10, 2023

Hi @puzza007 ,

I'm getting an error when trying to fetch a webpage via a GET request, and using a proxy:

> {ok, _} = application:ensure_all_started(katipo).
> {ok, _} = katipo_pool:start(pool, 1, [ {pipelining, nothing} ]),
> katipo:get(pool, "https://www.google.com/",  #{proxy => "http://localhost:3128", 
                                                 ssl_verifyhost => false,
                                                 ssl_verifypeer => false,
                                                 connecttimeout_ms => 5000}).
                                                 
 {error,#{code => bad_opts,
         message =>
             <<"[{url,\"https://www.google.com/\"},{proxy,\"http://localhost:3128\"}]">>}}

My proxy is working perfectly, and I'm able to test it using cURL.

$ curl -x "http://localhost:3128" "https://www.google.com/" > google.html 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 19649    0 19649    0     0   214k      0 --:--:-- --:--:-- --:--:--  215k
$ ls -la google.html
.rw-r--r-- 20k zab 11 Sep 01:22 google.html

It fails with a wrong/closed port 9999, which proves my proxy is working as expected:

$ curl -x "http://localhost:9999" "https://www.google.com/"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (7) Failed to connect to localhost port 9999 after 0 ms: Couldn't connect to server

What am i missing?

My setup:
. Erlang: 26.0.2 | 25.3.2.4 | 24.2.1
. katipo from master
. macOS: Ventura 13.5.1

Help appreciated
Z.

@puzza007
Copy link
Owner

Hi @Zabrane! Try making proxy a binary. The line that checks the parameter is here

katipo/src/katipo.erl

Lines 789 to 790 in 886d44b

opt(proxy, Proxy, {Req, Errors}) when is_binary(Proxy) ->
{Req#req{proxy=Proxy}, Errors};

@Zabrane
Copy link
Author

Zabrane commented Sep 11, 2023

Hi @Zabrane! Try making proxy a binary. The line that checks the parameter is here

katipo/src/katipo.erl

Lines 789 to 790 in 886d44b

opt(proxy, Proxy, {Req, Errors}) when is_binary(Proxy) ->
{Req#req{proxy=Proxy}, Errors};

It works now. Many thanks @puzza007

@Zabrane Zabrane closed this as completed Sep 11, 2023
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