Well,
[https://github.com/nim-lang/Nim/blob/7f3b686b81f3f7ec060b5de9029e3234f24aa372/lib/pure/httpclient.nim#L373](https://github.com/nim-lang/Nim/blob/7f3b686b81f3f7ec060b5de9029e3234f24aa372/lib/pure/httpclient.nim#L373)
$parsed just shows the structure, not the real "toString" \- this is
[https://github.com/nim-lang/nimble/blob/f17eaef7957da23aab6e375400b37227394a632a/src/nimblepkg/options.nim#L408](https://github.com/nim-lang/nimble/blob/f17eaef7957da23aab6e375400b37227394a632a/src/nimblepkg/options.nim#L408)
nimble has this bug too, I'm going to open a github issue.
Plus:
let proxy= getProxy()
var client = newHttpClient(proxy = proxy)
echo("GPI:" & $proxy.url)
Run
and a duplicated url "teleports" into the url's path:
GPI:(scheme: "", username: "", password: "", hostname: "", port: "", path:
"(scheme:
parseUri doesn't work properly either:
var parsed = parseUri(url)
var parsed1 = initUri()
parsed1.hostname = "10.10.10.10"
parsed.port = "8080"
echo("PARSEDPROXY1:")
echo(parsed1)
echo(repr(parsed1))
Summary: After the when client is HttpClient: appears, the structure of
connectionUrl changes. The hostname and port are always empty, repr() shows
nothing special.
I spent some trying to understand this bug but:
proc newConnection(client: HttpClient | AsyncHttpClient,
url: Uri) {.multisync.} =
if client.currentURL.hostname != url.hostname or
client.currentURL.scheme != url.scheme or
Here's a way to replicate the bug:
1. Install mitmproxy and run it
2. Install the generated mitmproxy .pem file onto your machine
3. export http_proxy=http://127.0.0.1:8080 and export
https_proxy=http://127.0.0.1:8080
4. Run curl https://forum.nim-lang.org/
outputs the html correctly
I see. connectionUrl.hostname has something when you echo it the object but not
when you echo the field itself, try using repr, it's possible that there is a 0
(end-of-string) character in that string.
@dom96 I'd like to fix it but in one of my previous comments I presented
something that shouldn't happen. If someone has a clue about that issue then I
will be able to continue but otherwise I'm in the dark.
It happens because either:
1\. You are doing something wrong, like not setting the http_proxy env var
(Unlikely since it works for you in curl)
2\. There is a bug in the httpclient module (Likely as there were other bugs
with the proxy support before)
I don't use proxies, I also don't have
Why does this happen? Can we ever expect proper proxy support for nim? Because
if we can't then I might as well just change language or use curl as a
replacement.
I appended these after httpclient.nim:865(when client is HttpClient):
when client is HttpClient:
echo("httpclient.nim/newConnection")
echo("CU:", $connectionUrl)
echo("HN:", connectionUrl.hostname)
echo("Port0:", connectionUrl.port == "")
The port is empty too, it just gets a default in the same function.
What I don't know is what supposed to go there...
Keep going, check why `address` is `""` :)
I added this after lib/pure/nativesockets.nim:261:
echo "SOCKET:"
echo address
echo socket_port
echo $hints
echo $gaiResult
Run
output:
SOCKET:
80
(ai_flags: 0, ai_family: 0, ai_socktype: 1, ai_protocol: 6, ai_addrlen:
Proxy support in httpclient isn't well tested, if you want to move faster with
this please add some debugging code into the httpclient module and compare to
see what httpclient sends vs. curl (use `curl -v`)
There is no proxy authentication.
The httpclient docs say that only basic authentication is supported at the
moment. How do you authenticate with the proxy you are using? Can you give more
details on the proxy itself?
They are set and everything works fine except nim's httpclient.
I use a proxy. I tried it with -d:ssl too.
Do you have the proxy details set up in the environment variable http_proxy or
https_proxy? Maybe add some echo calls to see if the proxy is being picked up
or not
If I compile with nim c -d:ssl -r test.nim it runs correctly and saves
httpclient.html. Does the link work correctly for you in a browser?
I get this error:
Error: an error happened while downloading a file!
main.nim(72) main
main.nim(66) downloadFile
httpclient.nim(1305) downloadFile
httpclient.nim(1235) get
httpclient.nim(1227) request
httpclient.nim(1204)
24 matches
Mail list logo