bugfix: httpclient
This commit is contained in:
parent
8733886e53
commit
d11a62af31
2 changed files with 9 additions and 2 deletions
|
|
@ -345,6 +345,11 @@ proc writeContentType*() =
|
||||||
write(stdout, "Content-type: text/html\n\n")
|
write(stdout, "Content-type: text/html\n\n")
|
||||||
system.stackTraceNewLine = "<br />\n"
|
system.stackTraceNewLine = "<br />\n"
|
||||||
|
|
||||||
|
proc setStackTraceNewLine*() =
|
||||||
|
## Modifies the debug stack traces so that they contain
|
||||||
|
## ``<br />`` and are easily readable in a browser.
|
||||||
|
system.stackTraceNewLine = "<br />\n"
|
||||||
|
|
||||||
proc setCookie*(name, value: string) =
|
proc setCookie*(name, value: string) =
|
||||||
## Sets a cookie.
|
## Sets a cookie.
|
||||||
write(stdout, "Set-Cookie: ", name, "=", value, "\n")
|
write(stdout, "Set-Cookie: ", name, "=", value, "\n")
|
||||||
|
|
|
||||||
|
|
@ -238,8 +238,10 @@ proc request*(url: string, httpMethod = httpGET, extraHeaders = "",
|
||||||
|
|
||||||
var headers = copy($httpMethod, len("http"))
|
var headers = copy($httpMethod, len("http"))
|
||||||
if r.path != "":
|
if r.path != "":
|
||||||
headers.add(" " & r.path & r.query)
|
headers.add(" /" & r.path & r.query)
|
||||||
headers.add(" / HTTP/1.1\c\L")
|
else:
|
||||||
|
headers.add(" /")
|
||||||
|
headers.add(" HTTP/1.1\c\L")
|
||||||
|
|
||||||
add(headers, "Host: " & r.hostname & "\c\L")
|
add(headers, "Host: " & r.hostname & "\c\L")
|
||||||
add(headers, extraHeaders)
|
add(headers, extraHeaders)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue