Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace http-parser with llhttp #126

Merged
merged 10 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .github/memory_statistics_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@
"src": [
"source/core_http_client.c",
{
"file": "source/dependency/3rdparty/http_parser/http_parser.c",
"tag": "http-parser"
"file": "source/dependency/3rdparty/llhttp/src/api.c",
"tag": "llhttp"
},
{
"file": "source/dependency/3rdparty/llhttp/src/http.c",
"tag": "llhttp"
},
{
"file": "source/dependency/3rdparty/llhttp/src/llhttp.c",
"tag": "llhttp"
}
],
"include": [
"source/include",
"source/interface",
"source/dependency/3rdparty/http_parser"
"source/dependency/3rdparty/llhttp/include"
],
"compiler_flags": [
"HTTP_DO_NOT_USE_CUSTOM_CONFIG"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: ["**"]
pull_request:
branches: [main]
branches: ["**"]
workflow_dispatch:

jobs:
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
path = test/cbmc/litani
url = https://github.com/awslabs/aws-build-accumulator
update = none
[submodule "source/dependency/3rdparty/http_parser"]
path = source/dependency/3rdparty/http_parser
url = https://github.com/nodejs/http-parser.git
[submodule "source/dependency/3rdparty/llhttp"]
path = source/dependency/3rdparty/llhttp
url = https://github.com/nodejs/llhttp.git
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

Expand Down
20 changes: 15 additions & 5 deletions docs/doxygen/include/size_table.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,26 @@
<tr>
<td>core_http_client.c</td>
<td><center>3.2K</center></td>
<td><center>2.5K</center></td>
</tr>
<tr>
<td>api.c (llhttp)</td>
<td><center>2.6K</center></td>
<td><center>2.0K</center></td>
</tr>
<tr>
<td>http.c (llhttp)</td>
<td><center>0.3K</center></td>
<td><center>0.3K</center></td>
</tr>
<tr>
<td>http_parser.c (http-parser)</td>
<td><center>15.7K</center></td>
<td><center>13.0K</center></td>
<td>llhttp.c (llhttp)</td>
<td><center>17.9K</center></td>
<td><center>15.9K</center></td>
</tr>
<tr>
<td><b>Total estimates</b></td>
<td><b><center>18.9K</center></b></td>
<td><b><center>15.6K</center></b></td>
<td><b><center>24.0K</center></b></td>
<td><b><center>20.7K</center></b></td>
</tr>
</table>
8 changes: 4 additions & 4 deletions docs/doxygen/pages.dox
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This HTTP Client library implements a subset of the HTTP/1.1 protocol. Features
of this library include:
- Fully synchronous API, to allow applications to completely manage their concurrency and multi-threading.
- Operations on user supplied buffers, so that applications have complete control of their memory allocation strategy.
- Integration with [http-parser](https://github.com/nodejs/http-parser) to handle chunked encoding.
- Integration with [llhttp](https://github.com/nodejs/llhttp) to handle chunked encoding.

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

If the user application wants to avoid re-parsing @ref HTTPResponse_t.pBuffer,
then the user application may register a callback in
@ref HTTPResponse_t.pHeaderParsingCallback. When the HTTP response message is
first received from the network, in @ref HTTPClient_Send, http-parser is invoked
first received from the network, in @ref HTTPClient_Send, llhttp is invoked
to parse the response. This first parsing in @ref HTTPClient_Send will invoke
@ref HTTPResponse_t.pHeaderParsingCallback for each header that is found
in response. Please see the sequence diagram below for an illustration of when
Expand Down
6 changes: 4 additions & 2 deletions httpFilePaths.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
# HTTP library source files.
set( HTTP_SOURCES
${CMAKE_CURRENT_LIST_DIR}/source/core_http_client.c
${CMAKE_CURRENT_LIST_DIR}/source/dependency/3rdparty/http_parser/http_parser.c )
${CMAKE_CURRENT_LIST_DIR}/source/dependency/3rdparty/llhttp/src/api.c
${CMAKE_CURRENT_LIST_DIR}/source/dependency/3rdparty/llhttp/src/llhttp.c
${CMAKE_CURRENT_LIST_DIR}/source/dependency/3rdparty/llhttp/src/http.c )

# HTTP library public include directories.
set( HTTP_INCLUDE_PUBLIC_DIRS
${CMAKE_CURRENT_LIST_DIR}/source/include
${CMAKE_CURRENT_LIST_DIR}/source/interface
${CMAKE_CURRENT_LIST_DIR}/source/dependency/3rdparty/http_parser )
${CMAKE_CURRENT_LIST_DIR}/source/dependency/3rdparty/llhttp/include )
7 changes: 6 additions & 1 deletion lexicon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ chk
chunked
colspan
com
cond
config
configpagestyle
const
Expand All @@ -42,6 +43,7 @@ defgroup
doesn
doxygen
endcode
endcond
endif
enums
eof
Expand Down Expand Up @@ -122,6 +124,9 @@ lastheadervaluelen
latin
len
linux
llhttp
llhttpparser
llhttpsettings
logdebug
logerror
loginfo
Expand Down Expand Up @@ -201,7 +206,7 @@ prequestbodybuf
prequestheaders
prequestinfo
presponse
processhttpparsererror
processllhttperror
ptransport
ptransportinterface
pvalue
Expand Down
6 changes: 3 additions & 3 deletions manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ version: "v2.1.0"
description: |
"Client implementation of the HTTP/1.1 specification for embedded devices.\n"
dependencies:
- name : "http-parser"
version: "v2.9.4"
- name : "llhttp"
version: "release/v6.0.5"
repository:
type: "git"
url: "https://github.com/nodejs/http-parser"
url: "https://github.com/nodejs/llhttp"
license: "MIT"
Loading