Closed
Description
Hi all,
Would it be possible in next version of this lib insert another signatures for
ESP8266WebServer::sendContent as follow
void ESP8266WebServer::sendContent(const char* content, size_t len);
void ESP8266WebServer::sendContent(const char* content)
Useful when parsing a char*
buffer like a HTML template from a file, and sending little pieces of this buffer to client after parsed. Call <server_instance>.client().write( ... )
directly is not an option, because final length of parsed buffer is unknown and encoding is chunked
Thanks in advance
The implementation.
void ESP8266WebServer::sendContent(const char* content, size_t len) {
const char * footer = "\r\n";
if(_chunked) {
char * chunkSize = (char *)malloc(11);
if(chunkSize){
sprintf(chunkSize, "%x%s", len, footer);
_currentClient.write(chunkSize, strlen(chunkSize));
free(chunkSize);
}
}
_currentClient.write(content, len);
if(_chunked){
_currentClient.write(footer, 2);
}
}
void ESP8266WebServer::sendContent(const char* content) {
sendContent(content, strlen(content));
}
void ESP8266WebServer::sendContent(const String& content) {
sendContent(content.c_str(), content.length());
}