0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 07:27:22 +01:00
Commit Graph

100 Commits

Author SHA1 Message Date
Robert Nagy
f22c7c10ca http: always emit close on req and res
PR-URL: https://github.com/nodejs/node/pull/20611
Fixes: https://github.com/nodejs/node/issues/20600
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-05-13 16:23:50 -07:00
Robert Nagy
d5e363b77e
http: added aborted property to request
PR-URL: https://github.com/nodejs/node/pull/20094
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2018-04-26 19:38:27 +02: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
3d480dcf4c
http: fix _dump regression
A recent set of changes removed _consuming tracking from server
incoming messages which ensures that _dump only runs if the
user has never attempted to read the incoming data. Fix by
reintroducing _consuming which tracks whether _read was ever
successfully called.

PR-URL: https://github.com/nodejs/node/pull/20088
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-04-19 08:41:17 +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
Matteo Collina
1f29963eac test,http: fix http dump test
Make sure the dump test actually verify what is happening and it is
not flaky.

See: https://github.com/nodejs/node/issues/19139
PR-URL: https://github.com/nodejs/node/pull/19823
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-04-07 10:03:22 +02:00
Michaël Zasso
1d2fd8b65b lib: port remaining errors to new system
PR-URL: https://github.com/nodejs/node/pull/19137
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-03-07 14:54:38 +01:00
Glen Keane
30fd3d25df src: Remove lttng support.
This cleans up and removes lttng support completely. Recent discussion
on a PR to deprecate lttng suggested that we remove it completely
pending feedback from the TSC.

This should be considered a non breaking change, as a recent PR reveals
that compiling with this system has been broken for nearly two years.

Refs: https://github.com/nodejs/node/issues/18971
Refs: https://github.com/nodejs/node/pull/18975
Refs: https://github.com/nodejs/node/pull/18945

PR-URL: https://github.com/nodejs/node/pull/18982
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jackson Tian <shyvo1987@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-01 16:44:43 +00:00
Luigi Pinca
51be03cd57
http: remove default 'error' listener on upgrade
Remove the default `'error'` listener when the socket is freed. This
is consistent with the client and prevents spurious `'clientError'`
events from being emitted on the server.

PR-URL: https://github.com/nodejs/node/pull/18868
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-02-22 14:58:47 +00:00
Miles Elam
baf8495078 http: process 100, 102-199 according to specs.
Adding ServerResponse.writeProcessing to send 102 status codes.

Added an `'information'` event to ClientRequest to handle
1xx status codes except 101 Upgrade.
101 Upgrade is excluded due to its non-informational
processing according to RFC7231, Section 6.2.2.

This affects several modules downstream that use the http
module, e.g., node-fetch, all of whom violate HTTP RFCs
due to this module. As such, this could introduce a
breaking change for downstream if HTTP standards were
ignored in an ad-hoc fashion.

See also RFC2518 RFC8297.

PR-URL: https://github.com/nodejs/node/pull/18033
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
2018-02-15 11:57:57 +01:00
Peter Marton
a899576c97
http: add options to http.createServer()
This adds the optional options argument to `http.createServer()`.
It contains two options: the `IncomingMessage` and `ServerReponse`
option.

PR-URL: https://github.com/nodejs/node/pull/15752
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
2018-02-06 15:40:24 +01:00
Anna Henningsen
7c4b09b24b
src: refactor stream callbacks and ownership
Instead of setting individual callbacks on streams and tracking
stream ownership through a boolean `consume_` flag, always have
one specific listener object in charge of a stream, and call
methods on that object rather than generic C-style callbacks.

PR-URL: https://github.com/nodejs/node/pull/18334
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-02-01 10:53:26 +01:00
Ben Noordhuis
de4600ea2b
http: fix parsing of binary upgrade response body
Fix a bug where a connection upgrade response with a Transfer-Encoding
header and a body whose first byte is > 127 causes said byte to be
dropped on the floor when passing the remainder of the message to
the 'upgrade' event listeners.

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

