Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Lindberg2009-05-13 17:21:16 -0400
committerHenrik Lindberg2009-05-13 17:21:16 -0400
commit2199a0ca8eddaf4bfdd49863b949c5719b6f5095 (patch)
tree616e428cde32f27135f347521a2007eb947e6c92 /bundles/org.eclipse.equinox.p2.testserver
parentd33f1ed6eae00a517dcb0d0619b3433a46155d37 (diff)
downloadrt.equinox.p2-2199a0ca8eddaf4bfdd49863b949c5719b6f5095.tar.gz
rt.equinox.p2-2199a0ca8eddaf4bfdd49863b949c5719b6f5095.tar.xz
rt.equinox.p2-2199a0ca8eddaf4bfdd49863b949c5719b6f5095.zip
Status codes were not passed through when server delivered content on a 404
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.testserver')
-rw-r--r--bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/BasicResourceDelivery.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/BasicResourceDelivery.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/BasicResourceDelivery.java
index ff5eaeb4f..13dc0cf99 100644
--- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/BasicResourceDelivery.java
+++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/BasicResourceDelivery.java
@@ -120,6 +120,9 @@ public class BasicResourceDelivery extends HttpServlet {
protected void doDeliver(URLConnection conn, InputStream in, String filename, HttpServletRequest request, HttpServletResponse response) throws IOException {
// set when the resource was modified
addDateHeader(response, HttpConstants.LAST_MODIFIED, getLastModified(conn));
+ int statusCode = HttpHeaderToStatus(conn.getHeaderField(0));
+
+ response.setStatus(statusCode != -1 ? HttpServletResponse.SC_OK : statusCode);
int contentlength = getContentLength(conn);
if (contentlength >= 0) {
@@ -193,6 +196,9 @@ public class BasicResourceDelivery extends HttpServlet {
protected void doDeliverHead(String filename, URLConnection conn, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
int contentlength = getContentLength(conn);
+ int statusCode = HttpHeaderToStatus(conn.getHeaderField(0));
+ // set status = ok if there was no http header...
+ response.setStatus(statusCode == -1 ? HttpServletResponse.SC_OK : statusCode);
if (contentlength >= 0) {
response.setContentLength(contentlength);
@@ -206,6 +212,18 @@ public class BasicResourceDelivery extends HttpServlet {
}
+ public int HttpHeaderToStatus(String httpHeader) {
+ if (httpHeader == null)
+ return -1;
+ try {
+ return Integer.valueOf((httpHeader.substring(9, 12))).intValue();
+ } catch (IndexOutOfBoundsException e) {
+ return -1;
+ } catch (NumberFormatException e) {
+ return -1;
+ }
+ }
+
/**
* Override to lie about last modified
* @param conn

Back to the top