Skip to content

Commit

Permalink
*) Suppress stacktrace on proxy error for "Connection reset"
Browse files Browse the repository at this point in the history
  • Loading branch information
theli committed Sep 3, 2005
1 parent 6991b9e commit 8f3d19b
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions source/de/anomic/http/httpdProxyHandler.java
Expand Up @@ -668,36 +668,49 @@ private void fulfillRequestFromWeb(Properties conProp, URL url,String ext, httpH
String httpStatusText = null;
String errorMessage = null;
Exception errorExc = e;
boolean unknownError = false;

if (e instanceof ConnectException) {
httpStatusCode = 403; httpStatusText = "Connection refused";
errorMessage = "Connection refused by destination host";
errorMessage = "Connection refused by destination host";
} else if (e instanceof BindException) {
errorMessage = "Unable to establish a connection to the destination host";
} else if (e instanceof NoRouteToHostException) {
errorMessage = "No route to destination host";
} else if (e instanceof UnknownHostException) {
errorMessage = "IP address of the destination host could not be determined";
} else {
if (e.getMessage().indexOf("Corrupt GZIP trailer") >= 0) {
String exceptionMsg = e.getMessage();
if ((exceptionMsg != null) && (exceptionMsg.indexOf("Corrupt GZIP trailer") >= 0)) {
// just do nothing, we leave it this way
this.theLogger.logFine("ignoring bad gzip trail for URL " + url + " (" + e.getMessage() + ")");
this.forceConnectionClose();
} else if ((exceptionMsg != null) && (exceptionMsg.indexOf("Connection reset")>= 0)) {
errorMessage = "Connection reset";
} else if ((remote != null)&&(remote.isClosed())) {
// TODO: query for broken pipe
errorMessage = "destination host unexpectedly closed connection";
errorMessage = "Destination host unexpectedly closed connection";
} else {
errorMessage = "Unexpected Error. " + e.getClass().getName() + ": " + e.getMessage();
unknownError = true;
}
}

// sending back an error message to the client
if (!conProp.containsKey(httpd.CONNECTION_PROP_PROXY_RESPOND_HEADER)) {
httpd.sendRespondError(conProp,respond,4,httpStatusCode,httpStatusText,errorMessage,errorExc);
} else {
this.theLogger.logFine("Error while processing request '" +
conProp.getProperty(httpd.CONNECTION_PROP_REQUESTLINE,"unknown") + "':" +
"\n" + errorMessage,e);
if (unknownError) {
this.theLogger.logFine("Error while processing request '" +
conProp.getProperty(httpd.CONNECTION_PROP_REQUESTLINE,"unknown") + "':" +
"\n" + Thread.currentThread().getName() +
"\n" + errorMessage,e);
} else {
this.theLogger.logFine("Error while processing request '" +
conProp.getProperty(httpd.CONNECTION_PROP_REQUESTLINE,"unknown") + "':" +
"\n" + Thread.currentThread().getName() +
"\n" + errorMessage);
}
this.forceConnectionClose();
}
} catch (Exception ee) {
Expand Down

0 comments on commit 8f3d19b

Please sign in to comment.