Fix body in httpclient

- Never append a newline to the body in a HTTP post.
- Pass the entire body to redirections, including multipart data
This commit is contained in:
def
2015-01-13 18:48:49 +01:00
parent 4754d2dcbd
commit f2c1b3be13

View File

@@ -505,7 +505,7 @@ proc post*(url: string, extraHeaders = "", body = "",
else:
x
var xb = mpBody.withNewLine() & body.withNewLine()
var xb = mpBody.withNewLine() & body
var xh = extraHeaders.withNewLine() & mpHeaders.withNewLine() &
withNewLine("Content-Length: " & $len(xb))
@@ -517,7 +517,7 @@ proc post*(url: string, extraHeaders = "", body = "",
if result.status.redirection():
let redirectTo = getNewLocation(lastURL, result.headers)
var meth = if result.status != "307": httpGet else: httpPost
result = request(redirectTo, meth, xh, body, sslContext, timeout,
result = request(redirectTo, meth, xh, xb, sslContext, timeout,
userAgent, proxy)
lastUrl = redirectTo