Skip to content

Commit 32a29b4

Browse files
ci(pre-commit): Apply automatic fixes
1 parent 440762a commit 32a29b4

File tree

3 files changed

+20
-31
lines changed

3 files changed

+20
-31
lines changed

examples/Headers/Headers.ino

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,34 +37,34 @@ void setup() {
3737
//List all collected headers
3838
int headers = request->headers();
3939
int i;
40-
for(i=0;i<headers;i++){
41-
const AsyncWebHeader* h = request->getHeader(i);
40+
for (i = 0; i < headers; i++) {
41+
const AsyncWebHeader *h = request->getHeader(i);
4242
Serial.printf("HEADER[%s]: %s\n", h->name().c_str(), h->value().c_str());
4343
}
4444

45-
AsyncWebServerResponse *response = request->beginResponse(200, "text/plain", "Hello World!");
45+
AsyncWebServerResponse *response = request->beginResponse(200, "text/plain", "Hello World!");
4646

47-
//Add header to the response
48-
response->addHeader("Server","ESP Async Web Server");
47+
//Add header to the response
48+
response->addHeader("Server", "ESP Async Web Server");
4949

50-
//Add multiple headers with the same name
51-
response->addHeader("Set-Cookie","sessionId=38afes7a8", false);
52-
response->addHeader("Set-Cookie","id=a3fWa; Max-Age=2592000", false);
53-
response->addHeader("Set-Cookie","qwerty=219ffwef9w0f; Domain=example.com", false);
50+
//Add multiple headers with the same name
51+
response->addHeader("Set-Cookie", "sessionId=38afes7a8", false);
52+
response->addHeader("Set-Cookie", "id=a3fWa; Max-Age=2592000", false);
53+
response->addHeader("Set-Cookie", "qwerty=219ffwef9w0f; Domain=example.com", false);
5454

55-
//Remove specific header
56-
response->removeHeader("Set-Cookie","sessionId=38afes7a8");
55+
//Remove specific header
56+
response->removeHeader("Set-Cookie", "sessionId=38afes7a8");
5757

58-
//Remove all headers with the same name
59-
response->removeHeader("Set-Cookie");
58+
//Remove all headers with the same name
59+
response->removeHeader("Set-Cookie");
6060

61-
request->send(response);
61+
request->send(response);
6262
});
6363

6464
server.begin();
6565
}
6666

6767
void loop() {
68-
//Sleep in the loop task to not keep the CPU busy
69-
delay(1000);
68+
//Sleep in the loop task to not keep the CPU busy
69+
delay(1000);
7070
}

src/WebResponses.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ bool AsyncWebServerResponse::addHeader(const char *name, const char *value, bool
142142
// remove, break and add the new one
143143
_headers.erase(i);
144144
break;
145-
} else if(headerMustBePresentOnce(i->name())){ // we can have only one header with that name
145+
} else if (headerMustBePresentOnce(i->name())) { // we can have only one header with that name
146146
// do not update
147147
return false;
148148
} else {
149-
break; // accept multiple headers with the same name
149+
break; // accept multiple headers with the same name
150150
}
151151
}
152152
}

src/literals.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -187,18 +187,7 @@ static constexpr const char *T_HTTP_CODE_505 = "HTTP Version not supported";
187187
static constexpr const char *T_HTTP_CODE_ANY = "Unknown code";
188188

189189
static constexpr const uint8_t T_only_once_headers_len = 11;
190-
static constexpr const char * T_only_once_headers[] = {
191-
T_Content_Length,
192-
T_Content_Type,
193-
T_Date,
194-
T_ETag,
195-
T_Last_Modified,
196-
T_LOCATION,
197-
T_retry_after,
198-
T_Transfer_Encoding,
199-
T_Content_Location,
200-
T_Server,
201-
T_WWW_AUTH
202-
};
190+
static constexpr const char *T_only_once_headers[] = {T_Content_Length, T_Content_Type, T_Date, T_ETag, T_Last_Modified, T_LOCATION, T_retry_after,
191+
T_Transfer_Encoding, T_Content_Location, T_Server, T_WWW_AUTH};
203192

204193
} // namespace asyncsrv

0 commit comments

Comments
 (0)