Commit 6192c98
committed
http: add checkIsHttpToken check for header fields
Ref: nodejs/node-convergence-archive#13
This adds a new check for header and trailer fields names and method
names to ensure that they conform to the HTTP token rule. If they do
not, a `TypeError` is thrown.
Previously this had an additional `strictMode` option that has been
removed in favor of making the strict check the default (and only)
behavior.
Doc and test case are included.
On the client-side
```javascript
var http = require('http');
var url = require('url');
var p = url.parse('http://localhost:8888');
p.headers = {'testing 123': 123};
http.client(p, function(res) { }); // throws
```
On the server-side
```javascript
var http = require('http');
var server = http.createServer(function(req,res) {
res.setHeader('testing 123', 123); // throws
res.end('...');
});
```
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Trevor Norris <trevnorris@nodejs.org>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
PR-URL: #25261 parent b50e89e commit 6192c98Copy full SHA for 6192c98
File tree
Expand file treeCollapse file tree
5 files changed
+85
-1
lines changedOpen diff view settings
Filter options
- doc/api
- lib
- test/parallel
Expand file treeCollapse file tree
5 files changed
+85
-1
lines changedOpen diff view settings
Collapse file
+5Lines changed: 5 additions & 0 deletions
- Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
364 | 364 | |
365 | 365 | |
366 | 366 | |
| 367 | + |
| 368 | + |
| 369 | + |
367 | 370 | |
368 | 371 | |
369 | 372 | |
| ||
439 | 442 | |
440 | 443 | |
441 | 444 | |
| 445 | + |
| 446 | + |
442 | 447 | |
443 | 448 | |
444 | 449 | |
|
Collapse file
+3Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
67 | 67 | |
68 | 68 | |
69 | 69 | |
| 70 | + |
| 71 | + |
| 72 | + |
70 | 73 | |
71 | 74 | |
72 | 75 | |
|
Collapse file
+10Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
195 | 195 | |
196 | 196 | |
197 | 197 | |
| 198 | + |
| 199 | + |
| 200 | + |
| 201 | + |
| 202 | + |
| 203 | + |
| 204 | + |
| 205 | + |
| 206 | + |
| 207 | + |
Collapse file
+11-1Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
295 | 295 | |
296 | 296 | |
297 | 297 | |
| 298 | + |
| 299 | + |
| 300 | + |
| 301 | + |
298 | 302 | |
299 | 303 | |
300 | 304 | |
| ||
323 | 327 | |
324 | 328 | |
325 | 329 | |
| 330 | + |
| 331 | + |
| 332 | + |
326 | 333 | |
327 | 334 | |
328 | 335 | |
| ||
498 | 505 | |
499 | 506 | |
500 | 507 | |
501 | | - |
| 508 | + |
| 509 | + |
| 510 | + |
| 511 | + |
502 | 512 | |
503 | 513 | |
504 | 514 | |
|
Collapse file
test/parallel/test-http-invalidheaderfield.js
Copy file name to clipboard+56Lines changed: 56 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 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 | + |
0 commit comments