diff --git a/libraries/ESP8266WebServer/src/ESP8266WebServer.cpp b/libraries/ESP8266WebServer/src/ESP8266WebServer.cpp index df067f0c9..4a0fbd3f5 100644 --- a/libraries/ESP8266WebServer/src/ESP8266WebServer.cpp +++ b/libraries/ESP8266WebServer/src/ESP8266WebServer.cpp @@ -115,7 +115,7 @@ void ESP8266WebServer::handleClient() _handleRequest(); } -void ESP8266WebServer::sendHeader(String name, String value, bool first) { +void ESP8266WebServer::sendHeader(const String& name, const String& value, bool first) { String headerLine = name; headerLine += ": "; headerLine += value; @@ -129,7 +129,7 @@ void ESP8266WebServer::sendHeader(String name, String value, bool first) { } } -void ESP8266WebServer::send(int code, const char* content_type, String content) { +void ESP8266WebServer::send(int code, const char* content_type, const String& content) { String response = "HTTP/1.1 "; response += String(code); response += " "; @@ -155,15 +155,15 @@ void ESP8266WebServer::send(int code, const char* content_type, String content) sendContent(response); } -void ESP8266WebServer::send(int code, char* content_type, String content) { +void ESP8266WebServer::send(int code, char* content_type, const String& content) { send(code, (const char*)content_type, content); } -void ESP8266WebServer::send(int code, String content_type, String content) { +void ESP8266WebServer::send(int code, const String& content_type, const String& content) { send(code, (const char*)content_type.c_str(), content); } -void ESP8266WebServer::sendContent(String content) { +void ESP8266WebServer::sendContent(const String& content) { size_t size_to_send = content.length(); size_t size_sent = 0; while(size_to_send) { diff --git a/libraries/ESP8266WebServer/src/ESP8266WebServer.h b/libraries/ESP8266WebServer/src/ESP8266WebServer.h index d787e4e3f..888e36b4a 100644 --- a/libraries/ESP8266WebServer/src/ESP8266WebServer.h +++ b/libraries/ESP8266WebServer/src/ESP8266WebServer.h @@ -77,15 +77,15 @@ public: // code - HTTP response code, can be 200 or 404 // content_type - HTTP content type, like "text/plain" or "image/png" // content - actual content body - void send(int code, const char* content_type = NULL, String content = String("")); - void send(int code, char* content_type, String content); - void send(int code, String content_type, String content); + void send(int code, const char* content_type = NULL, const String& content = String("")); + void send(int code, char* content_type, const String& content); + void send(int code, const String& content_type, const String& content); void setContentLength(size_t contentLength) { _contentLength = contentLength; } - void sendHeader(String name, String value, bool first = false); - void sendContent(String content); + void sendHeader(const String& name, const String& value, bool first = false); + void sendContent(const String& content); -template size_t streamFile(T &file, String contentType){ +template size_t streamFile(T &file, const String& contentType){ setContentLength(file.size()); if (String(file.name()).endsWith(".gz") && contentType != "application/x-gzip" &&