Skip to content

Commit 6006055

Browse files
committed
http: use cached '1.1' http version string
1 parent b4c5fb4 commit 6006055

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/_http_common.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ function parserOnHeaders(headers, url) {
6464
this._url += url;
6565
}
6666

67+
const HTTP_VERSION_1_1 = '1.1';
68+
6769
// `headers` and `url` are set only if .onHeaders() has not been called for
6870
// this request.
6971
// `url` is not set for response parsers but that's not applicable here since
@@ -91,7 +93,9 @@ function parserOnHeadersComplete(versionMajor, versionMinor, headers, method,
9193
const incoming = parser.incoming = new ParserIncomingMessage(socket);
9294
incoming.httpVersionMajor = versionMajor;
9395
incoming.httpVersionMinor = versionMinor;
94-
incoming.httpVersion = `${versionMajor}.${versionMinor}`;
96+
incoming.httpVersion = versionMajor === 1 && versionMinor === 1
97+
? HTTP_VERSION_1_1
98+
: `${versionMajor}.${versionMinor}`;
9599
incoming.joinDuplicateHeaders = socket?.server?.joinDuplicateHeaders ||
96100
parser.joinDuplicateHeaders;
97101
incoming.url = url;

0 commit comments

Comments
 (0)