| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f14ff14 commit b0a79b1
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4415,6 +4415,42 @@ Passing the `type` option to [`Duplex.toWeb()`][] is deprecated. To specify the | |||
| 4415 | 4415 | type of the readable half of the constructed readable-writable pair, use the | |
| 4416 | 4416 | `readableType` option instead. | |
| 4417 | 4417 | ||
| 4418 | + ### DEP0202: `Http1IncomingMessage` and `Http1ServerResponse` options of HTTP/2 servers | ||
| 4419 | + | ||
| 4420 | + <!-- YAML | ||
| 4421 | + changes: | ||
| 4422 | + - version: REPLACEME | ||
| 4423 | + pr-url: https://github.com/nodejs/node/pull/61713 | ||
| 4424 | + description: Documentation-only deprecation. | ||
| 4425 | + --> | ||
| 4426 | + | ||
| 4427 | + Type: Documentation-only | ||
| 4428 | + | ||
| 4429 | + The `Http1IncomingMessage` and `Http1ServerResponse` options of | ||
| 4430 | + [`http2.createServer()`][] and [`http2.createSecureServer()`][] are | ||
| 4431 | + deprecated. Use `http1Options.IncomingMessage` and | ||
| 4432 | + `http1Options.ServerResponse` instead. | ||
| 4433 | + | ||
| 4434 | + ```cjs | ||
| 4435 | + // Deprecated | ||
| 4436 | + const server = http2.createSecureServer({ | ||
| 4437 | + allowHTTP1: true, | ||
| 4438 | + Http1IncomingMessage: MyIncomingMessage, | ||
| 4439 | + Http1ServerResponse: MyServerResponse, | ||
| 4440 | + }); | ||
| 4441 | + ``` | ||
| 4442 | + | ||
| 4443 | + ```cjs | ||
| 4444 | + // Use this instead | ||
| 4445 | + const server = http2.createSecureServer({ | ||
| 4446 | + allowHTTP1: true, | ||
| 4447 | + http1Options: { | ||
| 4448 | + IncomingMessage: MyIncomingMessage, | ||
| 4449 | + ServerResponse: MyServerResponse, | ||
| 4450 | + }, | ||
| 4451 | + }); | ||
| 4452 | + ``` | ||
| 4453 | + | ||
| 4418 | 4454 | [DEP0142]: #dep0142-repl_builtinlibs | |
| 4419 | 4455 | [NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf | |
| 4420 | 4456 | [RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3 | |
@@ -4494,6 +4530,8 @@ type of the readable half of the constructed readable-writable pair, use the | |||
| 4494 | 4530 | [`http.ServerResponse`]: http.md#class-httpserverresponse | |
| 4495 | 4531 | [`http.get()`]: http.md#httpgetoptions-callback | |
| 4496 | 4532 | [`http.request()`]: http.md#httprequestoptions-callback | |
| 4533 | + [`http2.createSecureServer()`]: http2.md#http2createsecureserveroptions-onrequesthandler | ||
| 4534 | + [`http2.createServer()`]: http2.md#http2createserveroptions-onrequesthandler | ||
| 4497 | 4535 | [`https.get()`]: https.md#httpsgetoptions-callback | |
| 4498 | 4536 | [`https.request()`]: https.md#httpsrequestoptions-callback | |
| 4499 | 4537 | [`message.connection`]: http.md#messageconnection | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2793,6 +2793,10 @@ Throws `ERR_INVALID_ARG_TYPE` for invalid `settings` argument. | |||
| 2793 | 2793 | <!-- YAML | |
| 2794 | 2794 | added: v8.4.0 | |
| 2795 | 2795 | changes: | |
| 2796 | + - version: REPLACEME | ||
| 2797 | + pr-url: https://github.com/nodejs/node/pull/61713 | ||
| 2798 | + description: Added `http1Options` option. The `Http1IncomingMessage` | ||
| 2799 | + and `Http1ServerResponse` options are now deprecated. | ||
| 2796 | 2800 | - version: | |
| 2797 | 2801 | - v23.0.0 | |
| 2798 | 2802 | - v22.10.0 | |
@@ -2911,9 +2915,27 @@ changes: | |||
| 2911 | 2915 | * `Http1IncomingMessage` {http.IncomingMessage} Specifies the | |
| 2912 | 2916 | `IncomingMessage` class to used for HTTP/1 fallback. Useful for extending | |
| 2913 | 2917 | the original `http.IncomingMessage`. **Default:** `http.IncomingMessage`. | |
| 2918 | + **Deprecated.** Use `http1Options.IncomingMessage` instead. See | ||
| 2919 | + [DEP0202][]. | ||
| 2914 | 2920 | * `Http1ServerResponse` {http.ServerResponse} Specifies the `ServerResponse` | |
| 2915 | 2921 | class to used for HTTP/1 fallback. Useful for extending the original | |
| 2916 | 2922 | `http.ServerResponse`. **Default:** `http.ServerResponse`. | |
| 2923 | + **Deprecated.** Use `http1Options.ServerResponse` instead. See | ||
| 2924 | + [DEP0202][]. | ||
| 2925 | + * `http1Options` {Object} An options object for configuring the HTTP/1 | ||
| 2926 | + fallback when `allowHTTP1` is `true`. These options are passed to the | ||
| 2927 | + underlying HTTP/1 server. See [`http.createServer()`][] for available | ||
| 2928 | + options. Among others, the following are supported: | ||
| 2929 | + * `IncomingMessage` {http.IncomingMessage} Specifies the | ||
| 2930 | + `IncomingMessage` class to use for HTTP/1 fallback. | ||
| 2931 | + **Default:** `http.IncomingMessage`. | ||
| 2932 | + * `ServerResponse` {http.ServerResponse} Specifies the `ServerResponse` | ||
| 2933 | + class to use for HTTP/1 fallback. | ||
| 2934 | + **Default:** `http.ServerResponse`. | ||
| 2935 | + * `keepAliveTimeout` {number} The number of milliseconds of inactivity | ||
| 2936 | + a server needs to wait for additional incoming data, after it has | ||
| 2937 | + finished writing the last response, before a socket will be destroyed. | ||
| 2938 | + **Default:** `5000`. | ||
| 2917 | 2939 | * `Http2ServerRequest` {http2.Http2ServerRequest} Specifies the | |
| 2918 | 2940 | `Http2ServerRequest` class to use. | |
| 2919 | 2941 | Useful for extending the original `Http2ServerRequest`. | |
@@ -2987,6 +3009,9 @@ server.listen(8000); | |||
| 2987 | 3009 | <!-- YAML | |
| 2988 | 3010 | added: v8.4.0 | |
| 2989 | 3011 | changes: | |
| 3012 | + - version: REPLACEME | ||
| 3013 | + pr-url: https://github.com/nodejs/node/pull/61713 | ||
| 3014 | + description: Added `http1Options` option. | ||
| 2990 | 3015 | - version: | |
| 2991 | 3016 | - v15.10.0 | |
| 2992 | 3017 | - v14.16.0 | |
@@ -3105,6 +3130,20 @@ changes: | |||
| 3105 | 3130 | and trailing whitespace validation for HTTP/2 header field names and values | |
| 3106 | 3131 | as per [RFC-9113](https://www.rfc-editor.org/rfc/rfc9113.html#section-8.2.1). | |
| 3107 | 3132 | **Default:** `true`. | |
| 3133 | + * `http1Options` {Object} An options object for configuring the HTTP/1 | ||
| 3134 | + fallback when `allowHTTP1` is `true`. These options are passed to the | ||
| 3135 | + underlying HTTP/1 server. See [`http.createServer()`][] for available | ||
| 3136 | + options. Among others, the following are supported: | ||
| 3137 | + * `IncomingMessage` {http.IncomingMessage} Specifies the | ||
| 3138 | + `IncomingMessage` class to use for HTTP/1 fallback. | ||
| 3139 | + **Default:** `http.IncomingMessage`. | ||
| 3140 | + * `ServerResponse` {http.ServerResponse} Specifies the `ServerResponse` | ||
| 3141 | + class to use for HTTP/1 fallback. | ||
| 3142 | + **Default:** `http.ServerResponse`. | ||
| 3143 | + * `keepAliveTimeout` {number} The number of milliseconds of inactivity | ||
| 3144 | + a server needs to wait for additional incoming data, after it has | ||
| 3145 | + finished writing the last response, before a socket will be destroyed. | ||
| 3146 | + **Default:** `5000`. | ||
| 3108 | 3147 | * `onRequestHandler` {Function} See [Compatibility API][] | |
| 3109 | 3148 | * Returns: {Http2SecureServer} | |
| 3110 | 3149 | ||
@@ -4934,6 +4973,7 @@ you need to implement any fall-back behavior yourself. | |||
| 4934 | 4973 | [ALPN Protocol ID]: https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids | |
| 4935 | 4974 | [ALPN negotiation]: #alpn-negotiation | |
| 4936 | 4975 | [Compatibility API]: #compatibility-api | |
| 4976 | + [DEP0202]: deprecations.md#dep0202-http1incomingmessage-and-http1serverresponse-options-of-http2-servers | ||
| 4937 | 4977 | [HTTP/1]: http.md | |
| 4938 | 4978 | [HTTP/2]: https://tools.ietf.org/html/rfc7540 | |
| 4939 | 4979 | [HTTP/2 Headers Object]: #headers-object | |
@@ -4960,6 +5000,7 @@ you need to implement any fall-back behavior yourself. | |||
| 4960 | 5000 | [`Http2Stream`]: #class-http2stream | |
| 4961 | 5001 | [`ServerHttp2Stream`]: #class-serverhttp2stream | |
| 4962 | 5002 | [`TypeError`]: errors.md#class-typeerror | |
| 5003 | + [`http.createServer()`]: http.md#httpcreateserveroptions-requestlistener | ||
| 4963 | 5004 | [`http2.SecureServer`]: #class-http2secureserver | |
| 4964 | 5005 | [`http2.Server`]: #class-http2server | |
| 4965 | 5006 | [`http2.createSecureServer()`]: #http2createsecureserveroptions-onrequesthandler | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,8 +48,12 @@ const { Duplex } = require('stream'); | |||
| 48 | 48 | const tls = require('tls'); | |
| 49 | 49 | const { setImmediate, setTimeout, clearTimeout } = require('timers'); | |
| 50 | 50 | ||
| 51 | - const { kIncomingMessage } = require('_http_common'); | ||
| 52 | - const { kServerResponse, Server: HttpServer, httpServerPreClose, setupConnectionsTracking } = require('_http_server'); | ||
| 51 | + const { | ||
| 52 | + Server: HttpServer, | ||
| 53 | + httpServerPreClose, | ||
| 54 | + setupConnectionsTracking, | ||
| 55 | + storeHTTPOptions, | ||
| 56 | + } = require('_http_server'); | ||
| 53 | 57 | const JSStreamSocket = require('internal/js_stream_socket'); | |
| 54 | 58 | ||
| 55 | 59 | const { | |
@@ -3257,8 +3261,6 @@ function connectionListener(socket) { | |||
| 3257 | 3261 | if (socket.alpnProtocol === false || socket.alpnProtocol === 'http/1.1') { | |
| 3258 | 3262 | // Fallback to HTTP/1.1 | |
| 3259 | 3263 | if (options.allowHTTP1 === true) { | |
| 3260 | - socket.server[kIncomingMessage] = options.Http1IncomingMessage; | ||
| 3261 | - socket.server[kServerResponse] = options.Http1ServerResponse; | ||
| 3262 | 3264 | return httpConnectionListener.call(this, socket); | |
| 3263 | 3265 | } | |
| 3264 | 3266 | // Let event handler deal with the socket | |
@@ -3340,9 +3342,18 @@ function initializeOptions(options) { | |||
| 3340 | 3342 | options.unknownProtocolTimeout = 10000; | |
| 3341 | 3343 | ||
| 3342 | 3344 | ||
| 3343 | - // Used only with allowHTTP1 | ||
| 3344 | - options.Http1IncomingMessage ||= http.IncomingMessage; | ||
| 3345 | - options.Http1ServerResponse ||= http.ServerResponse; | ||
| 3345 | + // Initialize http1Options bag for HTTP/1 fallback when allowHTTP1 is true. | ||
| 3346 | + // This bag is passed to storeHTTPOptions() to configure HTTP/1 server | ||
| 3347 | + // behavior (timeouts, IncomingMessage/ServerResponse classes, etc.). | ||
| 3348 | + options.http1Options = { ...options.http1Options }; | ||
| 3349 | + | ||
| 3350 | + // Backward compat: migrate deprecated top-level Http1 options (DEP0201) | ||
| 3351 | + if (options.Http1IncomingMessage !== undefined) { | ||
| 3352 | + options.http1Options.IncomingMessage ??= options.Http1IncomingMessage; | ||
| 3353 | + } | ||
| 3354 | + if (options.Http1ServerResponse !== undefined) { | ||
| 3355 | + options.http1Options.ServerResponse ??= options.Http1ServerResponse; | ||
| 3356 | + } | ||
| 3346 | 3357 | ||
| 3347 | 3358 | options.Http2ServerRequest ||= Http2ServerRequest; | |
| 3348 | 3359 | options.Http2ServerResponse ||= Http2ServerResponse; | |
@@ -3390,9 +3401,7 @@ class Http2SecureServer extends TLSServer { | |||
| 3390 | 3401 | this.timeout = 0; | |
| 3391 | 3402 | this.on('newListener', setupCompat); | |
| 3392 | 3403 | if (options.allowHTTP1 === true) { | |
| 3393 | - this.headersTimeout = 60_000; // Minimum between 60 seconds or requestTimeout | ||
| 3394 | - this.requestTimeout = 300_000; // 5 minutes | ||
| 3395 | - this.connectionsCheckingInterval = 30_000; // 30 seconds | ||
| 3404 | + storeHTTPOptions.call(this, { ...options, ...options.http1Options }); | ||
| 3396 | 3405 | this.shouldUpgradeCallback = function() { | |
| 3397 | 3406 | return this.listenerCount('upgrade') > 0; | |
| 3398 | 3407 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,6 +20,10 @@ const ca = fixtures.readKey('fake-startcom-root-cert.pem'); | |||
| 20 | 20 | function onRequest(request, response) { | |
| 21 | 21 | const { socket: { alpnProtocol } } = request.httpVersion === '2.0' ? | |
| 22 | 22 | request.stream.session : request; | |
| 23 | + // Verify that http1Options are applied when allowHTTP1 is true | ||
| 24 | + if (request.httpVersion === '1.1') { | ||
| 25 | + assert.strictEqual(request.socket.server.keepAliveTimeout, 10000); | ||
| 26 | + } | ||
| 23 | 27 | response.status(200); | |
| 24 | 28 | response.end(JSON.stringify({ | |
| 25 | 29 | alpnProtocol, | |
@@ -46,8 +50,11 @@ class MyServerResponse extends http.ServerResponse { | |||
| 46 | 50 | { | |
| 47 | 51 | cert, | |
| 48 | 52 | key, allowHTTP1: true, | |
| 49 | - Http1IncomingMessage: MyIncomingMessage, | ||
| 50 | - Http1ServerResponse: MyServerResponse | ||
| 53 | + http1Options: { | ||
| 54 | + IncomingMessage: MyIncomingMessage, | ||
| 55 | + ServerResponse: MyServerResponse, | ||
| 56 | + keepAliveTimeout: 10000, | ||
| 57 | + }, | ||
| 51 | 58 | }, | |
| 52 | 59 | common.mustCall(onRequest, 1) | |
| 53 | 60 | ); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments