@@ -430,12 +430,32 @@ void WebServer::send(int code, const char* content_type, const String& content)
430
430
// Can we asume the following?
431
431
// if(code == 200 && content.length() == 0 && _contentLength == CONTENT_LENGTH_NOT_SET)
432
432
// _contentLength = CONTENT_LENGTH_UNKNOWN;
433
+ if (content.length () == 0 ) {
434
+ log_w (" content length is zero" );
435
+ }
433
436
_prepareHeader (header, code, content_type, content.length ());
434
437
_currentClientWrite (header.c_str (), header.length ());
435
438
if (content.length ())
436
439
sendContent (content);
437
440
}
438
441
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
+
439
459
void WebServer::send_P (int code, PGM_P content_type, PGM_P content) {
440
460
size_t contentLength = 0 ;
441
461
@@ -460,14 +480,6 @@ void WebServer::send_P(int code, PGM_P content_type, PGM_P content, size_t conte
460
480
sendContent_P (content, contentLength);
461
481
}
462
482
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
-
471
483
void WebServer::sendContent (const String& content) {
472
484
sendContent (content.c_str (), content.length ());
473
485
}
0 commit comments