From e81bb6f57ccf551426bc323b582ced25619202fc Mon Sep 17 00:00:00 2001 From: aesapronov Date: Thu, 4 Jul 2019 14:00:54 +0300 Subject: [PATCH] HTTPClient: Added possibility of sending POST with empty payload (#4275) * Added possibility of sending POST with empty payload Specification does not prohibit the sending of an empty POST requests. In this case "Content-Length: 0" should be set. See thread here: http://lists.w3.org/Archives/Public/ietf-http-wg/2010JulSep/0276.html --- libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp index 8d7880e4e..a7c3fb88a 100644 --- a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp +++ b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp @@ -656,9 +656,7 @@ int HTTPClient::sendRequest(const char * type, uint8_t * payload, size_t size) return returnError(HTTPC_ERROR_CONNECTION_REFUSED); } - if(payload && size > 0) { - addHeader(F("Content-Length"), String(size)); - } + addHeader(F("Content-Length"), String(payload && size > 0 ? size : 0)); // send Header if(!sendHeader(type)) {