diff options
author | Dominik Picheta <dominikpicheta@gmail.com> | 2016-09-25 00:10:07 +0200 |
---|---|---|
committer | Dominik Picheta <dominikpicheta@gmail.com> | 2016-09-25 00:10:07 +0200 |
commit | 6a83bc1ff57807f2bc6676da545dee79876ffb75 (patch) | |
tree | 70a66243c8da03e0635dc9e39d48af837ec7150a /lib/pure | |
parent | 545e24b8ff9d262e402056c5bfd90a8ad1217123 (diff) | |
download | Nim-6a83bc1ff57807f2bc6676da545dee79876ffb75.tar.gz |
HTTP client's request proc no longer slices http method string param.
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/httpclient.nim | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim index c11fa5f57..4d5b6e26c 100644 --- a/lib/pure/httpclient.nim +++ b/lib/pure/httpclient.nim @@ -649,7 +649,7 @@ proc downloadFile*(url: string, outputFilename: string, proc generateHeaders(requestUrl: Uri, httpMethod: string, headers: HttpHeaders, body: string, proxy: Proxy): string = # GET - result = substr(httpMethod, len("http")).toUpper() + result = httpMethod.toUpper() result.add ' ' if proxy.isNil: @@ -1010,14 +1010,15 @@ proc request*(client: HttpClient | AsyncHttpClient, url: string, if not client.headers.hasKey("user-agent") and client.userAgent != "": client.headers["User-Agent"] = client.userAgent - var headers = generateHeaders(requestUrl, $httpMethod, + var headers = generateHeaders(requestUrl, httpMethod, client.headers, body, client.proxy) await client.socket.send(headers) if body != "": await client.socket.send(body) - result = await parseResponse(client, httpMethod notin {HttpHead, HttpConnect}) + result = await parseResponse(client, + httpMethod.toLower() notin ["head", "connect"]) # Restore the clients proxy in case it was overwritten. client.proxy = savedProxy @@ -1033,7 +1034,7 @@ proc request*(client: HttpClient | AsyncHttpClient, url: string, ## ## When a request is made to a different hostname, the current connection will ## be closed. - result = await request(client, url, $httpMethod, body) + result = await request(client, url, substr($httpMethod, len("http")), body) proc get*(client: HttpClient | AsyncHttpClient, url: string): Future[Response] {.multisync.} = |