From: gmungoc Date: Wed, 13 May 2015 09:44:28 +0000 (+0100) Subject: JAL-1575 no-cache headers added to (empty) rest response X-Git-Tag: Release_2_10_0~678 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=ac207fd787051c6e0f4f9f10ea6b94452480d931;p=jalview.git JAL-1575 no-cache headers added to (empty) rest response --- diff --git a/src/jalview/httpserver/AbstractRequestHandler.java b/src/jalview/httpserver/AbstractRequestHandler.java index 9642508..8030c1d 100644 --- a/src/jalview/httpserver/AbstractRequestHandler.java +++ b/src/jalview/httpserver/AbstractRequestHandler.java @@ -73,9 +73,10 @@ public abstract class AbstractRequestHandler extends AbstractHandler * * @param request * @param response + * @throws IOException */ protected abstract void processRequest(HttpServletRequest request, - HttpServletResponse response); + HttpServletResponse response) throws IOException; /** * For debug - writes HTTP request details to stdout diff --git a/src/jalview/httpserver/HttpServer.java b/src/jalview/httpserver/HttpServer.java index fcfefaa..34b39cd 100644 --- a/src/jalview/httpserver/HttpServer.java +++ b/src/jalview/httpserver/HttpServer.java @@ -131,7 +131,6 @@ public class HttpServer // "HttpServer started with %d threads", server.getThreadPool() // .getThreads())); contextRoot = server.getURI(); - System.out.println("Jalview endpoint " + contextRoot); } catch (Exception e) { System.err.println("Error trying to start HttpServer: " diff --git a/src/jalview/rest/RestHandler.java b/src/jalview/rest/RestHandler.java index 88f23f4..3f00c07 100644 --- a/src/jalview/rest/RestHandler.java +++ b/src/jalview/rest/RestHandler.java @@ -64,7 +64,7 @@ public class RestHandler extends AbstractRequestHandler */ @Override protected void processRequest(HttpServletRequest request, - HttpServletResponse response) + HttpServletResponse response) throws IOException { /* * Currently just echoes the request; add helper classes as required to @@ -72,19 +72,15 @@ public class RestHandler extends AbstractRequestHandler */ final String queryString = request.getQueryString(); final String reply = "REST not yet implemented; received " - + request.getRequestURL() + + request.getMethod() + ": " + request.getRequestURL() + (queryString == null ? "" : "?" + queryString); System.out.println(reply); - try - { - final PrintWriter writer = response.getWriter(); - writer.write(reply); - writer.close(); - } catch (IOException e) - { - System.err.println("Error writing REST response: " + e.getMessage()); - } + response.setHeader("Cache-Control", "no-cache/no-store"); + response.setHeader("Content-type", "text/plain"); + final PrintWriter writer = response.getWriter(); + writer.write(reply); + writer.close(); } /**