blob: 3a7f3ffd14fed561a8a906f53be4d5d8a325df10 (
plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
# Contributing to Undici
* [Guides](#guides)
* [Update `llhttp`](#update-llhttp)
* [Lint](#lint)
* [Test](#test)
* [Coverage](#coverage)
* [Update `WPTs`](#update-wpts)
* [Developer's Certificate of Origin 1.1](#developers-certificate-of-origin)
* [Moderation Policy](#moderation-policy)
<a id="guides"></a>
## Guides
<a id="update-llhttp"></a>
### Update `llhttp`
The HTTP parser used by `undici` is a WebAssembly build of [`llhttp`](https://github.com/nodejs/llhttp).
While the project itself provides a way to compile targeting WebAssembly, at the moment we embed the sources
directly and compile the module in `undici`.
The `deps/llhttp/include` folder contains the C header files, while the `deps/llhttp/src` folder contains
the C source files needed to compile the module.
The `lib/llhttp` folder contains the `.js` transpiled assets required to implement a parser.
The following are the steps required to perform an update.
#### Clone the [llhttp](https://github.com/nodejs/llhttp) project
```bash
git clone git@github.com:nodejs/llhttp.git
cd llhttp
```
#### Checkout a `llhttp` release
```bash
git checkout <tag>
```
#### Install the `llhttp` dependencies
```bash
npm i
```
#### Run the wasm build script
> This requires [docker](https://www.docker.com/) installed on your machine.
```bash
npm run build-wasm
```
#### Copy the sources to `undici`
```bash
cp build/wasm/*.js <your-path-to-undici>/lib/llhttp/
cp build/wasm/*.js.map <your-path-to-undici>/lib/llhttp/
cp build/wasm/*.d.ts <your-path-to-undici>/lib/llhttp/
cp src/native/api.c src/native/http.c build/c/llhttp.c <your-path-to-undici>/deps/llhttp/src/
cp src/native/api.h build/llhttp.h <your-path-to-undici>/deps/llhttp/include/
```
#### Build the WebAssembly module in `undici`
> This requires [docker](https://www.docker.com/) installed on your machine.
```bash
cd <your-path-to-undici>
npm run build:wasm
```
#### Commit the contents of lib/llhttp
Create a commit which includes all of the updated files in lib/llhttp.
<a id="update-wpts"></a>
### Update `WPTs`
`undici` runs a subset of the [`web-platform-tests`](https://github.com/web-platform-tests/wpt).
Here are the steps to update them.
<details>
<summary>Skip the tutorial</summary>
```bash
git clone --depth 1 --single-branch --branch epochs/daily --filter=blob:none --sparse https://github.com/web-platform-tests/wpt.git test/wpt/tests
cd test/wpt/tests
git sparse-checkout add /resources
git sparse-checkout add /interfaces
git sparse-checkout add /common
git sparse-checkout add /fetch
git sparse-checkout add /FileAPI
git sparse-checkout add /xhr
git sparse-checkout add /websockets
git sparse-checkout add /mimesniff
git sparse-checkout add /storage
git sparse-checkout add /service-workers
```
</details>
#### Sparse-clone the [wpt](https://github.com/web-platform-tests/wpt) repo
```bash
git clone --depth 1 --single-branch --branch epochs/daily --filter=blob:none --sparse https://github.com/web-platform-tests/wpt.git test/wpt/tests
cd test/wpt/tests
```
#### Checkout the tests
Only run the commands for the folder(s) you want to update.
```bash
git sparse-checkout add /fetch
git sparse-checkout add /FileAPI
git sparse-checkout add /xhr
git sparse-checkout add /websockets
git sparse-checkout add /resources
git sparse-checkout add /common
# etc
```
#### Run the tests
Run the tests to ensure that any new failures are marked as such.
You can mark tests as failing in their corresponding [status](./test/wpt/status) file.
```bash
npm run test:wpt
```
<a id="lint"></a>
### Lint
```bash
npm run lint
```
<a id="test"></a>
### Test
```bash
npm run test
```
<a id="coverage"></a>
### Coverage
```bash
npm run coverage
```
<a id="developers-certificate-of-origin"></a>
## Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
* (a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
* (b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
* (c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
* (d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
<a id="moderation-policy"></a>
### Moderation Policy
The [Node.js Moderation Policy] applies to this project.
[Node.js Moderation Policy]:
https://github.com/nodejs/admin/blob/main/Moderation-Policy.md
|