diff --git a/lib/pure/cgi.nim b/lib/pure/cgi.nim
index 490ae926d7..643c67bec8 100755
--- a/lib/pure/cgi.nim
+++ b/lib/pure/cgi.nim
@@ -345,6 +345,11 @@ proc writeContentType*() =
write(stdout, "Content-type: text/html\n\n")
system.stackTraceNewLine = "
\n"
+proc setStackTraceNewLine*() =
+ ## Modifies the debug stack traces so that they contain
+ ## ``
`` and are easily readable in a browser.
+ system.stackTraceNewLine = "
\n"
+
proc setCookie*(name, value: string) =
## Sets a cookie.
write(stdout, "Set-Cookie: ", name, "=", value, "\n")
diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim
index c02a7a6e71..9948e6c9bb 100755
--- a/lib/pure/httpclient.nim
+++ b/lib/pure/httpclient.nim
@@ -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)