From 74f064f0bb03b2e65cc056c87b6cadc4393e0a57 Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Wed, 25 May 2022 10:17:57 -0400 Subject: [PATCH] issue #328 - empty POST should still have content-length --- http2.d | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/http2.d b/http2.d index ca64241..3e56ecf 100644 --- a/http2.d +++ b/http2.d @@ -1141,13 +1141,18 @@ class HttpRequest { } headers ~= "\r\n"; + bool specSaysRequestAlwaysHasBody = + requestParameters.method == HttpVerb.POST || + requestParameters.method == HttpVerb.PUT || + requestParameters.method == HttpVerb.PATCH; + if(requestParameters.userAgent.length) headers ~= "User-Agent: "~requestParameters.userAgent~"\r\n"; if(requestParameters.contentType.length) headers ~= "Content-Type: "~requestParameters.contentType~"\r\n"; if(requestParameters.authorization.length) headers ~= "Authorization: "~requestParameters.authorization~"\r\n"; - if(requestParameters.bodyData.length) + if(requestParameters.bodyData.length || specSaysRequestAlwaysHasBody) headers ~= "Content-Length: "~to!string(requestParameters.bodyData.length)~"\r\n"; if(requestParameters.acceptGzip) headers ~= "Accept-Encoding: gzip\r\n";