diff options
author | Anna Henningsen <anna@addaleax.net> | 2017-10-17 22:19:27 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2017-10-23 17:11:57 +0200 |
commit | 3e25e4d00f382641af1c78a28b02296bef686c1e (patch) | |
tree | 8db28c0265694d200e1564b215d05a9126e20060 /doc/api | |
parent | ab16eec4369f60f14014933886f84a926488f368 (diff) | |
download | node-new-3e25e4d00f382641af1c78a28b02296bef686c1e.tar.gz |
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>
Diffstat (limited to 'doc/api')
-rw-r--r-- | doc/api/http.md | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/doc/api/http.md b/doc/api/http.md index e4300cc429..4a84e50ba0 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -797,11 +797,14 @@ added: v0.1.0 * `socket` {net.Socket} -When a new TCP stream is established. `socket` is an object of type -[`net.Socket`][]. Usually users will not want to access this event. In -particular, the socket will not emit `'readable'` events because of how -the protocol parser attaches to the socket. The `socket` can also be -accessed at `request.connection`. +This event is emitted when a new TCP stream is established. `socket` is +typically an object of type [`net.Socket`][]. Usually users will not want to +access this event. In particular, the socket will not emit `'readable'` events +because of how the protocol parser attaches to the socket. The `socket` can +also be accessed at `request.connection`. + +*Note*: This event can also be explicitly emitted by users to inject connections +into the HTTP server. In that case, any [`Duplex`][] stream can be passed. ### Event: 'request' <!-- YAML @@ -1769,7 +1772,7 @@ changes: use for the request when the `agent` option is not used. This can be used to avoid creating a custom `Agent` class just to override the default `createConnection` function. See [`agent.createConnection()`][] for more - details. + details. Any [`Duplex`][] stream is a valid return value. * `timeout` {number}: A number specifying the socket timeout in milliseconds. This will set the timeout before the socket is connected. * `callback` {Function} @@ -1869,6 +1872,7 @@ const req = http.request(options, (res) => { [`'request'`]: #http_event_request [`'response'`]: #http_event_response [`Agent`]: #http_class_http_agent +[`Duplex`]: stream.html#stream_class_stream_duplex [`EventEmitter`]: events.html#events_class_eventemitter [`TypeError`]: errors.html#errors_class_typeerror [`URL`]: url.html#url_the_whatwg_url_api |