|
1 | 1 | # llhttp |
| 2 | +[](https://github.com/nodejs/llhttp/actions?query=workflow%3ACI) |
2 | 3 |
|
3 | 4 | Port of [http_parser][0] to [llparse][1]. |
4 | 5 |
|
5 | | -**IMPORTANT: The 2.x series is discontinued and not maintained anymore. Update to the latest version of llhttp as soon as possible. The only exception is the 2.1.x series which will be supported until Node.js 14 goes End-Of-Life).** |
6 | | - |
7 | 6 | ## Why? |
8 | 7 |
|
9 | 8 | Let's face it, [http_parser][0] is practically unmaintainable. Even |
@@ -33,7 +32,7 @@ So far llhttp outperforms http_parser: |
33 | 32 |
|
34 | 33 | | | input size | bandwidth | reqs/sec | time | |
35 | 34 | |:----------------|-----------:|-------------:|-----------:|--------:| |
36 | | -| **llhttp** | 8192.00 mb | 1777.24 mb/s | 3583799.39 ops/sec | 4.61 s | |
| 35 | +| **llhttp** | 8192.00 mb | 1777.24 mb/s | 3583799.39 req/sec | 4.61 s | |
37 | 36 | | **http_parser** | 8192.00 mb | 694.66 mb/s | 1406180.33 req/sec | 11.79 s | |
38 | 37 |
|
39 | 38 | llhttp is faster by approximately **156%**. |
@@ -91,9 +90,60 @@ if (err == HPE_OK) { |
91 | 90 | parser.reason); |
92 | 91 | } |
93 | 92 | ``` |
| 93 | +For more information on API usage, please refer to [src/native/api.h](https://github.com/nodejs/llhttp/blob/main/src/native/api.h). |
| 94 | +
|
| 95 | +## Build Instructions |
| 96 | +
|
| 97 | +Make sure you have [Node.js](https://nodejs.org/), npm and npx installed. Then under project directory run: |
| 98 | +
|
| 99 | +```sh |
| 100 | +npm install |
| 101 | +make |
| 102 | +``` |
94 | 103 |
|
95 | 104 | --- |
96 | 105 |
|
| 106 | +### Bindings to other languages |
| 107 | + |
| 108 | +* Python: [pallas/pyllhttp][8] |
| 109 | +* Ruby: [metabahn/llhttp][9] |
| 110 | +* Rust: [JackLiar/rust-llhttp][10] |
| 111 | + |
| 112 | +### Using with CMake |
| 113 | + |
| 114 | +If you want to use this library in a CMake project you can use the snippet below. |
| 115 | + |
| 116 | +``` |
| 117 | +FetchContent_Declare(llhttp |
| 118 | + URL "https://github.com/nodejs/llhttp/archive/refs/tags/v6.0.5.tar.gz") # Using version 6.0.5 |
| 119 | +
|
| 120 | +FetchContent_MakeAvailable(llhttp) |
| 121 | +
|
| 122 | +target_link_libraries(${EXAMPLE_PROJECT_NAME} ${PROJECT_LIBRARIES} llhttp ${PROJECT_NAME}) |
| 123 | +``` |
| 124 | + |
| 125 | +## Building on Windows |
| 126 | + |
| 127 | +### Installation |
| 128 | + |
| 129 | +* `choco install git` |
| 130 | +* `choco install node` |
| 131 | +* `choco install llvm` (or install the `C++ Clang tools for Windows` optional package from the Visual Studio 2019 installer) |
| 132 | +* `choco install make` (or if you have MinGW, it comes bundled) |
| 133 | + |
| 134 | +1. Ensure that `Clang` and `make` are in your system path. |
| 135 | +2. Using Git Bash, clone the repo to your preferred location. |
| 136 | +3. Cd into the cloned directory and run `npm install` |
| 137 | +5. Run `make` |
| 138 | +6. Your `repo/build` directory should now have `libllhttp.a` and `libllhttp.so` static and dynamic libraries. |
| 139 | +7. When building your executable, you can link to these libraries. Make sure to set the build folder as an include path when building so you can reference the declarations in `repo/build/llhttp.h`. |
| 140 | + |
| 141 | +### A simple example on linking with the library: |
| 142 | + |
| 143 | +Assuming you have an executable `main.cpp` in your current working directory, you would run: `clang++ -Os -g3 -Wall -Wextra -Wno-unused-parameter -I/path/to/llhttp/build main.cpp /path/to/llhttp/build/libllhttp.a -o main.exe`. |
| 144 | + |
| 145 | +If you are getting `unresolved external symbol` linker errors you are likely attempting to build `llhttp.c` without linking it with object files from `api.c` and `http.c`. |
| 146 | + |
97 | 147 | #### LICENSE |
98 | 148 |
|
99 | 149 | This software is licensed under the MIT License. |
@@ -127,3 +177,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. |
127 | 177 | [5]: https://llvm.org/docs/LangRef.html#call-instruction |
128 | 178 | [6]: https://clang.llvm.org/ |
129 | 179 | [7]: https://github.com/nodejs/node |
| 180 | +[8]: https://github.com/pallas/pyllhttp |
| 181 | +[9]: https://github.com/metabahn/llhttp |
| 182 | +[10]: https://github.com/JackLiar/rust-llhttp |
0 commit comments