提交 c2c4eb47 编写于 作者: K kohsuke

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
上级 5f431413
......@@ -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;
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册