mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
ESP8266WebServer: send empty chunk when done sending chunked response
Fixes https://github.com/esp8266/Arduino/issues/3225
This commit is contained in:
parent
9b3583d227
commit
4c08389961
@ -433,6 +433,9 @@ void ESP8266WebServer::sendContent(const String& content) {
|
|||||||
_currentClient.write(content.c_str(), len);
|
_currentClient.write(content.c_str(), len);
|
||||||
if(_chunked){
|
if(_chunked){
|
||||||
_currentClient.write(footer, 2);
|
_currentClient.write(footer, 2);
|
||||||
|
if (len == 0) {
|
||||||
|
_chunked = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,6 +456,9 @@ void ESP8266WebServer::sendContent_P(PGM_P content, size_t size) {
|
|||||||
_currentClient.write_P(content, size);
|
_currentClient.write_P(content, size);
|
||||||
if(_chunked){
|
if(_chunked){
|
||||||
_currentClient.write(footer, 2);
|
_currentClient.write(footer, 2);
|
||||||
|
if (size == 0) {
|
||||||
|
_chunked = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,19 +566,27 @@ void ESP8266WebServer::_handleRequest() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
if (!handled && _notFoundHandler) {
|
||||||
if (!handled) {
|
|
||||||
if(_notFoundHandler) {
|
|
||||||
_notFoundHandler();
|
_notFoundHandler();
|
||||||
|
handled = true;
|
||||||
}
|
}
|
||||||
else {
|
if (!handled) {
|
||||||
send(404, "text/plain", String("Not found: ") + _currentUri);
|
send(404, "text/plain", String("Not found: ") + _currentUri);
|
||||||
|
handled = true;
|
||||||
}
|
}
|
||||||
|
if (handled) {
|
||||||
|
_finalizeResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
_currentUri = String();
|
_currentUri = String();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ESP8266WebServer::_finalizeResponse() {
|
||||||
|
if (_chunked) {
|
||||||
|
sendContent("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String ESP8266WebServer::_responseCodeToString(int code) {
|
String ESP8266WebServer::_responseCodeToString(int code) {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 100: return F("Continue");
|
case 100: return F("Continue");
|
||||||
|
@ -142,6 +142,7 @@ template<typename T> size_t streamFile(T &file, const String& contentType){
|
|||||||
protected:
|
protected:
|
||||||
void _addRequestHandler(RequestHandler* handler);
|
void _addRequestHandler(RequestHandler* handler);
|
||||||
void _handleRequest();
|
void _handleRequest();
|
||||||
|
void _finalizeResponse();
|
||||||
bool _parseRequest(WiFiClient& client);
|
bool _parseRequest(WiFiClient& client);
|
||||||
void _parseArguments(String data);
|
void _parseArguments(String data);
|
||||||
static String _responseCodeToString(int code);
|
static String _responseCodeToString(int code);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user