PR-URL: https://github.com/nodejs/node/pull/17806
Fixes: https://github.com/nodejs/node/issues/17789
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-01-21 01:50:56 +01:00
Andreas Madsen
8479606a24
async_hooks,http: set HTTPParser trigger to socket
This allows more easy tracking of where HTTP requests come from. Before
this change the HTTPParser would have the HTTPServer as the
triggerAsyncId.

The HTTPParser will still have the executionAsyncId set to the HTTP
Server so that information is still directly available. Indirectly, the
TCP socket itself also has its triggerAsyncId set to the TCP Server.

PR-URL: https://github.com/nodejs/node/pull/18003
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
2018-01-12 08:54:36 +01:00
XadillaX
6c0da34905
http: add rawPacket in err of clientError event
The `rawPacket` is the current buffer that just parsed. Adding this
buffer to the error object of `clientError` event is to make it possible
that developers can log the broken packet.

PR-URL: https://github.com/nodejs/node/pull/17672
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-12-27 19:42:57 +01:00
Calvin Metcalf
e20af3371b stream: add flow and buffer properties to streams
This adds computed properties to readable and writable streams to
allow access to the readable buffer, the writable buffer, and flow
state without accessing the readable or writable state.

These are the only uses of readable and writable state in the docs
so adding these work arounds allows them to be removed from the docs.

This also updates net, http_client and http_server to use the new
methods instead of manipulating readable and writable state directly.

See: https://github.com/nodejs/node/issues/445
PR-URL: https://github.com/nodejs/node/pull/12855
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-12-15 23:05:45 +01:00
Ben Noordhuis
31addac8bb
http: remove adapter frame from onParserExecute
Remove a pointless adapter frame  by fixing up the function's formal
parameter count.  Before:

    frame #0: 0x000033257ea446d5 onParserExecute(...)
    frame #1: 0x000033257ea3b93f <adaptor>
    frame #2: 0x000033257ea41959 <internal>
    frame #3: 0x000033257e9840ff <entry>

After:

    frame #0: 0x00000956287446d5 onParserExecute(...)
    frame #1: 0x0000095628741959 <internal>
    frame #2: 0x00000956286840ff <entry>

PR-URL: https://github.com/nodejs/node/pull/17693
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
2017-12-15 19:49:25 -02:00
Matteo Collina
3eb5778d1b http, stream: writeHWM -> writableHighWaterMark
See: https://github.com/nodejs/node/pull/12860#pullrequestreview-76800871

PR-URL: https://github.com/nodejs/node/pull/17050
Reviewed-By: Calvin Metcalf <calvin.metcalf@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-11-15 19:12:08 +01:00
Calvin Metcalf
157df5a47c stream: remove usage of *State.highWaterMark
Replaced _readableState.highWaterMark with a .readableHighWaterMark
getter and _writableState.highWaterMark with a .writableHighWaterMark
getter.
The getters are non-enumerable because they break some prototype
manipulation that happen in the ecosystem.

Ref: https://github.com/nodejs/node/issues/445.

PR-URL: https://github.com/nodejs/node/pull/12860
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2017-11-15 14:30:39 +01:00
Jayashree S Kumar
cb87c92694 lib: replace string concatenation with template
PR-URL: https://github.com/nodejs/node/pull/16921
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
2017-11-11 11:09:29 +01:00
Yosuke Furukawa
7eb5ee3ca8
http, http2: add 103 Early Hints status code
PR-URL: https://github.com/nodejs/node/pull/16644
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-11-04 11:13:52 -04:00
Anna Henningsen
3e25e4d00f
http: support generic Duplex streams
Support generic `Duplex` streams through more duck typing
on the server and client sides.

Since HTTP is, as a protocol, independent of its underlying transport
layer, Node.js should not enforce any restrictions on what streams
its HTTP parser may use.

Ref: https://github.com/nodejs/node/issues/16256
PR-URL: https://github.com/nodejs/node/pull/16267
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
2017-10-23 17:11:57 +02:00
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
mog422
f2f391e575
http: send 400 bad request on parse error
A web server such as nginx assumes that upstream is dead
if upstream closes the socket without any response.

