Open zivoslav opened 1 year ago
what's expected here? parseUri
with a invalid url
import std/uri except `$`
echo parseUri "https://nim-lang.org"
var url = parseUri "nim-lang.org"
url.scheme = "https"
echo url
Output:
(scheme: "https", username: "", password: "", hostname: "nim-lang.org", port: "", path: "", query: "", anchor: "", opaque: false, isIpv6: false)
(scheme: "https", username: "", password: "", hostname: "", port: "", path: "nim-lang.org", query: "", anchor: "", opaque: false, isIpv6: false)
200 OK would definitely be the wrong result. If anything, httpclient should require that the passed Uri has a hostname.
The parser is working as expected. You can't just expect the user to eventually specify the scheme if it's necessary for the HTTP client to work, you have to ensure that it's there in the first place.
The parser is working as expected
shouldn't at least the parseUri
function raise an exception?
Oh, wait, I didn't see that. I thought it was throwing an error when no scheme was provided and the issue poster was talking about that.
Description
If I use httpClient with Uri object and if I parse url without "http" and set scheme directly, program exit with error.
Run
for 4 variants of this program:
Nim Version
nim -v Nim Compiler Version 1.6.12 [Linux: amd64] Compiled at 2023-03-10 Copyright (c) 2006-2023 by Andreas Rumpf
git hash: 1aa9273640c0c51486cf3a7b67282fe58f360e91 active boot switches: -d:release
------------------------------------------------------------------------- AND TOO ----------------------
nim -v Nim Compiler Version 1.9.3 [Linux: amd64] Compiled at 2023-05-08 Copyright (c) 2006-2023 by Andreas Rumpf
git hash: 71f2e1a502ad231e3356217398e2d7fcd6137967 active boot switches: -d:release
Current Output
Expected Output
Possible Solution
No response
Additional Information
No response