FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ESPAsyncWebServer/src/AsyncWebHeader.cpp at main · ESP32Async/ESPAsyncWebServer · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
ESP32Async
/
ESPAsyncWebServer
Public
forked from
me-no-dev/ESPAsyncWebServer
Notifications
You must be signed in to change notification settings
Fork
108
Star
648
Code
Issues
0
Pull requests
1
Discussions
Actions
Projects
Security and quality
3
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ESPAsyncWebServer
/
src
/
AsyncWebHeader.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (33 loc) · 1.26 KB
Breadcrumbs
ESPAsyncWebServer
/
src
/
AsyncWebHeader.cpp
Copy path
File metadata and controls
35 lines (33 loc) · 1.26 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
SPDX-License-Identifier: LGPL-3.0-or-later
//
Copyright 2016-2026 Hristo Gochkov, Mathieu Carbou, Emil Muratov, Will Miles
#
include
<
ESPAsyncWebServer.h
>
const
AsyncWebHeader
AsyncWebHeader::parse
(
const
char
*data) {
//
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers
//
In HTTP/1.X, a header is a case-insensitive name followed by a colon, then optional whitespace which will be ignored, and finally by its value
if
(!data) {
return
AsyncWebHeader
();
//
nullptr
}
if
(data[
0
] ==
'
\0
'
) {
return
AsyncWebHeader
();
//
empty string
}
if
(
strchr
(data,
'
\n
'
) ||
strchr
(data,
'
\r
'
)) {
return
AsyncWebHeader
();
//
Invalid header format
}
const
char
*colon =
strchr
(data,
'
:
'
);
if
(!colon) {
return
AsyncWebHeader
();
//
separator not found
}
if
(colon == data) {
return
AsyncWebHeader
();
//
Header name cannot be empty
}
const
char
*startOfValue = colon +
1
;
//
Skip the colon
//
RFC 7230 §3.2.3: OWS (optional whitespace) = *( SP / HTAB )
//
Skip all leading spaces and tabs, not just the first one.
while
(*startOfValue ==
'
'
|| *startOfValue ==
'
\t
'
) {
startOfValue++;
}
String name;
name.
reserve
(colon - data);
name.
concat
(data, colon - data);
return
AsyncWebHeader
(name,
String
(startOfValue));
}
Back
|
FazBrowse Home
|
New Git URL