mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
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: https://github.com/nodejs/node/pull/16327 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
01a55ee8cb
commit
7a171fd88a
@ -881,14 +881,14 @@ class Http2Session extends EventEmitter {
|
||||
|
||||
// A stream cannot be made to depend on itself
|
||||
if (options.parent === id) {
|
||||
debug(`[${sessionName(this[kType])}] session still connecting. queue ` +
|
||||
'priority');
|
||||
throw new errors.TypeError('ERR_INVALID_OPT_VALUE',
|
||||
'parent',
|
||||
options.parent);
|
||||
}
|
||||
|
||||
if (id === undefined) {
|
||||
debug(`[${sessionName(this[kType])}] session still connecting. queue ` +
|
||||
'priority');
|
||||
stream.once('ready', submitPriority.bind(this, stream, options));
|
||||
return;
|
||||
}
|
||||
@ -1203,7 +1203,7 @@ function streamOnResume() {
|
||||
if (session && !state.reading) {
|
||||
state.reading = true;
|
||||
assert(session[kHandle].streamReadStart(this[kID]) === undefined,
|
||||
'HTTP/2 Stream #{this[kID]} does not exist. Please report this as ' +
|
||||
`HTTP/2 Stream ${this[kID]} does not exist. Please report this as ` +
|
||||
'a bug in Node.js');
|
||||
}
|
||||
}
|
||||
@ -1411,7 +1411,7 @@ class Http2Stream extends Duplex {
|
||||
return;
|
||||
state.reading = true;
|
||||
assert(this[kSession][kHandle].streamReadStart(this[kID]) === undefined,
|
||||
'HTTP/2 Stream #{this[kID]} does not exist. Please report this as ' +
|
||||
`HTTP/2 Stream ${this[kID]} does not exist. Please report this as ` +
|
||||
'a bug in Node.js');
|
||||
}
|
||||
|
||||
@ -2264,16 +2264,14 @@ function connectionListener(socket) {
|
||||
const options = this[kOptions] || {};
|
||||
|
||||
if (socket.alpnProtocol === false || socket.alpnProtocol === 'http/1.1') {
|
||||
if (options.allowHTTP1 === true) {
|
||||
// Fallback to HTTP/1.1
|
||||
// Fallback to HTTP/1.1
|
||||
if (options.allowHTTP1 === true)
|
||||
return httpConnectionListener.call(this, socket);
|
||||
} else if (this.emit('unknownProtocol', socket)) {
|
||||
// Let event handler deal with the socket
|
||||
// Let event handler deal with the socket
|
||||
if (this.emit('unknownProtocol', socket))
|
||||
return;
|
||||
} else {
|
||||
// Reject non-HTTP/2 client
|
||||
return socket.destroy();
|
||||
}
|
||||
// Reject non-HTTP/2 client
|
||||
return socket.destroy();
|
||||
}
|
||||
|
||||
socket.on('error', socketOnError);
|
||||
|
Loading…
Reference in New Issue
Block a user