diff options
author | Peter Marton <email@martonpeter.com> | 2017-10-27 09:18:59 +0200 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-02-06 15:40:25 +0100 |
commit | f6e1466352e00e40da4f4c3e8b14d40752890374 (patch) | |
tree | 63deec76c1574989e6c5d63598bc841e5987882c /lib/internal | |
parent | a899576c977aef32d85074ac09d511e4590e28d7 (diff) | |
download | android-node-v8-f6e1466352e00e40da4f4c3e8b14d40752890374.tar.gz android-node-v8-f6e1466352e00e40da4f4c3e8b14d40752890374.tar.bz2 android-node-v8-f6e1466352e00e40da4f4c3e8b14d40752890374.zip |
http2: add http fallback options to .createServer
This adds the Http1IncomingMessage and Http1ServerReponse options
to http2.createServer().
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>
Diffstat (limited to 'lib/internal')
-rw-r--r-- | lib/internal/http2/core.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index 7702d998fa..f735e2fcc9 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -5,6 +5,7 @@ require('internal/util').assertCrypto(); const { async_id_symbol } = process.binding('async_wrap'); +const http = require('http'); const binding = process.binding('http2'); const assert = require('assert'); const { Buffer } = require('buffer'); @@ -68,6 +69,8 @@ const NETServer = net.Server; const TLSServer = tls.Server; const kInspect = require('internal/util').customInspectSymbol; +const { kIncomingMessage } = require('_http_common'); +const { kServerResponse } = require('_http_server'); const kAlpnProtocol = Symbol('alpnProtocol'); const kAuthority = Symbol('authority'); @@ -2453,8 +2456,11 @@ function connectionListener(socket) { if (socket.alpnProtocol === false || socket.alpnProtocol === 'http/1.1') { // Fallback to HTTP/1.1 - if (options.allowHTTP1 === true) + if (options.allowHTTP1 === true) { + socket.server[kIncomingMessage] = options.Http1IncomingMessage; + socket.server[kServerResponse] = options.Http1ServerResponse; return httpConnectionListener.call(this, socket); + } // Let event handler deal with the socket if (!this.emit('unknownProtocol', socket)) socket.destroy(); @@ -2485,6 +2491,13 @@ function initializeOptions(options) { options.allowHalfOpen = true; assertIsObject(options.settings, 'options.settings'); options.settings = Object.assign({}, options.settings); + + // Used only with allowHTTP1 + options.Http1IncomingMessage = options.Http1IncomingMessage || + http.IncomingMessage; + options.Http1ServerResponse = options.Http1ServerResponse || + http.ServerResponse; + return options; } |