Hi,
I am trying to make http request adapted to the configured proxy settings on my windows.
Therefore I use this method:
proc setHttpClient(self: Ygg) =
var url = self.getProxy()
echo url
let myProxy = newProxy(url = url)
var client = newHttpClient(proxy = myProxy)
client.headers = newHttpHeaders({ "Content-Type": "application/json" })
self.client = client
The proxy url returned by getProxy is a string "http://x.x.x.x:8080"
Unfortunately, I get the followinf error when using request method:
response = self.client.request(self.user_endpoint, httpMethod = HttpPost, body = $body)
strutils.nim(1072) parseInt Error: unhandled exception: invalid integer: 8080
Does anyone know why ?
Okay it seems coming from the var url which is not exactly a string apparently.
(I tested by bypassing getProxy() and writing directly url = "http://x.x.x.x:8080"
I'll let you know about it
The exception is raised here:
https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/strutils.nim#L1073
But I'm not sure why. If I do this on my machine:
import std/[strutils, uri]
var u = parseUri("http://127.0.0.1:8080")
echo u.port.parseInt
It echoes 8080 without error.
I can only suspect that your actual input (proxy string) isn't what it appears to be.
A perfect opportunity to use a debugger, IMO.