Add delete tunnel endpoint
#151
+10
-2
@@ -55,7 +55,7 @@ class Client extends EventEmitter {
|
|||||||
this.emit('close');
|
this.emit('close');
|
||||||
}
|
}
|
||||||
|
|
||||||
handleRequest(req, res) {
|
handleRequest(req, res, retry = true) {
|
||||||
this.debug('> %s', req.url);
|
this.debug('> %s', req.url);
|
||||||
const opt = {
|
const opt = {
|
||||||
path: req.url,
|
path: req.url,
|
||||||
@@ -74,6 +74,7 @@ class Client extends EventEmitter {
|
|||||||
pump(clientRes, res, (err) => {
|
pump(clientRes, res, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
this.debug('> PIPE ERROR, %s', err);
|
this.debug('> PIPE ERROR, %s', err);
|
||||||
|
this.debug(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -83,14 +84,21 @@ class Client extends EventEmitter {
|
|||||||
// if we have already sent headers?
|
// if we have already sent headers?
|
||||||
clientReq.once('error', (err) => {
|
clientReq.once('error', (err) => {
|
||||||
// TODO(roman): if headers not sent - respond with gateway unavailable
|
// TODO(roman): if headers not sent - respond with gateway unavailable
|
||||||
this.debug('ERROR < %s', req.url);
|
this.debug(' < ERROR %s', req.url);
|
||||||
this.debug(err);
|
this.debug(err);
|
||||||
|
this.debug(JSON.stringify( err ));
|
||||||
|
|
||||||
|
if (retry) {
|
||||||
|
this.debug('< RETRY');
|
||||||
|
this.handleRequest( req, res, false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// using pump is deliberate - see the pump docs for why
|
// using pump is deliberate - see the pump docs for why
|
||||||
pump(req, clientReq, (err) => {
|
pump(req, clientReq, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
this.debug('< PIPE ERROR, %s', err);
|
this.debug('< PIPE ERROR, %s', err);
|
||||||
|
this.debug(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ export default function(opt) {
|
|||||||
const clientId = GetClientIdFromHostname(hostname);
|
const clientId = GetClientIdFromHostname(hostname);
|
||||||
if (!clientId) {
|
if (!clientId) {
|
||||||
appCallback(req, res);
|
appCallback(req, res);
|
||||||
|
debug('ClientID for host %s was not found :(', hostname);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user