Open
Description
Description:
webserver :Please add chunkedResponseModeStart / chunkedResponseFinalize
These functions were added in a recent release for ESP8266WebServer and it will be nice to have them in the upcomming release for ESP32. If not , porting from ESP8266 to ESP32 becomes cumbersome.
I developed a small derivated class to get them in rhe ESP32 environment. If it can help .....
Sketch:
#ifndef FS_WEBSERVER_H
#define FS_WEBSERVER_H
#include <WebServer.h>
class fs_WebServer : public WebServer
{
public:
fs_WebServer(int port = 80): WebServer(port) {
}
using WebServer:: send_P;
void send_P(int code, PGM_P content_type, PGM_P content) {
size_t contentLength = 0;
if (content != NULL) {
contentLength = strlen_P(content);
}
String header;
char type[64];
memccpy_P((void*)type, (PGM_VOID_P)content_type, 0, sizeof(type));
_prepareHeader(header, code, (const char* )type, contentLength);
_currentClientWrite(header.c_str(), header.length());
if (contentLength) { // if rajouté par FS ...........................+++++
sendContent_P(content);
}
}
bool chunkedResponseModeStart_P (int code, PGM_P content_type) {
if (_currentVersion == 0)
// no chunk mode in HTTP/1.0
return false;
setContentLength(CONTENT_LENGTH_UNKNOWN);
send_P(code, content_type, "");
return true;
}
bool chunkedResponseModeStart (int code, const char* content_type) {
return chunkedResponseModeStart_P(code, content_type);
}
bool chunkedResponseModeStart (int code, const String& content_type) {
return chunkedResponseModeStart_P(code, content_type.c_str());
}
void chunkedResponseFinalize () {
sendContent(emptyString);
}
};
#endif // FS_WEBSERVER_H
Metadata
Metadata
Assignees
Type
Projects
Status
Todo