bugfix: httpclient

This commit is contained in:
Araq
2010-10-30 19:13:35 +02:00
parent 8733886e53
commit d11a62af31
2 changed files with 9 additions and 2 deletions

View File

@@ -345,6 +345,11 @@ proc writeContentType*() =
write(stdout, "Content-type: text/html\n\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) =
## Sets a cookie.
write(stdout, "Set-Cookie: ", name, "=", value, "\n")

View File

@@ -238,8 +238,10 @@ proc request*(url: string, httpMethod = httpGET, extraHeaders = "",
var headers = copy($httpMethod, len("http"))
if r.path != "":
headers.add(" " & r.path & r.query)
headers.add(" / HTTP/1.1\c\L")
headers.add(" /" & r.path & r.query)
else:
headers.add(" /")
headers.add(" HTTP/1.1\c\L")
add(headers, "Host: " & r.hostname & "\c\L")
add(headers, extraHeaders)