Anatoli Papirovski
3c0ebf5aca
tools: enable additional eslint rules
...
Enable additional rules that node either already adheres to
or it makes sense to do so going forward: for-direction,
accessor-pairs, no-lonely-if and symbol-description.
Fix all instances of no-lonely-if in lib & test and disable
accessor-pairs in test-util-inspect.
PR-URL: https://github.com/nodejs/node/pull/16243
Refs: https://eslint.org/docs/rules/for-direction
Refs: https://eslint.org/docs/rules/accessor-pairs
Refs: https://eslint.org/docs/rules/no-lonely-if
Refs: https://eslint.org/docs/rules/symbol-description
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2017-10-19 13:54:14 -04:00
Anatoli Papirovski
7babce90c9
tools: update to ESLint 4.8.0
...
PR-URL: https://github.com/nodejs/node/pull/16199
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2017-10-19 09:00:34 -04:00
Anatoli Papirovski
10ef56359e
lib: fix extraneous space in module.js
...
An extra space was not caught by the linter due to what appears
to be a bug in eslint 4.3.0 — remove it.
PR-URL: https://github.com/nodejs/node/pull/16199
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2017-10-19 08:59:45 -04:00
Anatoli Papirovski
0a090d324f
doc: add apapirovski to collaborators
...
PR-URL: https://github.com/nodejs/node/pull/16302
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com >
2017-10-18 15:55:40 -04:00
Anatoli Papirovski
2da7d9b820
http2: near full http1 compatibility, add tests
...
Extensive re-work of http1 compatibility layer based on tests in
express, on-finished and finalhandler. Fix handling of HEAD
method to match http1. Adjust write, end, etc. to call writeHead
as in http1 and as expected by user-land modules. Add socket
proxy that instead uses the Http2Stream for the vast majority of
socket interactions. Add and change tests to closer represent
http1 behaviour.
Refs: https://github.com/nodejs/node/pull/15633
Refs: https://github.com/expressjs/express/tree/master/test
Refs: https://github.com/jshttp/on-finished/blob/master/test/test.js
Refs: https://github.com/pillarjs/finalhandler/blob/master/test/test.js
PR-URL: https://github.com/nodejs/node/pull/15702
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2017-10-06 14:04:22 -07:00
Anatoli Papirovski
5723b5dbbc
tls: improve TLSSocket & Server performance
...
Limit the number of closures created and functions called
throughout the lifecycle of TLSSocket, Server & connect.
PR-URL: https://github.com/nodejs/node/pull/15575
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com >
2017-10-01 23:34:48 -03:00
Anatoli Papirovski
ccd3afc843
http2: adjust error emit in core, add tests
...
Use the ability of nextTick and setImmediate to pass arguments
instead of creating closures or binding. Add tests that cover
the vast majority of error emits.
PR-URL: https://github.com/nodejs/node/pull/15586
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2017-10-01 20:14:10 -03:00
Anatoli Papirovski
c705f1067c
http2: fix compat stream read handling, add tests
...
Handle edge case where stream pause is called between resume being
called and actually evaluated. Other minor adjustments to avoid
various edge cases around stream events. Add new tests that cover
all changes.
Fixes: https://github.com/nodejs/node/issues/15491
PR-URL: https://github.com/nodejs/node/pull/15503
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2017-09-25 13:25:35 -07:00
Anatoli Papirovski
d8a226673b
test: expand http2 util test coverage for headers
...
Expand existing test cases to hit some additional branches of
toHeaderObject and mapToHeaders.
PR-URL: https://github.com/nodejs/node/pull/15493
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2017-09-24 14:10:44 -03:00
Anatoli Papirovski
33760ccc18
http2: remove unused onTimeout, add timeout tests
...
Remove unused onTimeout on Http2Session and Http2Stream because
the correct _onTimeout is already declared and in use. Expand
timeout tests to handle edge cases and additional arguments.
PR-URL: https://github.com/nodejs/node/pull/15539
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2017-09-24 12:57:35 -03:00
Anatoli Papirovski
bc23681aa2
http2: small fixes to compatibility layer
...
Expand argument validation through compat API, adjust behaviour
of response.end to not throw if stream already closed to match
http1, adjust behaviour of writeContinue to not throw if stream
already closed and other very small tweaks. Add tests for added
and fixed behaviour. Add tests for edge case behaviours of
setTimeout, createPushResponse, destroy, end and trailers.
PR-URL: https://github.com/nodejs/node/pull/15473
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com >
2017-09-21 09:21:53 +02:00
Anatoli Papirovski
15879adf1d
test: expand http2 frameError test case
...
Expand maxSendHeaderBlockLength test to check what happens if
frameError listener isn't available.
PR-URL: https://github.com/nodejs/node/pull/15298
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Refael Ackermann <refack@gmail.com >
2017-09-20 09:05:28 -03:00
Anatoli Papirovski
2f5bef4705
http2: expand list of known headers
...
Add access-control-*, dnt, forwarded, trailer, tk,
upgrade-insecure-requests, warning, x-content-type-options and
x-frame-options to known list of headers for HTTP2. Expand tests
to account for these headers.
Fixes: https://github.com/nodejs/node/issues/15337
Refs: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
Refs: https://www.w3.org/TR/cors/#syntax
Refs: https://www.w3.org/2011/tracking-protection/drafts/tracking-dnt.html#dnt-header-field
Refs: https://tools.ietf.org/html/rfc7239#section-4
Refs: https://tools.ietf.org/html/rfc7230#section-4.4
Refs: https://www.w3.org/2011/tracking-protection/drafts/tracking-dnt.html#response-header-field
Refs: https://www.w3.org/TR/upgrade-insecure-requests/#preference
Refs: https://tools.ietf.org/html/rfc7234#section-5.5
Refs: https://fetch.spec.whatwg.org/#x-content-type-options-header
Refs: https://tools.ietf.org/html/rfc7034
PR-URL: https://github.com/nodejs/node/pull/15434
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2017-09-20 01:23:11 -07:00
Anatoli Papirovski
8fa5fcc0ba
http2: emit close event if request aborted
...
Fix Http2ServerRequest and Http2ServerResponse to emit close event
if the request is aborted before response.end can be called.
Fixes: https://github.com/nodejs/node/issues/15385
PR-URL: https://github.com/nodejs/node/pull/15415
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2017-09-18 16:22:09 +02:00
Anatoli Papirovski
de51717c3e
test: fix flaky test-http2-session-timeout
...
Increase server timeout, reduce frequency of calls and
unbind timeout after runs are done in order to avoid
race conditions. Temporarily moved to sequential.
Fixes: https://github.com/nodejs/node/issues/15326
PR-URL: https://github.com/nodejs/node/pull/15338
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2017-09-18 15:19:46 +02:00
Anatoli Papirovski
a4e923f5c1
http2: fix subsequent end calls to not throw
...
Calling Http2ServerResponse.end multiple times should never
cause the code to throw an error, subsequent calls should
instead return false. Fix behaviour to match http1.
Fixes: https://github.com/nodejs/node/issues/15385
PR-URL: https://github.com/nodejs/node/pull/15414
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2017-09-18 12:28:24 +02:00
Anatoli Papirovski
1aca135cb9
http2: add tests for push stream error handling
...
Add tests that cover errors for wrong arguments, as well as
tests for error codes from nghttp2. Fix pushStream to emit
NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE on session rather than
stream.
PR-URL: https://github.com/nodejs/node/pull/15281
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2017-09-13 18:14:03 +02:00
Anatoli Papirovski
c981483686
http2: cleanup of h2 compat layer, add tests
...
Remove unnecessary variable assignments, remove unreachable code
pathways, remove path getter and setter, and other very minor
cleanup. Only remove reference to stream on nextTick so that
users and libraries can access it in the finish event.
Fixes: https://github.com/nodejs/node/issues/15313
Refs: https://github.com/expressjs/express/pull/3390
PR-URL: https://github.com/nodejs/node/pull/15254
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2017-09-12 16:13:23 +02:00
Anatoli Papirovski
fc1fa4e2c4
buffer: improve Buffer.from performance
...
Using == null in code paths that are expected to mostly receive
objects, arrays or other more complex data types is not
ideal because typecasting these types is very slow. Change
to instead check === null || === undefined. Also move one
variable assignment in fromString after an if condition
that doesn't need it (and returns if truthy).
PR-URL: https://github.com/nodejs/node/pull/15178
Refs: https://jsperf.com/triple-equals-vs-double-equals/3
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Timothy Gu <timothygu99@gmail.com >
2017-09-11 00:05:28 -03:00
Anatoli Papirovski
45357d0556
http2: fix refs to status 205, add tests
...
Fix references within http2 core to HTTP_STATUS_CONTENT_RESET to point
to the correct HTTP_STATUS_RESET_CONTENT. Add tests for status 204,
205 & 304 in respond, respondWithFD & respondWithFile. Add general
error tests for respondWithFD & respondWithFile.
PR-URL: https://github.com/nodejs/node/pull/15153
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Claudio Rodriguez <cjrodr@yahoo.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2017-09-10 23:50:51 -03:00
Anatoli Papirovski
c20901a7f5
http2: correct behaviour for enablePush unpack
...
The only valid values for enablePush are 0 and 1. If validation
is requested, we should verify that it wasn't set to another
value rather than casting to Boolean regardless of value.
PR-URL: https://github.com/nodejs/node/pull/15167
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2017-09-10 23:49:45 -03:00
Anatoli Papirovski
78fc726203
http2: store headersSent after stream destroyed
...
Store headersSent directly on response state after finish event
is triggered, so that users can always access it.
PR-URL: https://github.com/nodejs/node/pull/15232
Fixes: https://github.com/nodejs/node/issues/15226
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2017-09-10 23:47:48 -03:00
Anatoli Papirovski
2ffc8ac301
http2: set decodeStrings to false, test
...
Set writableStream decodeStrings to false to let the
native layer handle converting strings to buffer.
PR-URL: https://github.com/nodejs/node/pull/15140
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Claudio Rodriguez <cjrodr@yahoo.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2017-09-07 16:05:37 -07:00
Anatoli Papirovski
91dc50726b
test: add http2 compat setTimeout tests
...
Add tests for Http2ServerRequest and Http2ServerResponse setTimeout
PR-URL: https://github.com/nodejs/node/pull/15156
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2017-09-07 15:56:12 -07:00
Anatoli Papirovski
46133b5beb
http2: use session not socket timeout, tests
...
Change default timeout to be tracked on the session instead
of the socket, as nghttp2 manages the socket and we would
need to maintain two sets of timeouts for similar purpose.
Also fixes session setTimeout to work as it wasn't getting
_unrefActive correctly (was called on the handle).
Fixes: https://github.com/nodejs/node/issues/15158
PR-URL: https://github.com/nodejs/node/pull/15188
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2017-09-07 20:37:21 +02:00
Anatoli Papirovski
641646463d
http2: add compat trailers, adjust multi-headers
...
Adds Http2ServerRequest trailers & rawTrailers functionality. Also fixes
behaviour of multi-headers to conform with the spec (all values but
set-cookie and cookie should be comma delimited, cookie should be
semi-colon delimited and only set-cookie should be an array). Adds
setter for statusMessage that warns, for backwards compatibility.
End readable side of the stream on trailers or bodyless requests
Refs: https://github.com/expressjs/express/pull/3390#discussion_r136718729
PR-URL: https://github.com/nodejs/node/pull/15193
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2017-09-07 18:43:55 +02:00
Anatoli Papirovski
800c32d315
http2: fix closedCode NaN, increase test coverage
...
[kFinish](code) can be triggered from a 'finish' event (for example
when calling response.end) which does not pass code. That tries to
set closedCode to undefined resulting in NaN closedCode instead of
NGHTTP2_NO_ERROR. Check for code !== undefined before setting.
Adds tests for closed and closedCode.
PR-URL: https://github.com/nodejs/node/pull/15154
Reviewed-By: Timothy Gu <timothygu99@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2017-09-06 22:56:38 -07:00
Anatoli Papirovski
8d5b0130da
http2: correct emit error in onConnect, full tests
...
Correct requestOnConnect to emit session error on
NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE rather than stream error. Add full
test suite for the error handling within requestOnConnect.
PR-URL: https://github.com/nodejs/node/pull/15080
Refs: https://github.com/nodejs/node/issues/14985
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2017-09-03 20:32:56 -03:00
Anatoli Papirovski
e289540e12
http2: adjust error types, test coverage
...
Change error types emitted from request and validatePriorityOptions
to be TypeError rather than the incorrect RangeError. Add tests
to confirm that all errors are thrown as expected (weight, parent,
exclusive, silent, endStream and getTrailers). Add test for method
CONNECT throwing error on missing :authority or superfluous :scheme
and :path.
PR-URL: https://github.com/nodejs/node/pull/15109
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2017-09-03 20:31:11 -03:00
Anatoli Papirovski
198fcb9c62
test: increase Http2ServerResponse test coverage
...
Modify existing header tests for Http2ServerResponse to include
sendDate (get and set) and headersSent. Expand existing test
for end to include a check for closed. Add a new test for destroy.
PR-URL: https://github.com/nodejs/node/pull/15074
Refs: https://github.com/nodejs/node/issues/14985
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2017-09-03 20:18:49 -03:00
Anatoli Papirovski
365c24591c
util: remove duplicate code in format
...
util.format contains an idential if statement within each branch
of switch. Move it before the switch statement for cleaner code
and better performance.
PR-URL: https://github.com/nodejs/node/pull/15098
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Evan Lucas <evanlucas@me.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2017-08-30 18:52:28 -03:00
Anatoli Papirovski
ad3d2ce68a
http2: handle 100-continue flow & writeContinue
...
Adds an implementation for writeContinue based on the h2 spec & the
existing http implementation. ClientHttp2Stream now also emits
a continue event when it receives headers with :status 100.
Includes two test cases for default server continue behaviour and
for the exposed checkContinue listener.
PR-URL: https://github.com/nodejs/node/pull/15039
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2017-08-30 12:00:49 -07:00
Anatoli Papirovski
6eeb06f234
test: add a test for Expect & checkExpectation
...
New test case for Expect header & checkExpectation event based on the
existing http test case.
PR-URL: https://github.com/nodejs/node/pull/15040
Refs: https://github.com/nodejs/node/issues/14985
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2017-08-30 15:39:18 -03:00
Anatoli Papirovski
88441f6baf
test: add http2 test for method CONNECT
...
Adds test case for default handling of method CONNECT, as well
as the ability to bind a connect listener and handle the request.
PR-URL: https://github.com/nodejs/node/pull/15052
Refs: https://github.com/nodejs/node/issues/14985
Reviewed-By: James M Snell <jasnell@gmail.com >
2017-08-30 15:36:10 -03:00
Anatoli Papirovski
3eb029794c
test: increase coverage for http2 response headers
...
Expanded an existing test for setting pseudo-headers on response to
include all pseudo-headers, not just :status.
PR-URL: https://github.com/nodejs/node/pull/15035
Refs: https://github.com/nodejs/node/issues/14985
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com >
Reviewed-By: Timothy Gu <timothygu99@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2017-08-29 15:51:00 -03:00