mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-08-04 21:39:04 +00:00
fix #427
This commit is contained in:
@@ -550,14 +550,14 @@ function getConnectReqHandler(userRule, recorder, httpsServerMgr) {
|
||||
shouldIntercept = reqHandlerCtx.forceProxyHttps;
|
||||
}
|
||||
})
|
||||
.then(() =>
|
||||
new Promise((resolve) => {
|
||||
.then(() => {
|
||||
return new Promise((resolve) => {
|
||||
// mark socket connection as established, to detect the request protocol
|
||||
cltSocket.write('HTTP/' + req.httpVersion + ' 200 OK\r\n\r\n', 'UTF-8', resolve);
|
||||
})
|
||||
)
|
||||
.then(() =>
|
||||
new Promise((resolve, reject) => {
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let resolved = false;
|
||||
cltSocket.on('data', (chunk) => {
|
||||
requestStream.push(chunk);
|
||||
@@ -580,11 +580,19 @@ function getConnectReqHandler(userRule, recorder, httpsServerMgr) {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
cltSocket.on('error', (error) => {
|
||||
logUtil.printLog(util.collectErrorLog(error), logUtil.T_ERR);
|
||||
co.wrap(function *() {
|
||||
try {
|
||||
yield userRule.onClientSocketError(requestDetail, error);
|
||||
} catch (e) { }
|
||||
});
|
||||
});
|
||||
cltSocket.on('end', () => {
|
||||
requestStream.push(null);
|
||||
});
|
||||
})
|
||||
)
|
||||
});
|
||||
})
|
||||
.then((result) => {
|
||||
// log and recorder
|
||||
if (shouldIntercept) {
|
||||
|
||||
@@ -66,4 +66,16 @@ module.exports = {
|
||||
*onConnectError(requestDetail, error) {
|
||||
return null;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param {any} requestDetail
|
||||
* @param {any} error
|
||||
* @returns
|
||||
*/
|
||||
*onClientSocketError(requestDetail, error) {
|
||||
return null;
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user