Skip to content

Commit 7a171fd

Browse files
committed
http2: small fixes to http2 core
A few small changes: - fix debug statement location - simplify conditional with returns - consistent use of template strings PR-URL: #16327 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 01a55ee commit 7a171fd

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

lib/internal/http2/core.js

+10-12
Original file line numberDiff line numberDiff line change
@@ -881,14 +881,14 @@ class Http2Session extends EventEmitter {
881881

882882
// A stream cannot be made to depend on itself
883883
if (options.parent === id) {
884-
debug(`[${sessionName(this[kType])}] session still connecting. queue ` +
885-
'priority');
886884
throw new errors.TypeError('ERR_INVALID_OPT_VALUE',
887885
'parent',
888886
options.parent);
889887
}
890888

891889
if (id === undefined) {
890+
debug(`[${sessionName(this[kType])}] session still connecting. queue ` +
891+
'priority');
892892
stream.once('ready', submitPriority.bind(this, stream, options));
893893
return;
894894
}
@@ -1203,7 +1203,7 @@ function streamOnResume() {
12031203
if (session && !state.reading) {
12041204
state.reading = true;
12051205
assert(session[kHandle].streamReadStart(this[kID]) === undefined,
1206-
'HTTP/2 Stream #{this[kID]} does not exist. Please report this as ' +
1206+
`HTTP/2 Stream ${this[kID]} does not exist. Please report this as ` +
12071207
'a bug in Node.js');
12081208
}
12091209
}
@@ -1411,7 +1411,7 @@ class Http2Stream extends Duplex {
14111411
return;
14121412
state.reading = true;
14131413
assert(this[kSession][kHandle].streamReadStart(this[kID]) === undefined,
1414-
'HTTP/2 Stream #{this[kID]} does not exist. Please report this as ' +
1414+
`HTTP/2 Stream ${this[kID]} does not exist. Please report this as ` +
14151415
'a bug in Node.js');
14161416
}
14171417

@@ -2264,16 +2264,14 @@ function connectionListener(socket) {
22642264
const options = this[kOptions] || {};
22652265

22662266
if (socket.alpnProtocol === false || socket.alpnProtocol === 'http/1.1') {
2267-
if (options.allowHTTP1 === true) {
2268-
// Fallback to HTTP/1.1
2267+
// Fallback to HTTP/1.1
2268+
if (options.allowHTTP1 === true)
22692269
return httpConnectionListener.call(this, socket);
2270-
} else if (this.emit('unknownProtocol', socket)) {
2271-
// Let event handler deal with the socket
2270+
// Let event handler deal with the socket
2271+
if (this.emit('unknownProtocol', socket))
22722272
return;
2273-
} else {
2274-
// Reject non-HTTP/2 client
2275-
return socket.destroy();
2276-
}
2273+
// Reject non-HTTP/2 client
2274+
return socket.destroy();
22772275
}
22782276

22792277
socket.on('error', socketOnError);

0 commit comments

Comments
 (0)