Skip to content

Commit e81bb6f

Browse files
aesapronovd-a-v
authored andcommittedJul 4, 2019
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
1 parent 6272b49 commit e81bb6f

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed
 

‎libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -656,9 +656,7 @@ int HTTPClient::sendRequest(const char * type, uint8_t * payload, size_t size)
656656
return returnError(HTTPC_ERROR_CONNECTION_REFUSED);
657657
}
658658

659-
if(payload && size > 0) {
660-
addHeader(F("Content-Length"), String(size));
661-
}
659+
addHeader(F("Content-Length"), String(payload && size > 0 ? size : 0));
662660

663661
// send Header
664662
if(!sendHeader(type)) {

0 commit comments

Comments
 (0)
Please sign in to comment.