@@ -92,24 +92,23 @@ class ESP8266WebServer
92
92
void onNotFound (THandlerFunction fn); // called when handler is not assigned
93
93
void onFileUpload (THandlerFunction fn); // handle file uploads
94
94
95
- String uri () { return _currentUri; }
96
- HTTPMethod method () { return _currentMethod; }
95
+ const String& uri () const { return _currentUri; }
96
+ HTTPMethod method () const { return _currentMethod; }
97
97
virtual WiFiClient client () { return _currentClient; }
98
98
HTTPUpload& upload () { return *_currentUpload; }
99
99
100
- String arg (String name); // get request argument value by name
101
- String arg (int i); // get request argument value by number
102
- String argName (int i); // get request argument name by number
103
- int args (); // get arguments count
104
- bool hasArg (String name); // check if argument exists
100
+ const String& arg (String name) const ; // get request argument value by name
101
+ const String& arg (int i) const ; // get request argument value by number
102
+ const String& argName (int i) const ; // get request argument name by number
103
+ int args () const ; // get arguments count
104
+ bool hasArg (const String& name) const ; // check if argument exists
105
105
void collectHeaders (const char * headerKeys[], const size_t headerKeysCount); // set the request headers to collect
106
- String header (String name); // get request header value by name
107
- String header (int i); // get request header value by number
108
- String headerName (int i); // get request header name by number
109
- int headers (); // get header count
110
- bool hasHeader (String name); // check if header exists
111
-
112
- String hostHeader (); // get request host header if available or empty String if not
106
+ const String& header (String name) const ; // get request header value by name
107
+ const String& header (int i) const ; // get request header value by number
108
+ const String& headerName (int i) const ; // get request header name by number
109
+ int headers () const ; // get header count
110
+ bool hasHeader (String name) const ; // check if header exists
111
+ const String& hostHeader () const ; // get request host header if available or empty String if not
113
112
114
113
// send response to the client
115
114
// code - HTTP response code, can be 200 or 404
@@ -129,12 +128,12 @@ class ESP8266WebServer
129
128
130
129
static String urlDecode (const String& text);
131
130
132
- template <typename T>
131
+ template <typename T>
133
132
size_t streamFile (T &file, const String& contentType) {
134
133
_streamFileCore (file.size (), file.name (), contentType);
135
134
return _currentClient.write (file);
136
135
}
137
-
136
+
138
137
protected:
139
138
virtual size_t _currentClientWrite (const char * b, size_t l) { return _currentClient.write ( b, l ); }
140
139
virtual size_t _currentClientWrite_P (PGM_P b, size_t l) { return _currentClient.write_P ( b, l ); }
@@ -144,19 +143,19 @@ class ESP8266WebServer
144
143
bool _parseRequest (WiFiClient& client);
145
144
void _parseArguments (const String& data);
146
145
int _parseArgumentsPrivate (const String& data, std::function<void (String&,String&,const String&,int ,int ,int ,int )> handler);
147
- static String _responseCodeToString (int code);
148
- bool _parseForm (WiFiClient& client, String boundary, uint32_t len);
146
+ static const String _responseCodeToString (int code);
147
+ bool _parseForm (WiFiClient& client, const String& boundary, uint32_t len);
149
148
bool _parseFormUploadAborted ();
150
149
void _uploadWriteByte (uint8_t b);
151
150
uint8_t _uploadReadByte (WiFiClient& client);
152
151
void _prepareHeader (String& response, int code, const char * content_type, size_t contentLength);
153
152
bool _collectHeader (const char * headerName, const char * headerValue);
154
-
153
+
155
154
void _streamFileCore (const size_t fileSize, const String & fileName, const String & contentType);
156
155
157
- String _getRandomHexString ();
156
+ static String _getRandomHexString ();
158
157
// for extracting Auth parameters
159
- String _extractParam (String& authReq,const String& param,const char delimit = ' "' );
158
+ String _extractParam (String& authReq,const String& param,const char delimit = ' "' ) const ;
160
159
161
160
struct RequestArgument {
162
161
String key;
0 commit comments