Skip to content

Commit

Permalink
http2: optimize the altsvc Max bytes limit, define and use constants
Browse files Browse the repository at this point in the history
PR-URL: #29673
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
rickyes authored and targos committed Oct 1, 2019
1 parent 64740d4 commit a04fc86
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ function debugSessionObj(session, message, ...args) {
const kMaxFrameSize = (2 ** 24) - 1;
const kMaxInt = (2 ** 32) - 1;
const kMaxStreams = (2 ** 31) - 1;
const kMaxALTSVC = (2 ** 14) - 2;

// eslint-disable-next-line no-control-regex
const kQuotedString = /^[\x09\x20-\x5b\x5d-\x7e\x80-\xff]*$/;
Expand Down Expand Up @@ -1498,7 +1499,7 @@ class ServerHttp2Session extends Http2Session {
throw new ERR_INVALID_CHAR('alt');

// Max length permitted for ALTSVC
if ((alt.length + (origin !== undefined ? origin.length : 0)) > 16382)
if ((alt.length + (origin !== undefined ? origin.length : 0)) > kMaxALTSVC)
throw new ERR_HTTP2_ALTSVC_LENGTH();

this[kHandle].altsvc(stream, origin || '', alt);
Expand Down Expand Up @@ -1530,7 +1531,7 @@ class ServerHttp2Session extends Http2Session {
len += origin.length;
}

if (len > 16382)
if (len > kMaxALTSVC)
throw new ERR_HTTP2_ORIGIN_LENGTH();

this[kHandle].origin(arr, count);
Expand Down

0 comments on commit a04fc86

Please sign in to comment.