diff options
author | hlaaf <hlaaftana@users.noreply.github.com> | 2018-04-26 20:54:14 +0300 |
---|---|---|
committer | Dominik Picheta <dominikpicheta@googlemail.com> | 2018-04-26 18:54:14 +0100 |
commit | 397e1731393be598991df302006ec3634baa3583 (patch) | |
tree | a17c77d8b47afa3c5ae854d8b8f964967c68bd31 /lib/pure | |
parent | ce1bd913cf036a57cff31e36c9e850316076649e (diff) | |
download | Nim-397e1731393be598991df302006ec3634baa3583.tar.gz |
fix #7680 (#7683)
* fix #7680 * Don't send on every HTTP method * These should be squashed * 80 column limit
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/httpclient.nim | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim index 27ae93e53..db8acf0eb 100644 --- a/lib/pure/httpclient.nim +++ b/lib/pure/httpclient.nim @@ -745,10 +745,11 @@ proc downloadFile*(url: string, outputFilename: string, proc generateHeaders(requestUrl: Uri, httpMethod: string, headers: HttpHeaders, body: string, proxy: Proxy): string = # GET - result = httpMethod.toUpperAscii() + let upperMethod = httpMethod.toUpperAscii() + result = upperMethod result.add ' ' - if proxy.isNil or (not proxy.isNil and requestUrl.scheme == "https"): + if proxy.isNil or requestUrl.scheme == "https": # /path?query if requestUrl.path[0] != '/': result.add '/' result.add(requestUrl.path) @@ -774,7 +775,9 @@ proc generateHeaders(requestUrl: Uri, httpMethod: string, add(result, "Connection: Keep-Alive\c\L") # Content length header. - if body.len > 0 and not headers.hasKey("Content-Length"): + const requiresBody = ["POST", "PUT", "PATCH"] + let needsContentLength = body.len > 0 or upperMethod in requiresBody + if needsContentLength and not headers.hasKey("Content-Length"): add(result, "Content-Length: " & $body.len & "\c\L") # Proxy auth header. |