Jetty doesn't seem to have a predefined MIME type mapping for JSON.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@17993 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2009-05-12 16:40:40 +00:00
1 parent 5f4314139f
commit c2c4eb471f
1 file changed
+10 -2
@@ -76,7 +76,7 @@ public class JavaNetReverseProxy extends HttpServlet {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String path = req.getPathInfo();
String path = req.getServletPath();
String d = Util.getDigestOf(path);
File cache = new File(cacheFolder, d);
@@ -85,10 +85,18 @@ public class JavaNetReverseProxy extends HttpServlet {
FileUtils.copyURLToFile(url,cache);
}
resp.setContentType(getServletContext().getMimeType(path));
resp.setContentType(getMimeType(path));
IOUtils.copy(new FileInputStream(cache),resp.getOutputStream());
}
private String getMimeType(String path) {
int idx = path.indexOf('?');
if(idx>=0)
path = path.substring(0,idx);
if(path.endsWith(".json")) return "text/javascript";
return getServletContext().getMimeType(path);
}
private static volatile JavaNetReverseProxy INSTANCE;
/**