Don't leave content-length on empty response

This commit is contained in:
Alex Hultman
2018-12-29 14:27:50 +01:00
parent 6befbd4a37
commit d597041ca4
5 changed files with 18 additions and 14 deletions
+9 -4
View File
@@ -95,10 +95,15 @@ private:
} else {
/* Write content-length on first call */
if (!(httpResponseData->state & HttpResponseData<SSL>::HTTP_END_CALLED)) {
/* We have a known send size */
Super::write("Content-Length: ", 16);
writeUnsigned(totalSize);
Super::write("\r\n\r\n", 4);
/* Ending with no response should not leave any content-length */
if (totalSize) {
/* We have a known send size */
Super::write("Content-Length: ", 16);
writeUnsigned(totalSize);
Super::write("\r\n\r\n", 4);
} else {
Super::write("\r\n", 2);
}
/* Mark end called */
httpResponseData->state |= HttpResponseData<SSL>::HTTP_END_CALLED;