PR-URL: https://github.com/nodejs/node/pull/15324
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2017-10-19 18:15:58 +02:00
Weijia Wang
212de3c5ec
lib: use destructuring for some constants
This change is to unify the declaration for constants into using
destructuring on the top-level-module scope, reducing some redundant
code.

PR-URL: https://github.com/nodejs/node/pull/16063
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
2017-10-16 23:34:32 +02:00
Weijia Wang
11a2ca29ba
errors: migrate _http_outgoing
PR-URL: https://github.com/nodejs/node/pull/14735
Refs: https://github.com/nodejs/node/issues/11273
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2017-08-14 17:19:19 -04:00
Rich Trott
a577bde917 lib: fix off-by-one indentation
In preparation for more robust indentation linting, fix an off-by-one
indentation in lib/http_server.js.

PR-URL: https://github.com/nodejs/node/pull/14064
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2017-07-04 06:49:05 -07:00
Ruben Bridgewater
2fa2a60721 http: simplify if statement
PR-URL: https://github.com/nodejs/node/pull/13857
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2017-06-28 20:00:47 +02:00
Ruben Bridgewater
1698c8e165 errors: fix and improve error types
1) Add missing lazy assert call
2) Remove obsolete error type
3) Name undocumented error type more appropriate
4) Consolidate error type style (rely on util.format
   instead of using a function)
5) Uppercase the first letter from error messages
6) Improve some internal error parameters

PR-URL: https://github.com/nodejs/node/pull/13857
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2017-06-28 20:00:25 +02:00
Rich Trott
095c0de94d benchmark,lib,test: use braces for multiline block
For if/else and loops where the bodies span more than one line, use
curly braces.

PR-URL: https://github.com/nodejs/node/pull/13828
Ref: https://github.com/nodejs/node/pull/13623#discussion_r123048602
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-06-23 14:43:20 -07:00
Alexey Orlenko
d71718db6a
http: fix timeout reset after keep-alive timeout
Fix the logic of resetting the socket timeout of keep-alive HTTP
connections and add two tests:

* `test-http-server-keep-alive-timeout-slow-server` is a regression test
  for GH-13391.  It ensures that the server-side keep-alive timeout will
  not fire during processing of a request.

* `test-http-server-keep-alive-timeout-slow-client-headers` ensures that
  the regular socket timeout is restored as soon as a client starts
  sending a new request, not as soon as the whole message is received,
  so that the keep-alive timeout will not fire while, e.g., the client
  is sending large cookies.

Refs: https://github.com/nodejs/node/pull/2534
Fixes: https://github.com/nodejs/node/issues/13391
PR-URL: https://github.com/nodejs/node/pull/13549
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
2017-06-13 07:42:11 +03:00
Luigi Pinca
ba449f3bf1
http: handle cases where socket.server is null
Fixes a regression that caused an error to be thrown when trying to
emit the 'timeout' event on the server referenced by `socket.server`.

Fixes: https://github.com/nodejs/node/issues/13435
Refs: https://github.com/nodejs/node/pull/11926
PR-URL: https://github.com/nodejs/node/pull/13578
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-06-12 14:10:13 +02:00
Bidisha Pyne
a9f798ebcc errors,http_server: migrate to use internal/errors.js
PR-URL: https://github.com/nodejs/node/pull/13301
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-06-01 20:09:30 -07:00
Sam Roberts
3fba3d6409 http: describe parse err in debug output
PR-URL: https://github.com/nodejs/node/pull/13206
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
2017-06-01 16:41:29 -07:00
Timur Shemsedinov
0aa7ef5950
http: destroy sockets after keepAliveTimeout
Implement server.keepAliveTimeout in addition to server.timeout to
prevent temporary socket/memory leaking in keep-alive mode.

PR-URL: https://github.com/nodejs/node/pull/2534
Author: Timur Shemsedinov <timur.shemsedinov@gmail.com>
Author: Alexey Orlenko <eaglexrlnk@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2017-05-26 19:05:53 +03:00
Luigi Pinca
e0a9ad1af2 http: avoid retaining unneeded memory
Prevent the events listeners of the sockets obtained with the HTTP
upgrade mechanism from retaining unneeded memory.

