@@ -95,29 +95,31 @@ class StaticRequestHandler : public RequestHandler<ServerType> {
95
95
return true ;
96
96
}
97
97
98
- bool handle (WebServerType& server, HTTPMethod requestMethod, const String& __requestUri) override {
99
- String requestUri (__requestUri);
98
+ bool handle (WebServerType& server, HTTPMethod requestMethod, const String& requestUri) override {
100
99
101
100
if (!canHandle (requestMethod, requestUri))
102
101
return false ;
103
102
104
103
DEBUGV (" StaticRequestHandler::handle: request=%s _uri=%s\r\n " , requestUri.c_str (), _uri.c_str ());
105
104
106
- String path (_path);
105
+ String path;
106
+ path.reserve (_path.length () + requestUri.length () + 32 );
107
+ path = _path;
107
108
108
109
if (!_isFile) {
109
- // Base URI doesn't point to a file.
110
- // If a directory is requested, look for index file.
111
- if (requestUri.endsWith (" /" ))
112
- requestUri += " index.htm" ;
113
110
114
111
// Append whatever follows this URI in request to get the file path.
115
112
path += requestUri.substring (_baseUriLength);
116
113
114
+ // Base URI doesn't point to a file.
115
+ // If a directory is requested, look for index file.
116
+ if (path.endsWith (" /" ))
117
+ path += F (" index.htm" );
118
+
117
119
// If neither <blah> nor <blah>.gz exist, and <blah> is a file.htm, try it with file.html instead
118
120
// For the normal case this will give a search order of index.htm, index.htm.gz, index.html, index.html.gz
119
121
if (!_fs.exists (path) && !_fs.exists (path + " .gz" ) && path.endsWith (" .htm" )) {
120
- path += " l " ;
122
+ path += ' l ' ;
121
123
}
122
124
}
123
125
DEBUGV (" StaticRequestHandler::handle: path=%s, isFile=%d\r\n " , path.c_str (), _isFile);
0 commit comments