Skip to content

Commit 7450dd3

Browse files
committed
ESP8266WebServer: save RAM by moving response strings to flash (#1732)
1 parent f6516b0 commit 7450dd3

File tree

2 files changed

+43
-43
lines changed

2 files changed

+43
-43
lines changed

libraries/ESP8266WebServer/src/ESP8266WebServer.cpp

+42-42
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ void ESP8266WebServer::sendContent_P(PGM_P content, size_t size) {
373373

374374
String ESP8266WebServer::arg(String name) {
375375
for (int i = 0; i < _currentArgCount; ++i) {
376-
if ( _currentArgs[i].key == name )
376+
if ( _currentArgs[i].key == name )
377377
return _currentArgs[i].value;
378378
}
379379
return String();
@@ -487,48 +487,48 @@ void ESP8266WebServer::_handleRequest() {
487487
_currentUri = String();
488488
}
489489

490-
const char* ESP8266WebServer::_responseCodeToString(int code) {
490+
String ESP8266WebServer::_responseCodeToString(int code) {
491491
switch (code) {
492-
case 100: return "Continue";
493-
case 101: return "Switching Protocols";
494-
case 200: return "OK";
495-
case 201: return "Created";
496-
case 202: return "Accepted";
497-
case 203: return "Non-Authoritative Information";
498-
case 204: return "No Content";
499-
case 205: return "Reset Content";
500-
case 206: return "Partial Content";
501-
case 300: return "Multiple Choices";
502-
case 301: return "Moved Permanently";
503-
case 302: return "Found";
504-
case 303: return "See Other";
505-
case 304: return "Not Modified";
506-
case 305: return "Use Proxy";
507-
case 307: return "Temporary Redirect";
508-
case 400: return "Bad Request";
509-
case 401: return "Unauthorized";
510-
case 402: return "Payment Required";
511-
case 403: return "Forbidden";
512-
case 404: return "Not Found";
513-
case 405: return "Method Not Allowed";
514-
case 406: return "Not Acceptable";
515-
case 407: return "Proxy Authentication Required";
516-
case 408: return "Request Time-out";
517-
case 409: return "Conflict";
518-
case 410: return "Gone";
519-
case 411: return "Length Required";
520-
case 412: return "Precondition Failed";
521-
case 413: return "Request Entity Too Large";
522-
case 414: return "Request-URI Too Large";
523-
case 415: return "Unsupported Media Type";
524-
case 416: return "Requested range not satisfiable";
525-
case 417: return "Expectation Failed";
526-
case 500: return "Internal Server Error";
527-
case 501: return "Not Implemented";
528-
case 502: return "Bad Gateway";
529-
case 503: return "Service Unavailable";
530-
case 504: return "Gateway Time-out";
531-
case 505: return "HTTP Version not supported";
492+
case 100: return F("Continue");
493+
case 101: return F("Switching Protocols");
494+
case 200: return F("OK");
495+
case 201: return F("Created");
496+
case 202: return F("Accepted");
497+
case 203: return F("Non-Authoritative Information");
498+
case 204: return F("No Content");
499+
case 205: return F("Reset Content");
500+
case 206: return F("Partial Content");
501+
case 300: return F("Multiple Choices");
502+
case 301: return F("Moved Permanently");
503+
case 302: return F("Found");
504+
case 303: return F("See Other");
505+
case 304: return F("Not Modified");
506+
case 305: return F("Use Proxy");
507+
case 307: return F("Temporary Redirect");
508+
case 400: return F("Bad Request");
509+
case 401: return F("Unauthorized");
510+
case 402: return F("Payment Required");
511+
case 403: return F("Forbidden");
512+
case 404: return F("Not Found");
513+
case 405: return F("Method Not Allowed");
514+
case 406: return F("Not Acceptable");
515+
case 407: return F("Proxy Authentication Required");
516+
case 408: return F("Request Time-out");
517+
case 409: return F("Conflict");
518+
case 410: return F("Gone");
519+
case 411: return F("Length Required");
520+
case 412: return F("Precondition Failed");
521+
case 413: return F("Request Entity Too Large");
522+
case 414: return F("Request-URI Too Large");
523+
case 415: return F("Unsupported Media Type");
524+
case 416: return F("Requested range not satisfiable");
525+
case 417: return F("Expectation Failed");
526+
case 500: return F("Internal Server Error");
527+
case 501: return F("Not Implemented");
528+
case 502: return F("Bad Gateway");
529+
case 503: return F("Service Unavailable");
530+
case 504: return F("Gateway Time-out");
531+
case 505: return F("HTTP Version not supported");
532532
default: return "";
533533
}
534534
}

libraries/ESP8266WebServer/src/ESP8266WebServer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ template<typename T> size_t streamFile(T &file, const String& contentType){
134134
void _handleRequest();
135135
bool _parseRequest(WiFiClient& client);
136136
void _parseArguments(String data);
137-
static const char* _responseCodeToString(int code);
137+
static String _responseCodeToString(int code);
138138
bool _parseForm(WiFiClient& client, String boundary, uint32_t len);
139139
bool _parseFormUploadAborted();
140140
void _uploadWriteByte(uint8_t b);

0 commit comments

Comments
 (0)