Skip to content

Commit

Permalink
*) Bugfix for:
Browse files Browse the repository at this point in the history
   - 302 redirection Problem on Amazon Server
   - Wrong References in proxymsg/error.html
   See: http://www.yacy-forum.de/viewtopic.php?t=515

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@271 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
theli committed Jun 13, 2005
1 parent 6dd3ec0 commit c7d294d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 18 deletions.
7 changes: 5 additions & 2 deletions htroot/proxymsg/error.html
Expand Up @@ -7,7 +7,10 @@
<meta name="keywords" content="yacy proxy error message">
<meta name="description" content="YaCy proxy error message">
<meta name="copyright" content="Michael Christen">

<base href="http://#[host]#:#[port]#/">
<link rel="stylesheet" media="all" href="/env/style.css">

<!-- (C), Architecture and Realisation: Michael Peter Christen; Contact: mc <at> anomic.de -->

</head>
Expand All @@ -32,7 +35,7 @@
</table>
<br><br>

<table border="0" cellspacing="0" cellpadding="0" style="margin-left: auto; margin-right: auto; margin-top: 5em;">
<table border="0" cellspacing="0" cellpadding="0" style="margin-left: 5em; margin-right: 5em; margin-top: 5em;">
<tr>
<td>
<p>
Expand Down Expand Up @@ -66,7 +69,7 @@ <h2>Error with request: <font color="#556699">#[requestMethod]# #[requestURL]#:<
::
<tr>
<td>
<code><font color="red">#[stacktrace]#</font></code>
<font color="red"><code>#[stacktrace]#</code></font>
</td>
</tr>
#(/printStackTrace)#
Expand Down
14 changes: 9 additions & 5 deletions source/de/anomic/http/httpd.java
Expand Up @@ -1086,23 +1086,27 @@ else if (httpVersion.equals("HTTP/1.1") && httpHeader.http1_1.containsKey(Intege

// set rewrite values
serverObjects tp = new serverObjects();

tp.put("host", serverCore.publicIP().getHostAddress());
tp.put("port", switchboard.getConfig("port", "8080"));

tp.put("errorMessageType", errorcase);
tp.put("httpStatus", Integer.toString(httpStatusCode) + " " + httpStatusText);
tp.put("requestMethod", conProp.getProperty(httpd.CONNECTION_PROP_METHOD));
tp.put("requestURL", urlString);
tp.put("detailedErrorMsg",(detailedErrorMsg != null) ? detailedErrorMsg : "");
tp.put("errorMessageType_detailedErrorMsg",(detailedErrorMsg != null) ? detailedErrorMsg : "");

// building the stacktrace
if (stackTrace != null) {
serverByteBuffer errorMsg = new serverByteBuffer();
errorMsg.append("Exception occurred:\r\n")
errorMsg.append("Exception occurred:\r\n\r\n")
.append(stackTrace.toString())
.append("\r\n")
.append("[TRACE: ");
.append("TRACE: ");
stackTrace.printStackTrace(new PrintStream(errorMsg));
errorMsg.write(("]\r\n").getBytes());
errorMsg.write(("\r\n").getBytes());
tp.put("printStackTrace",1);
tp.put("printStackTrace_stacktrace",errorMsg.toString());
tp.put("printStackTrace_stacktrace",errorMsg.toString().replaceAll("\n","<br>"));
} else {
tp.put("printStackTrace",0);
}
Expand Down
38 changes: 28 additions & 10 deletions source/de/anomic/http/httpdFileHandler.java
Expand Up @@ -343,7 +343,6 @@ public void doResponse(Properties conProp, httpHeader requestHeader, OutputStrea
}

Date filedate;
long filelength;
File rc = null;
try {
// locate the file
Expand Down Expand Up @@ -481,15 +480,34 @@ public void doResponse(Properties conProp, httpHeader requestHeader, OutputStrea
httpd.sendRespondError(conProp,out,3,404,"File not Found",null,null);
//textMessage(out, 404, "404 File not Found\r\n"); // would be a possible vuln to return original the original path
}
} catch (Exception e) {
//textMessage(out, 503, "Exception with query: " + path + "; '" + e.toString() + ":" + e.getMessage() + "'\r\n");
//e.printStackTrace();
this.theLogger.logError("ERROR: Exception with query: " + path + "; '" + e.toString() + ":" + e.getMessage() + "'");
}
out.flush();
if (!(requestHeader.get(httpHeader.CONNECTION, "close").equals("keep-alive"))) {
// wait a little time until everything closes so that clients can read from the streams/sockets
try {Thread.currentThread().sleep(1000);} catch (InterruptedException e) {}
} catch (Exception e) {
if (e instanceof InterruptedException) {
this.theLogger.logInfo("Interruption detected while processing query: " + path + "; '" + e.toString() + ":" + e.getMessage() + "'");
if (!conProp.containsKey(httpd.CONNECTION_PROP_PROXY_RESPOND_HEADER)) {
httpd.sendRespondError(conProp,out, 4, 503, null, "Exception with query: " + path + "; Service unavailable because of server shutdown.",e);
} else {
conProp.put(httpd.CONNECTION_PROP_PERSISTENT,"close");
}
} else {
if (e.getMessage().startsWith("Broken pipe") || e.getMessage().startsWith("Connection reset by peer")) {
// client closed the connection, so we just end silently
this.theLogger.logInfo("Client unexpectedly closed connection while processing query: " + path + "; '" + e.toString() + ":" + e.getMessage() + "'");
conProp.put(httpd.CONNECTION_PROP_PERSISTENT,"close");
} else {
this.theLogger.logError("ERROR: Exception with query: " + path + "; '" + e.toString() + ":" + e.getMessage() + "'");
if (!conProp.containsKey(httpd.CONNECTION_PROP_PROXY_RESPOND_HEADER)) {
httpd.sendRespondError(conProp,out, 4, 503, null, "Exception with query: " + path + "; '" + e.toString() + ":" + e.getMessage() + "'",e);
} else {
conProp.put(httpd.CONNECTION_PROP_PERSISTENT,"close");
}
}
}
} finally {
try {out.flush();}catch (Exception e) {}
if (!(requestHeader.get(httpHeader.CONNECTION, "close").equals("keep-alive"))) {
// wait a little time until everything closes so that clients can read from the streams/sockets
try {Thread.currentThread().sleep(1000);} catch (InterruptedException e) {}
}
}
}

Expand Down
9 changes: 8 additions & 1 deletion source/de/anomic/http/httpdProxyHandler.java
Expand Up @@ -598,7 +598,14 @@ private void fulfillRequestFromWeb(Properties conProp, URL url,String ext, httpH

// request has been placed and result has been returned. work off response
try {
httpd.sendRespondHeader(conProp,respond,httpVer,Integer.parseInt(res.status.split(" ")[0]),res.status.split(" ")[1],res.responseHeader);
String[] resStatus = res.status.split(" ");
httpd.sendRespondHeader(
conProp,
respond,
httpVer,
Integer.parseInt((resStatus.length > 0) ? resStatus[0]:"503"),
(resStatus.length > 1) ? resStatus[1] : null,
res.responseHeader);

String storeError;
if ((storeError = cacheEntry.shallStoreCache()) == null) {
Expand Down

0 comments on commit c7d294d

Please sign in to comment.