mirror of
https://github.com/avwo/whistle.git
synced 2026-10-19 07:01:44 +08:00
refactor: handle request errors
This commit is contained in:
+3
-3
@@ -27,7 +27,7 @@ function getSocket(options, callback) {
|
||||
NPNProtocols: SUPPORTED_PROTOS
|
||||
}, function(err, socket) {
|
||||
if (err) {
|
||||
return callback();
|
||||
return callback(false, null, err);
|
||||
}
|
||||
var proto = socket.alpnProtocol || socket.npnProtocol;
|
||||
callback(proto === 'h2', socket);
|
||||
@@ -124,7 +124,7 @@ exports.request = function(req, res, callback) {
|
||||
pendingList[name] = [[req, res, callback]];
|
||||
}
|
||||
}
|
||||
getSocket(client ? null : options, function(isH2, socket) {
|
||||
getSocket(client ? null : options, function(isH2, socket, err) {
|
||||
client = client || (isH2 && getClient(req, socket, name));
|
||||
var pendingItem = pendingList[name];
|
||||
delete pendingList[name];
|
||||
@@ -138,7 +138,7 @@ exports.request = function(req, res, callback) {
|
||||
requestH2(client, req, res);
|
||||
}
|
||||
} else {
|
||||
notH2.set(name, 1);
|
||||
!err && notH2.set(name, 1);
|
||||
if (pendingItem) {
|
||||
pendingItem.forEach(function(list) {
|
||||
list[2](socket);
|
||||
|
||||
Reference in New Issue
Block a user