Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 04fd5e5

Browse files
ci(pre-commit): Apply automatic fixes
1 parent 9e83287 commit 04fd5e5

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

src/WebHandlers.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ bool AsyncStaticWebHandler::_searchFile(AsyncWebServerRequest *request, const St
190190
/**
191191
* @brief Handles an incoming HTTP request for a static file.
192192
*
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).
196196
*
197197
* @param request Pointer to the incoming AsyncWebServerRequest object.
198198
*/
@@ -207,11 +207,11 @@ void AsyncStaticWebHandler::handleRequest(AsyncWebServerRequest *request) {
207207
return;
208208
}
209209

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
211211
char etag[9];
212-
const char* tempFileName = request->_tempFile.name();
212+
const char *tempFileName = request->_tempFile.name();
213213
const size_t lenFilename = strlen(tempFileName);
214-
214+
215215
if (lenFilename > T__GZ_LEN && memcmp(tempFileName + lenFilename - T__GZ_LEN, T__gz, T__GZ_LEN) == 0) {
216216
//File is a gz, get etag from CRC in trailer
217217
if (!AsyncWebServerRequest::_getEtag(request->_tempFile, etag)) {
@@ -221,8 +221,8 @@ void AsyncStaticWebHandler::handleRequest(AsyncWebServerRequest *request) {
221221
return;
222222
}
223223

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);
226226
} else if (_callback == nullptr) {
227227
// We don't have a Template processor
228228
uint32_t etagValue;
@@ -243,21 +243,21 @@ void AsyncStaticWebHandler::handleRequest(AsyncWebServerRequest *request) {
243243
AsyncWebServerResponse *response;
244244

245245
// 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
248248

249249
bool notModified = false;
250250
// 1. If the client sent If-None-Match and we have an ETag → compare
251251
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+
}
255255
}
256256
// 2. Otherwise, if there is no ETag and no Template processor but we have Last-Modified and Last-Modified matches
257257
else if (*etag == '\0' && _callback == nullptr && _last_modified.length() > 0 && ims && *ims && strcmp(ims, _last_modified.c_str()) == 0) {
258258
log_d("_last_modified: %s", _last_modified.c_str());
259259
log_d("ims: %s", ims);
260-
notModified = true;
260+
notModified = true;
261261
}
262262

263263
if (notModified) {
@@ -266,9 +266,9 @@ void AsyncStaticWebHandler::handleRequest(AsyncWebServerRequest *request) {
266266
} else {
267267
response = new AsyncFileResponse(request->_tempFile, filename, emptyString, false, _callback);
268268
if (!response) {
269-
#ifdef ESP32
270-
log_e("Failed to allocate");
271-
#endif
269+
#ifdef ESP32
270+
log_e("Failed to allocate");
271+
#endif
272272
request->abort();
273273
return;
274274
}
@@ -286,8 +286,7 @@ void AsyncStaticWebHandler::handleRequest(AsyncWebServerRequest *request) {
286286
// Set cache control
287287
if (_cache_control.length()) {
288288
response->addHeader(T_Cache_Control, _cache_control.c_str(), false);
289-
}
290-
else {
289+
} else {
291290
response->addHeader(T_Cache_Control, T_no_cache, false);
292291
}
293292

0 commit comments

Comments
 (0)