Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http2: optimize the altsvc Max bytes limit, define and use constants #29673

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,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 @@ -1476,7 +1477,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 @@ -1508,7 +1509,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