mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
DELETE requests should always have a content-length header (#16618)
* DELETE requests should always have a content-length header Not having DELETE in this list is causing hanging when trying to close webdriver sessions in [halonium](https://github.com/halonium/halonium/issues/10) and likely any other implementation of the webdriver protocol. Both at least chromedriver and geckodriver are affected by this issue. * Change the content length calculation to match the http spec For reference: https://www.w3.org/Protocols/HTTP/1.0/draft-ietf-http-spec.html#Entity-Body
This commit is contained in:
@@ -980,8 +980,11 @@ proc requestAux(client: HttpClient | AsyncHttpClient, url, httpMethod: string,
|
||||
var data: seq[string]
|
||||
if multipart != nil and multipart.content.len > 0:
|
||||
data = await client.format(multipart)
|
||||
elif httpMethod in ["POST", "PATCH", "PUT"] or body.len != 0:
|
||||
client.headers["Content-Length"] = $body.len
|
||||
else:
|
||||
if body.len != 0:
|
||||
client.headers["Content-Length"] = $body.len
|
||||
elif httpMethod notin ["GET", "HEAD"] and not client.headers.hasKey("Content-Length"):
|
||||
client.headers["Content-Length"] = "0"
|
||||
|
||||
when client is AsyncHttpClient:
|
||||
if not client.parseBodyFut.isNil:
|
||||
|
||||
Reference in New Issue
Block a user