Fix httpclient to properly encode queries (path?queries)
This commit is contained in:
parent
8f82205d12
commit
dd82f0c829
1 changed files with 7 additions and 2 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue