Commit Graph

99 Commits

Author SHA1 Message Date
Aviv Keller
574f2dd517
lib: prefer optional chaining
PR-URL: https://github.com/nodejs/node/pull/55045
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
2024-09-24 19:48:15 +00:00
Antoine du Hamel
cbd2c387ce
http: remove prototype primordials
Co-authored-by: Yagiz Nizipli <yagiz@nizipli.com>
PR-URL: https://github.com/nodejs/node/pull/53698
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2024-07-06 10:33:16 +02:00
Paolo Insogna
65c8380a5a http: correctly translate HTTP method
PR-URL: https://github.com/nodejs/node/pull/52701
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2024-05-04 08:56:28 -07:00
Antoine du Hamel
a596af0819
tools: add lint rule to keep primordials in ASCII order
PR-URL: https://github.com/nodejs/node/pull/52592
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
2024-04-21 16:53:08 +00:00
Luigi Pinca
651c02cbbc
http: null the joinDuplicateHeaders property on cleanup
Null the `joinDuplicateHeaders` property when the parser is freed.

Refs: https://github.com/nodejs/node/pull/45982
PR-URL: https://github.com/nodejs/node/pull/48608
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
2023-07-03 06:20:13 +00:00
Antoine du Hamel
5f76836277
lib: add trailing commas to more internal files
PR-URL: https://github.com/nodejs/node/pull/46811
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2023-02-26 11:34:02 +01:00
Marco Ippolito
4080bada1a
http: join authorization headers
PR-URL: https://github.com/nodejs/node/pull/45982
Fixes: https://github.com/nodejs/node/issues/45699
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
2023-01-03 10:43:21 +00:00
theanarkh
da3949cfd7
http: fix http server connection list when close
PR-URL: https://github.com/nodejs/node/pull/43949
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Feng Yu <F3n67u@outlook.com>
2022-07-24 15:06:24 +01:00
Antoine du Hamel
a055337a02
lib: refactor to avoid unsafe regex primordials
PR-URL: https://github.com/nodejs/node/pull/43475
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
2022-06-27 17:16:06 +02:00
Paolo Insogna
b970634cfe http: defer reentrant execution of Parser::Execute
PR-URL: https://github.com/nodejs/node/pull/43369
Fixes: https://github.com/nodejs/node/issues/39671
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2022-06-22 10:55:18 +02:00
Paolo Insogna
3caa2c1a00
http: refactor headersTimeout and requestTimeout logic
PR-URL: https://github.com/nodejs/node/pull/41263
Fixes: https://github.com/nodejs/node/issues/33440
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2022-04-13 15:47:59 +01:00
shfshanyue
e9fc67815e http: remove CRLF variable
PR-URL: https://github.com/nodejs/node/pull/40101
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
2021-09-16 09:44:12 -04:00
Tobias Koppers
3ac223ed25 http: clean up HttpParser correctly
Remove reference to kOnMessageBegin from HttpParser
to avoid leaking Server instances in FreeList.

PR-URL: https://github.com/nodejs/node/pull/39292
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
2021-07-10 22:47:47 +02:00
Antoine du Hamel
ee9e2a2eb6 lib: revert primordials in a hot path
Evidence has shown that use of primordials have sometimes an impact of
performance. This commit reverts the changes who are most likely to be
responsible for performance regression in the HTTP response path.

PR-URL: https://github.com/nodejs/node/pull/38248
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-04-19 10:23:01 +02:00
Michaël Zasso
3dee23334d
http: optimize debug function correctly
Exporting a variable that will be mutated later doesn't work.

Refs: https://github.com/nodejs/node/issues/37937

PR-URL: https://github.com/nodejs/node/pull/37966
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2021-03-31 18:21:20 +02:00
Antoine du Hamel
83cce8717f lib: use <array>.push and <array>.unshift instead of <array>.concat
Using `push` and `unshift` methods is more performant than reassigning a
new array created with `concat`.

PR-URL: https://github.com/nodejs/node/pull/37239
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-02-26 11:11:22 +01:00
Antoine du Hamel
8cf5ae07e9 http: refactor to use more primordials
PR-URL: https://github.com/nodejs/node/pull/36194
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-12-29 16:06:05 +01:00
Matteo Collina
df08d527c2
http: add requestTimeout
This commits introduces a new http.Server option called requestTimeout
with a default value in milliseconds of 0.

If requestTimeout is set to a positive value, the server will start a new
timer set to expire in requestTimeout milliseconds when a new connection
is established. The timer is also set again if new requests after the
first are received on the socket (this handles pipelining and keep-alive
cases).
The timer is cancelled when:

1. the request body is completely received by the server.
2. the response is completed. This handles the case where the
application responds to the client without consuming the request body.
3. the connection is upgraded, like in the WebSocket case.

If the timer expires, then the server responds with status code 408 and
closes the connection.

CVE-2020-8251

PR-URL: https://github.com/nodejs-private/node-private/pull/208
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Mary Marchini <oss@mmarchini.me>
Co-Authored-By: Paolo Insogna <paolo@cowtech.it>
Co-Authored-By: Robert Nagy <ronagy@icloud.com>
2020-09-15 15:39:54 -04:00
Brian White
c24b74a7ab
lib: improve debuglog() performance
PR-URL: https://github.com/nodejs/node/pull/32260
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-05-30 17:24:43 -04:00
John Leidegren
26f150022f http: fixes memory retention issue with FreeList and HTTPParser
Fixes: https://github.com/nodejs/node/issues/29394
Refs: https://github.com/nodejs/node/pull/33167#issuecomment-622102450

PR-URL: https://github.com/nodejs/node/pull/33190
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
2020-05-05 16:14:46 +02:00
Alex R
b149eefa82 http: fix incorrect headersTimeout measurement
For keep-alive connections, the headersTimeout may fire during
subsequent request because the measurement was reset after
a request and not before a request.

PR-URL: https://github.com/nodejs/node/pull/32329
Fixes: https://github.com/nodejs/node/issues/27363
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2020-04-02 14:50:20 +02:00
Sam Roberts
02a0c74861 http: llhttp opt-in insecure HTTP header parsing
Allow insecure HTTP header parsing. Make clear it is insecure.

See:
- https://github.com/nodejs/node/pull/30553
- https://github.com/nodejs/node/issues/27711#issuecomment-556265881
- https://github.com/nodejs/node/issues/30515

PR-URL: https://github.com/nodejs/node/pull/30567
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-12-09 09:56:16 -08:00
Sebastien Ahkrin
eac3f0adc4
lib: replace Symbol global by the primordials Symbol
PR-URL: https://github.com/nodejs/node/pull/30737
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-12-08 13:38:58 +01:00
Michaël Zasso
0646eda4fc
lib: flatten access to primordials
Store all primordials as properties of the primordials object.
Static functions are prefixed by the constructor's name and prototype
methods are prefixed by the constructor's name followed by "Prototype".
For example: primordials.Object.keys becomes primordials.ObjectKeys.

PR-URL: https://github.com/nodejs/node/pull/30610
Refs: https://github.com/nodejs/node/issues/29766
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-11-25 10:28:15 +01:00
telenord
cd696959d9 http: http_common rename var to let and const
PR-URL: https://github.com/nodejs/node/pull/30288
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-11-12 09:50:13 +00:00
Anna Henningsen
ac59dc42ed
http: remove legacy parser
Remove the legacy `http_parser` implementation as a dependency
and all code that uses it in favor of llhttp, given that the latter
has been the default for all of Node 12 with no outstanding issues.

PR-URL: https://github.com/nodejs/node/pull/29589
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-09-20 20:18:35 +02:00
Robert Nagy
bdf07f4317 http: simplify drain()
Simplify and slightly optimize draining outgoing http streams. Avoid
extra event listener and inline with rest of the drain logic.

PR-URL: https://github.com/nodejs/node/pull/29081
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2019-08-19 12:56:08 -07:00
Anna Henningsen
ba565a3734 http: improve parser error messages
Include the library-provided reason in the Error’s `message`.

Fixes: https://github.com/nodejs/node/issues/28468

PR-URL: https://github.com/nodejs/node/pull/28487
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-07-05 22:36:53 -07:00
Gerhard Stoebich
8876ac5c35
async_hooks: fixup do not reuse HTTPParser
Fix some issues introduced/not fixed via
https://github.com/nodejs/node/pull/25094:
* Init hook is not emitted for a reused HTTPParser
* HTTPParser was still used as resource in init hook
* type used in init hook was always HTTPINCOMINGMESSAGE even for client
requests
* some tests have not been adapted to new resource names

With this change the async hooks init event is emitted during a call
to Initialize() as the type and resource object is available at this
time. As a result Initialize() must be called now which could be seen
as breaking change even HTTPParser is not part of documented API.

It was needed to put the ClientRequest instance into a wrapper object
instead passing it directly as async resource otherwise
test-domain-multi fails. I think this is because adding an EventEmitter
to a Domain adds a property 'domain' and the presence of this changes
the context propagation in domains.

Besides that tests still refering to resource HTTPParser have been
updated/improved.

Fixes: https://github.com/nodejs/node/issues/27467
Fixes: https://github.com/nodejs/node/issues/26961
Refs: https://github.com/nodejs/node/pull/25094

PR-URL: https://github.com/nodejs/node/pull/27477
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-05-03 16:02:55 +02:00
Joyee Cheung
a38e9c438a
lib: require globals instead of using the global proxy
In addition, use process.stderr instead of console.error when
there is no need to swallow the error.

PR-URL: https://github.com/nodejs/node/pull/27112
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-04-16 04:24:26 +08:00
Anatoli Papirovski
47f5cc1ad1 lib: faster FreeList
Make FreeList faster by using Reflect.apply and not using
is_reused_symbol, but rather just checking whether any
items are present in the list prior to calling alloc.

PR-URL: https://github.com/nodejs/node/pull/27021
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-04-11 05:40:59 +02:00
Michaël Zasso
0817840f77 lib: force using primordials for JSON, Math and Reflect
Use the "no-restricted-globals" ESLint rule to lint for it.

PR-URL: https://github.com/nodejs/node/pull/27027
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-04-03 21:36:08 +08:00
ZYSzys
4c4e4f4bda http: reduce usage of public util
PR-URL: https://github.com/nodejs/node/pull/26548
Refs: https://github.com/nodejs/node/issues/26546
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-03-12 06:40:57 +01:00
Ruben Bridgewater
f8763bb077
benchmark,doc,lib,test: capitalize comments
PR-URL: https://github.com/nodejs/node/pull/26483
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2019-03-10 00:44:40 +01:00
Ruben Bridgewater
50dd555910
doc,lib,test: capitalize comment sentences
This activates the eslint capitalize comment rule for comments
above 50 characters.

PR-URL: https://github.com/nodejs/node/pull/24996
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-12-17 17:14:35 +01:00
Anna Henningsen
aa943d098e http: make parser choice a runtime flag
Add a `--http-parser=llhttp` vs `--http-parser=traditional`
command line switch, to make testing and comparing the new
llhttp-based implementation easier.

PR-URL: https://github.com/nodejs/node/pull/24739
Refs: https://github.com/nodejs/node/issues/24730
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
2018-12-06 05:21:36 +01:00
Weijia Wang
d7f17b2a61
http: reduce duplicated code for cleaning parser
PR-URL: https://github.com/nodejs/node/pull/23351
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-10-12 14:53:36 -07:00
Bastian Krol
eb9748d222 async_hooks: add missing async_hooks destroys in AsyncReset
This adds missing async_hooks destroy calls for sockets (in
_http_agent.js) and HTTP parsers. We need to emit a destroy in
AsyncWrap#AsyncReset before assigning a new async_id when the instance
has already been in use and is being recycled, because in that case, we
have already emitted an init for the "old" async_id.

This also removes a duplicated init call for HTTP parser: Each time a
new parser was created, AsyncReset was being called via the C++ Parser
class constructor (super constructor AsyncWrap) and also via
Parser::Reinitialize.

