@@ -190,9 +190,9 @@ bool AsyncStaticWebHandler::_searchFile(AsyncWebServerRequest *request, const St
190
190
/* *
191
191
* @brief Handles an incoming HTTP request for a static file.
192
192
*
193
- * This method processes a request for serving static files asynchronously.
194
- * It determines the correct ETag (entity tag) for caching, checks if the file
195
- * has been modified, and prepares the appropriate response (file response or 304 Not Modified).
193
+ * This method processes a request for serving static files asynchronously.
194
+ * It determines the correct ETag (entity tag) for caching, checks if the file
195
+ * has been modified, and prepares the appropriate response (file response or 304 Not Modified).
196
196
*
197
197
* @param request Pointer to the incoming AsyncWebServerRequest object.
198
198
*/
@@ -207,11 +207,11 @@ void AsyncStaticWebHandler::handleRequest(AsyncWebServerRequest *request) {
207
207
return ;
208
208
}
209
209
210
- // Get server ETag. If file is not GZ and we have a Template Processor, ETag=0
210
+ // Get server ETag. If file is not GZ and we have a Template Processor, ETag=0
211
211
char etag[9 ];
212
- const char * tempFileName = request->_tempFile .name ();
212
+ const char * tempFileName = request->_tempFile .name ();
213
213
const size_t lenFilename = strlen (tempFileName);
214
-
214
+
215
215
if (lenFilename > T__GZ_LEN && memcmp (tempFileName + lenFilename - T__GZ_LEN, T__gz, T__GZ_LEN) == 0 ) {
216
216
// File is a gz, get etag from CRC in trailer
217
217
if (!AsyncWebServerRequest::_getEtag (request->_tempFile , etag)) {
@@ -221,8 +221,8 @@ void AsyncStaticWebHandler::handleRequest(AsyncWebServerRequest *request) {
221
221
return ;
222
222
}
223
223
224
- // Reset file position to the beginning so the file can be served from the start.
225
- request->_tempFile .seek (0 );
224
+ // Reset file position to the beginning so the file can be served from the start.
225
+ request->_tempFile .seek (0 );
226
226
} else if (_callback == nullptr ) {
227
227
// We don't have a Template processor
228
228
uint32_t etagValue;
@@ -243,21 +243,21 @@ void AsyncStaticWebHandler::handleRequest(AsyncWebServerRequest *request) {
243
243
AsyncWebServerResponse *response;
244
244
245
245
// Get raw header pointers to avoid creating temporary String objects
246
- const char * inm = request->header (T_INM).c_str (); // If-None-Match
247
- const char * ims = request->header (T_IMS).c_str (); // If-Modified-Since
246
+ const char * inm = request->header (T_INM).c_str (); // If-None-Match
247
+ const char * ims = request->header (T_IMS).c_str (); // If-Modified-Since
248
248
249
249
bool notModified = false ;
250
250
// 1. If the client sent If-None-Match and we have an ETag → compare
251
251
if (*etag != ' \0 ' && inm && *inm) {
252
- if (strcmp (inm, etag) == 0 ) {
253
- notModified = true ;
254
- }
252
+ if (strcmp (inm, etag) == 0 ) {
253
+ notModified = true ;
254
+ }
255
255
}
256
256
// 2. Otherwise, if there is no ETag and no Template processor but we have Last-Modified and Last-Modified matches
257
257
else if (*etag == ' \0 ' && _callback == nullptr && _last_modified.length () > 0 && ims && *ims && strcmp (ims, _last_modified.c_str ()) == 0 ) {
258
258
log_d (" _last_modified: %s" , _last_modified.c_str ());
259
259
log_d (" ims: %s" , ims);
260
- notModified = true ;
260
+ notModified = true ;
261
261
}
262
262
263
263
if (notModified) {
@@ -266,9 +266,9 @@ void AsyncStaticWebHandler::handleRequest(AsyncWebServerRequest *request) {
266
266
} else {
267
267
response = new AsyncFileResponse (request->_tempFile , filename, emptyString, false , _callback);
268
268
if (!response) {
269
- #ifdef ESP32
270
- log_e (" Failed to allocate" );
271
- #endif
269
+ #ifdef ESP32
270
+ log_e (" Failed to allocate" );
271
+ #endif
272
272
request->abort ();
273
273
return ;
274
274
}
@@ -286,8 +286,7 @@ void AsyncStaticWebHandler::handleRequest(AsyncWebServerRequest *request) {
286
286
// Set cache control
287
287
if (_cache_control.length ()) {
288
288
response->addHeader (T_Cache_Control, _cache_control.c_str (), false );
289
- }
290
- else {
289
+ } else {
291
290
response->addHeader (T_Cache_Control, T_no_cache, false );
292
291
}
293
292
0 commit comments