Skip to content

Commit

Permalink
http2: small fixes to http2 core
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
apapirovski authored and MylesBorins committed Oct 23, 2017
1 parent bcb83f7 commit bc1ad81
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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');
}
}
Expand Down Expand Up @@ -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');
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit bc1ad81

Please sign in to comment.