Skip to content

Commit 3711181

Browse files
John DoeJohn Doe
John Doe
authored and
John Doe
committed
allow proper content length handling
1 parent f510e10 commit 3711181

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

hardware/esp8266com/esp8266/libraries/ESP8266WebServer/src/ESP8266WebServer.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,10 @@ void ESP8266WebServer::send(int code, const char* content_type, String content)
140140
content_type = "text/html";
141141

142142
sendHeader("Content-Type", content_type, true);
143-
if (_contentLength != CONTENT_LENGTH_UNKNOWN) {
144-
size_t length = (_contentLength == CONTENT_LENGTH_NOT_SET) ?
145-
content.length() : _contentLength;
146-
String lengthStr(length);
147-
sendHeader("Content-Length", lengthStr.c_str());
143+
if (_contentLength != CONTENT_LENGTH_UNKNOWN && _contentLength != CONTENT_LENGTH_NOT_SET) {
144+
sendHeader("Content-Length", String(_contentLength).c_str());
145+
} else if(content.length() > 0){
146+
sendHeader("Content-Length", String(content.length()).c_str());
148147
}
149148
sendHeader("Connection", "close");
150149
sendHeader("Access-Control-Allow-Origin", "*");

0 commit comments

Comments
 (0)