Ref: https://github.com/nodejs/node/issues/11868
PR-URL: https://github.com/nodejs/node/pull/11926
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2017-03-22 10:26:02 -07:00
Rich Trott
cce520a5de tools: ignore URLs in line length linting
Where inclusion of a lengthy URL causes a line to exceed 80 characters
in our code base, do not report the line length as a linting error.

PR-URL: https://github.com/nodejs/node/pull/11890
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2017-03-20 18:28:40 -07:00
James M Snell
5425e0dcbe http: use more efficient module.exports pattern
PR-URL: https://github.com/nodejs/node/pull/11594
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2017-03-20 16:01:31 -07:00
James M Snell
98e54b0bd4 meta: restore original copyright header
A prior io.js era commit inappropriately removed the
original copyright statements from the source. This
restores those in any files still remaining from that
edit.

Ref: https://github.com/nodejs/TSC/issues/174
Ref: https://github.com/nodejs/node/pull/10599
PR-URL: https://github.com/nodejs/node/pull/10155

Note: This PR was required, reviewed-by and approved
by the Node.js Foundation Legal Committee and the TSC.
There is no `Approved-By:` meta data.
2017-03-10 11:23:48 -08:00
Brian White
940b5303be
http: use Symbol for outgoing headers
PR-URL: https://github.com/nodejs/node/pull/10941
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2017-03-09 05:50:22 -05:00
James M Snell
fb71ba4921 http: docs-only deprecation of res.writeHeader()
Doc-only deprecation of the undocumented res.writeHeader() API.
Also makes res.writeHeader an alias of res.writeHead since the
previous implementation simply deferred to that method.

PR-URL: https://github.com/nodejs/node/pull/11355
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2017-02-24 18:05:52 -08:00
cjihrig
a4bb9fdb89 http: include provided status code in range error
ServerResponse#writeHead() coerces the user provided status code
to a number and then performs a range check. If the check fails,
a range error is thrown. The coerced status code is included in
the error message. This commit uses the user provided status code
instead.

PR-URL: https://github.com/nodejs/node/pull/11221
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-02-09 12:38:06 -05:00
Roee Kasher
3e3bfc57d9 src: unconsume stream fix in internal http impl
When emitting a 'connection' event on a httpServer, the function
connectionListener is called. Then, a new parser is created, and
'consume' method is called on the socket's externalStream. However,
if this stream was already consumed and unconsumed, the process
crashes with a cpp assert from the 'Consume' method in stream_base.h.
This commit makes sure that no SIGABRT will be raised and the process
will stay alive (after emitting the socket).

PR-URL: https://github.com/nodejs/node/pull/11015
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-02-02 12:01:13 -08:00
Brian White
176cdc2823
http: misc optimizations and style fixes
PR-URL: https://github.com/nodejs/node/pull/10558
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
2017-01-11 12:54:45 -05:00
Brian White
c00e4adbb4
http: optimize header storage and matching
This commit implements two optimizations when working with headers:

* Avoid having to explicitly "render" headers and separately store the
original casing for header names.

* Match special header names using a single regular expression instead
of testing one regular expression per header name.

PR-URL: https://github.com/nodejs/node/pull/10558
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
2017-01-11 12:54:31 -05:00
Brian White
ec8910bcea
http: check statusCode early
By enforcing the statusCode to be an SMI, it helps a bit
performance-wise when looking up the associated statusMessage.

PR-URL: https://github.com/nodejs/node/pull/10558
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
2017-01-11 12:54:26 -05:00
vitkarpov
a2ea1344ea
http: define all used properties in constructors
Adding all used properties in the constructor makes the hidden class
stable and heap snapshots more verbose.

Refs: https://github.com/nodejs/node/issues/8912
PR-URL: https://github.com/nodejs/node/pull/9116
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2017-01-10 01:33:52 -05:00
Brian White
832271c88f
http: refactor server connection handling
PR-URL: https://github.com/nodejs/node/pull/6533
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2016-12-29 14:18:57 -05:00
Brian White
14c76f8671
http: misc cleanup and minor optimizations
PR-URL: https://github.com/nodejs/node/pull/6533
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2016-12-29 14:18:53 -05:00