Skip to content

Commit ff33d46

Browse files
Merge LLHTTP changes to main (FreeRTOS#129)
* Replace http-parser with llhttp (FreeRTOS#126) * Add llhttp submodule * Replace http-parser with llhttp in source * Fix CI checks * Fix unit tests 100% coverage * Rename functions * Disable strict mode * Remove http-parser submodule * Update CBMC proofs for llhttp (FreeRTOS#127) * Update CBMC proofs * Update execute mocks * Rename stub file * Return error fields from stubs * Remove unused variable (FreeRTOS#128) * Remove unused variable * Void unused status code * Address review comments Signed-off-by: Gaurav Aggarwal <[email protected]> Co-authored-by: Muneeb Ahmed <[email protected]>
1 parent 1f61846 commit ff33d46

39 files changed

+528
-514
lines changed

.github/memory_statistics_config.json

+11-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,22 @@
33
"src": [
44
"source/core_http_client.c",
55
{
6-
"file": "source/dependency/3rdparty/http_parser/http_parser.c",
7-
"tag": "http-parser"
6+
"file": "source/dependency/3rdparty/llhttp/src/api.c",
7+
"tag": "llhttp"
8+
},
9+
{
10+
"file": "source/dependency/3rdparty/llhttp/src/http.c",
11+
"tag": "llhttp"
12+
},
13+
{
14+
"file": "source/dependency/3rdparty/llhttp/src/llhttp.c",
15+
"tag": "llhttp"
816
}
917
],
1018
"include": [
1119
"source/include",
1220
"source/interface",
13-
"source/dependency/3rdparty/http_parser"
21+
"source/dependency/3rdparty/llhttp/include"
1422
],
1523
"compiler_flags": [
1624
"HTTP_DO_NOT_USE_CUSTOM_CONFIG"

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches: ["**"]
66
pull_request:
7-
branches: [main]
7+
branches: ["**"]
88
workflow_dispatch:
99

1010
jobs:

.gitmodules

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
path = test/cbmc/litani
1111
url = https://github.com/awslabs/aws-build-accumulator
1212
update = none
13-
[submodule "source/dependency/3rdparty/http_parser"]
14-
path = source/dependency/3rdparty/http_parser
15-
url = https://github.com/nodejs/http-parser.git
13+
[submodule "source/dependency/3rdparty/llhttp"]
14+
path = source/dependency/3rdparty/llhttp
15+
url = https://github.com/nodejs/llhttp.git

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This repository contains a C language HTTP client library designed for embedded
44
platforms. It has no dependencies on any additional libraries other than the
5-
standard C library, [http-parser](https://github.com/nodejs/http-parser), and
5+
standard C library, [llhttp](https://github.com/nodejs/llhttp), and
66
a customer-implemented transport interface. This library is distributed under
77
the [MIT Open Source License](LICENSE).
88

docs/doxygen/include/size_table.md

+15-5
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,26 @@
1010
<tr>
1111
<td>core_http_client.c</td>
1212
<td><center>3.2K</center></td>
13+
<td><center>2.5K</center></td>
14+
</tr>
15+
<tr>
16+
<td>api.c (llhttp)</td>
1317
<td><center>2.6K</center></td>
18+
<td><center>2.0K</center></td>
19+
</tr>
20+
<tr>
21+
<td>http.c (llhttp)</td>
22+
<td><center>0.3K</center></td>
23+
<td><center>0.3K</center></td>
1424
</tr>
1525
<tr>
16-
<td>http_parser.c (http-parser)</td>
17-
<td><center>15.7K</center></td>
18-
<td><center>13.0K</center></td>
26+
<td>llhttp.c (llhttp)</td>
27+
<td><center>17.9K</center></td>
28+
<td><center>15.9K</center></td>
1929
</tr>
2030
<tr>
2131
<td><b>Total estimates</b></td>
22-
<td><b><center>18.9K</center></b></td>
23-
<td><b><center>15.6K</center></b></td>
32+
<td><b><center>24.0K</center></b></td>
33+
<td><b><center>20.7K</center></b></td>
2434
</tr>
2535
</table>

docs/doxygen/pages.dox

+4-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This HTTP Client library implements a subset of the HTTP/1.1 protocol. Features
77
of this library include:
88
- Fully synchronous API, to allow applications to completely manage their concurrency and multi-threading.
99
- Operations on user supplied buffers, so that applications have complete control of their memory allocation strategy.
10-
- Integration with [http-parser](https://github.com/nodejs/http-parser) to handle chunked encoding.
10+
- Integration with [llhttp](https://github.com/nodejs/llhttp) to handle chunked encoding.
1111

1212
Feature of HTTP/1.1 not supported in this library:
1313
- Streaming uploads and downloads. Range requests for partial content responses are highly encouraged with this API.
@@ -110,7 +110,7 @@ If the request has a body it is passed as a parameter to @ref HTTPClient_Send.
110110
As soon as the response is received from the network it is parsed. The final
111111
parsed response is represented by the @ref HTTPResponse_t returned from
112112
@ref HTTPClient_Send. Parsing the HTTP response is done using
113-
[http-parser](https://github.com/nodejs/http-parser). http-parser invokes
113+
[llhttp](https://github.com/nodejs/llhttp). llhttp invokes
114114
callbacks for each section in the HTTP response it finds. Using these callbacks
115115
the HTTP client library sets the members of @ref HTTPResponse_t to return from
116116
@ref HTTPClient_Send. The overall flow of @ref HTTPClient_Send is
@@ -125,14 +125,14 @@ can be read from the headers found in @ref HTTPResponse_t.pHeaders. The function
125125
@ref HTTPClient_ReadHeader reads the headers from an @ref HTTPResponse_t.
126126
@ref HTTPClient_ReadHeader will re-parse the response in
127127
@ref HTTPResponse_t.pBuffer, looking for the header field of interest.
128-
Re-parsing involves using http-parser to look at each character starting from
128+
Re-parsing involves using llhttp to look at each character starting from
129129
the beginning of @ref HTTPResponse_t.pBuffer until the header field of interest
130130
is found.
131131

132132
If the user application wants to avoid re-parsing @ref HTTPResponse_t.pBuffer,
133133
then the user application may register a callback in
134134
@ref HTTPResponse_t.pHeaderParsingCallback. When the HTTP response message is
135-
first received from the network, in @ref HTTPClient_Send, http-parser is invoked
135+
first received from the network, in @ref HTTPClient_Send, llhttp is invoked
136136
to parse the response. This first parsing in @ref HTTPClient_Send will invoke
137137
@ref HTTPResponse_t.pHeaderParsingCallback for each header that is found
138138
in response. Please see the sequence diagram below for an illustration of when
@@ -161,7 +161,6 @@ then the @ref HTTP_DO_NOT_USE_CUSTOM_CONFIG macro must be defined.
161161
@see [Configurations](@ref http_config)
162162

163163
The following macros can be configured for this library:
164-
- @ref HTTP_MAX_RESPONSE_HEADERS_SIZE_BYTES
165164
- @ref HTTP_USER_AGENT_VALUE
166165
- @ref HTTP_SEND_RETRY_TIMEOUT_MS
167166
- @ref HTTP_RECV_RETRY_TIMEOUT_MS
@@ -243,9 +242,6 @@ config macros defined in core_http_config_defaults.h file.
243242
If a custom config is provided, then HTTP_DO_NOT_USE_CUSTOM_CONFIG should not be
244243
defined.
245244

246-
@section HTTP_MAX_RESPONSE_HEADERS_SIZE_BYTES
247-
@copydoc HTTP_MAX_RESPONSE_HEADERS_SIZE_BYTES
248-
249245
@section HTTP_USER_AGENT_VALUE
250246
@copydoc HTTP_USER_AGENT_VALUE
251247

httpFilePaths.cmake

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
# HTTP library source files.
99
set( HTTP_SOURCES
1010
${CMAKE_CURRENT_LIST_DIR}/source/core_http_client.c
11-
${CMAKE_CURRENT_LIST_DIR}/source/dependency/3rdparty/http_parser/http_parser.c )
11+
${CMAKE_CURRENT_LIST_DIR}/source/dependency/3rdparty/llhttp/src/api.c
12+
${CMAKE_CURRENT_LIST_DIR}/source/dependency/3rdparty/llhttp/src/llhttp.c
13+
${CMAKE_CURRENT_LIST_DIR}/source/dependency/3rdparty/llhttp/src/http.c )
1214

1315
# HTTP library public include directories.
1416
set( HTTP_INCLUDE_PUBLIC_DIRS
1517
${CMAKE_CURRENT_LIST_DIR}/source/include
1618
${CMAKE_CURRENT_LIST_DIR}/source/interface
17-
${CMAKE_CURRENT_LIST_DIR}/source/dependency/3rdparty/http_parser )
19+
${CMAKE_CURRENT_LIST_DIR}/source/dependency/3rdparty/llhttp/include )

lexicon.txt

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ chk
2525
chunked
2626
colspan
2727
com
28+
cond
2829
config
2930
configpagestyle
3031
const
@@ -42,6 +43,7 @@ defgroup
4243
doesn
4344
doxygen
4445
endcode
46+
endcond
4547
endif
4648
enums
4749
eof
@@ -102,7 +104,6 @@ httpsecurityalertinvalidcharacter
102104
httpsecurityalertinvalidchunkheader
103105
httpsecurityalertinvalidprotocolversion
104106
httpsecurityalertinvalidstatuscode
105-
httpsecurityalertresponseheaderssizelimitexceeded
106107
httpstatus
107108
httpsuccess
108109
ietf
@@ -122,6 +123,9 @@ lastheadervaluelen
122123
latin
123124
len
124125
linux
126+
llhttp
127+
llhttpparser
128+
llhttpsettings
125129
logdebug
126130
logerror
127131
loginfo
@@ -201,7 +205,7 @@ prequestbodybuf
201205
prequestheaders
202206
prequestinfo
203207
presponse
204-
processhttpparsererror
208+
processllhttperror
205209
ptransport
206210
ptransportinterface
207211
pvalue

manifest.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ version: "v2.1.0"
33
description: |
44
"Client implementation of the HTTP/1.1 specification for embedded devices.\n"
55
dependencies:
6-
- name : "http-parser"
7-
version: "v2.9.4"
6+
- name : "llhttp"
7+
version: "release/v6.0.5"
88
repository:
99
type: "git"
10-
url: "https://github.com/nodejs/http-parser"
10+
url: "https://github.com/nodejs/llhttp"
1111
license: "MIT"

0 commit comments

Comments
 (0)