mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-18 00:48:35 +00:00
Fix httpclient to properly encode queries (path?queries)
This commit is contained in:
@@ -294,7 +294,10 @@ proc request*(url: string, httpMethod = httpGET, extraHeaders = "",
|
||||
var r = if proxy == nil: parseUri(url) else: proxy.url
|
||||
var headers = substr($httpMethod, len("http"))
|
||||
if proxy == nil:
|
||||
headers.add(" /" & r.path & r.query)
|
||||
var pathQuery = " /" & r.path
|
||||
if r.query.len > 0:
|
||||
pathQuery.add("?" & r.query)
|
||||
headers.add(pathQuery)
|
||||
else:
|
||||
headers.add(" " & url)
|
||||
|
||||
@@ -442,7 +445,9 @@ proc generateHeaders(r: Uri, httpMethod: HttpMethod,
|
||||
headers: StringTableRef): string =
|
||||
result = substr($httpMethod, len("http"))
|
||||
# TODO: Proxies
|
||||
result.add(" /" & r.path & r.query)
|
||||
result.add(" /" & r.path)
|
||||
if r.query.len > 0:
|
||||
result.add("?" & r.query)
|
||||
result.add(" HTTP/1.1\c\L")
|
||||
|
||||
add(result, "Host: " & r.hostname & "\c\L")
|
||||
|
||||
Reference in New Issue
Block a user