PR-URL: https://github.com/nodejs/node/pull/23272
Fixes: https://github.com/nodejs/node/issues/19859
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-10-10 08:45:56 +02:00
Gus Caplan
e7f710c1d4 bootstrapper: move internalBinding to NativeModule
internalBinding is used so often that it should just automatically be
available for usage in internals.

PR-URL: https://github.com/nodejs/node/pull/23025
Refs: https://github.com/nodejs/node/commit/2a9eb31
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-10-04 11:55:34 +02:00
James M Snell
1744205ff5
http: move process.binding('http_parser') to internalBinding
Refs: https://github.com/nodejs/node/issues/22160

PR-URL: https://github.com/nodejs/node/pull/22329
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-08-18 13:01:21 -07:00
Petras
72624fdd53 http: name anonymous function in _http_common.js
Refs: https://github.com/nodejs/node/issues/8913

PR-URL: https://github.com/nodejs/node/pull/21755
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-07-18 04:50:27 -07:00
Mark S. Everitt
4d91d0164d http: remove a pair of outdated comments
Fixes: https://github.com/nodejs/node/issues/21202

PR-URL: https://github.com/nodejs/node/pull/21214
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-06-10 20:25:43 -07:00
Anatoli Papirovski
54e112dd61
http: remove duplicate parser unset
freeParser already unsets parser property of socket if socket is passed
in specifically. There's no need to do this twice.

PR-URL: https://github.com/nodejs/node/pull/20126
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-04-23 15:59:28 +02:00
Anatoli Papirovski
58e0800b81
http: cleanup parser properties
Cleanup constructor and freeParser to manage all existing parser
properties, not just some.

PR-URL: https://github.com/nodejs/node/pull/20126
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-04-23 15:59:27 +02:00
Anatoli Papirovski
1c84914c5a
http: remove duplicate comment
A comment explaining kOnHeaders function of the parser was duplicated
in two places but the second instance was more confusing than helpful.

PR-URL: https://github.com/nodejs/node/pull/20126
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-04-23 15:59:26 +02:00
Anatoli Papirovski
2e31d5db73
http: cleanup _http_common.js
Remove constant deep property access by storing a reference,
use more const, make some conditionals stricter.

PR-URL: https://github.com/nodejs/node/pull/20126
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-04-23 15:59:26 +02:00
Anatoli Papirovski
95fafc0254
http: fix undefined error in parser event
The current check for socket.server[kIncomingMessage] does not
account for the possibility of a socket.server that doesn't
have that property defined. Fix it.

PR-URL: https://github.com/nodejs/node/pull/20029
Fixes: https://github.com/nodejs/node/issues/19231
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Khaidi Chu <i@2333.moe>
2018-04-17 16:08:31 +02:00
Anatoli Papirovski
f7fbbeedc6 http: relax requirements on upgrade listener
The http spec does not say anything about Upgrade headers making
protocol switch mandatory but Node.js implements them as if they
are. Relax the requirements to only destroy the socket if no
upgrade listener exists on the client when status code is 101.

PR-URL: https://github.com/nodejs/node/pull/19981
Fixes: https://github.com/nodejs/node/issues/11552
Refs: https://tools.ietf.org/html/rfc7230#section-6.7
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-04-16 11:02:23 +02:00
Weijia Wang
254058109f tools: add 'spaced-comment' into eslint rules
PR-URL: https://github.com/nodejs/node/pull/19596
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2018-04-01 22:33:13 +08:00
Seth Brenith
862389b0aa
http: simplify checkInvalidHeaderChar
In the spirit of [17399](https://github.com/nodejs/node/pull/17399),
we can also simplify checkInvalidHeaderChar to use regex matching
instead of a loop. This makes it faster on long matches and slower
on short matches or non-matches. This change also includes some
sample data from an AcmeAir benchmark run, as a rough proxy for
real-world data.

PR-URL: https://github.com/nodejs/node/pull/18381
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benedikt Meurer <benedikt.meurer@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
2018-02-16 19:27:28 +01:00