1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-07 16:23:38 +03:00

allow proper content length handling

This commit is contained in:
John Doe 2015-06-16 00:25:34 +03:00
parent 960ada04c3
commit d441d8485e

View File

@ -140,11 +140,10 @@ void ESP8266WebServer::send(int code, const char* content_type, String content)
content_type = "text/html"; content_type = "text/html";
sendHeader("Content-Type", content_type, true); sendHeader("Content-Type", content_type, true);
if (_contentLength != CONTENT_LENGTH_UNKNOWN) { if (_contentLength != CONTENT_LENGTH_UNKNOWN && _contentLength != CONTENT_LENGTH_NOT_SET) {
size_t length = (_contentLength == CONTENT_LENGTH_NOT_SET) ? sendHeader("Content-Length", String(_contentLength).c_str());
content.length() : _contentLength; } else if(content.length() > 0){
String lengthStr(length); sendHeader("Content-Length", String(content.length()).c_str());
sendHeader("Content-Length", lengthStr.c_str());
} }
sendHeader("Connection", "close"); sendHeader("Connection", "close");
sendHeader("Access-Control-Allow-Origin", "*"); sendHeader("Access-Control-Allow-Origin", "*");