@@ -62,11 +62,14 @@ AsyncStaticWebHandler& AsyncStaticWebHandler::setLastModified(const char* last_m
62
62
return *this ;
63
63
}
64
64
65
- AsyncStaticWebHandler& AsyncStaticWebHandler::setLastModified (const std::tm* last_modified){
66
- constexpr size_t buffsize = sizeof (" Fri, 27 Jan 2023 15:50:27 GMT" ); // a format for LM header
67
- char result[buffsize];
68
- std::strftime (result, buffsize, " %a, %d %b %Y %H:%M:%S GMT" , last_modified);
69
- return setLastModified (static_cast <const char *>(result));
65
+ AsyncStaticWebHandler& AsyncStaticWebHandler::setLastModified (struct tm * last_modified){
66
+ auto formatP = PSTR (" %a, %d %b %Y %H:%M:%S %Z" );
67
+ char format[strlen_P (formatP) + 1 ];
68
+ strcpy_P (format, formatP);
69
+
70
+ char result[30 ];
71
+ strftime (result, sizeof (result), format, last_modified);
72
+ return setLastModified ((const char *)result);
70
73
}
71
74
72
75
#ifdef ESP8266
@@ -195,15 +198,15 @@ uint8_t AsyncStaticWebHandler::_countBits(const uint8_t value) const
195
198
void AsyncStaticWebHandler::handleRequest (AsyncWebServerRequest *request)
196
199
{
197
200
// Get the filename from request->_tempObject and free it
198
- String filename ((char *)request->_tempObject );
201
+ String filename = String ((char *)request->_tempObject );
199
202
free (request->_tempObject );
200
203
request->_tempObject = NULL ;
201
204
if ((_username.length () && _password.length ()) && !request->authenticate (_username.c_str (), _password.c_str ()))
202
205
return request->requestAuthentication ();
203
206
204
207
if (request->_tempFile == true ) {
205
208
time_t lw = request->_tempFile .getLastWrite (); // get last file mod time (if supported by FS)
206
- if (lw) setLastModified (std:: gmtime (&lw));
209
+ if (lw) setLastModified (gmtime (&lw));
207
210
String etag (lw ? lw : request->_tempFile .size ()); // set etag to lastmod timestamp if available, otherwise to size
208
211
if (_last_modified.length () && _last_modified == request->header (F (" If-Modified-Since" ))) {
209
212
request->_tempFile .close ();
0 commit comments