]> source.dussan.org Git - gitblit.git/commitdiff
Do not stamp raw servlet responses with cache-control headers 48/148/1
authorJames Moger <james.moger@gitblit.com>
Thu, 4 Sep 2014 17:04:20 +0000 (13:04 -0400)
committerJames Moger <james.moger@gitblit.com>
Thu, 4 Sep 2014 17:04:20 +0000 (13:04 -0400)
src/main/java/com/gitblit/servlet/PagesServlet.java
src/main/java/com/gitblit/servlet/RawServlet.java

index f578f86f59b1e703eaa5af11cb1cb74b60d1b2cd..a8e834183fc7286fa2e56f6775b10bc27dce2ebc 100644 (file)
  */\r
 package com.gitblit.servlet;\r
 \r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.util.Date;\r
+\r
+import javax.servlet.ServletException;\r
 import javax.servlet.http.HttpServletRequest;\r
 import javax.servlet.http.HttpServletResponse;\r
 \r
+import org.eclipse.jgit.lib.Repository;\r
+import org.eclipse.jgit.revwalk.RevCommit;\r
+\r
 import com.gitblit.Constants;\r
+import com.gitblit.utils.JGitUtils;\r
 \r
 /**\r
  * Serves the content of a gh-pages branch.\r
@@ -73,4 +82,22 @@ public class PagesServlet extends RawServlet {
        protected void setContentType(HttpServletResponse response, String contentType) {\r
                response.setContentType(contentType);;\r
        }\r
+\r
+       @Override\r
+       protected void streamFromRepo(HttpServletResponse response, Repository repository,\r
+                       RevCommit commit, String requestedPath) throws IOException {\r
+\r
+               response.setDateHeader("Last-Modified", JGitUtils.getCommitDate(commit).getTime());\r
+               response.setHeader("Cache-Control", "public, max-age=3600, must-revalidate");\r
+\r
+               super.streamFromRepo(response, repository, commit, requestedPath);\r
+       }\r
+\r
+       @Override\r
+       protected void sendContent(HttpServletResponse response, Date date, InputStream is) throws ServletException, IOException {\r
+               response.setDateHeader("Last-Modified", date.getTime());\r
+               response.setHeader("Cache-Control", "public, max-age=3600, must-revalidate");\r
+\r
+               super.sendContent(response, date, is);\r
+       }\r
 }\r
index a9e58202a28768ff07e6552a15b1c0ef9c2c1fcd..30d33fd758bc78b742990d1633447fd68bd3d7b3 100644 (file)
@@ -421,12 +421,9 @@ public class RawServlet extends DaggerServlet {
                }
        }
 
-       private void streamFromRepo(HttpServletResponse response, Repository repository,
+       protected void streamFromRepo(HttpServletResponse response, Repository repository,
                        RevCommit commit, String requestedPath) throws IOException {
 
-               response.setDateHeader("Last-Modified", JGitUtils.getCommitDate(commit).getTime());
-               response.setHeader("Cache-Control", "public, max-age=3600, must-revalidate");
-
                RevWalk rw = new RevWalk(repository);
                TreeWalk tw = new TreeWalk(repository);
                try {
@@ -457,9 +454,8 @@ public class RawServlet extends DaggerServlet {
                response.flushBuffer();
        }
 
-       private void sendContent(HttpServletResponse response, Date date, InputStream is) throws ServletException, IOException {
-               response.setDateHeader("Last-Modified", date.getTime());
-               response.setHeader("Cache-Control", "public, max-age=3600, must-revalidate");
+       protected void sendContent(HttpServletResponse response, Date date, InputStream is) throws ServletException, IOException {
+
                try {
                        byte[] tmp = new byte[8192];
                        int len = 0;