@@ -430,12 +430,32 @@ void WebServer::send(int code, const char* content_type, const String& content)
430430 // Can we asume the following?
431431 // if(code == 200 && content.length() == 0 && _contentLength == CONTENT_LENGTH_NOT_SET)
432432 // _contentLength = CONTENT_LENGTH_UNKNOWN;
433+ if (content.length () == 0 ) {
434+ log_w (" content length is zero" );
435+ }
433436 _prepareHeader (header, code, content_type, content.length ());
434437 _currentClientWrite (header.c_str (), header.length ());
435438 if (content.length ())
436439 sendContent (content);
437440}
438441
442+ void WebServer::send (int code, char * content_type, const String& content) {
443+ send (code, (const char *)content_type, content);
444+ }
445+
446+ void WebServer::send (int code, const String& content_type, const String& content) {
447+ send (code, (const char *)content_type.c_str (), content);
448+ }
449+
450+ void WebServer::send (int code, const char * content_type, const char * content)
451+ {
452+ const String passStr = (String)content;
453+ if (strlen (content) != passStr.length ()) {
454+ log_e (" String cast failed. Use send_P for long arrays" );
455+ }
456+ send (code, content_type, passStr);
457+ }
458+
439459void WebServer::send_P (int code, PGM_P content_type, PGM_P content) {
440460 size_t contentLength = 0 ;
441461
@@ -460,14 +480,6 @@ void WebServer::send_P(int code, PGM_P content_type, PGM_P content, size_t conte
460480 sendContent_P (content, contentLength);
461481}
462482
463- void WebServer::send (int code, char * content_type, const String& content) {
464- send (code, (const char *)content_type, content);
465- }
466-
467- void WebServer::send (int code, const String& content_type, const String& content) {
468- send (code, (const char *)content_type.c_str (), content);
469- }
470-
471483void WebServer::sendContent (const String& content) {
472484 sendContent (content.c_str (), content.length ());
473485}
0 commit comments