summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2014-09-04 13:04:20 -0400
committerJames Moger <james.moger@gitblit.com>2014-09-04 13:04:20 -0400
commit818973b2baece0ff3245de10091f5ca8bdffebc6 (patch)
tree66fe9009efc25bb085170c05e0de50ff14508b73 /src/main/java
parent16e1542465bf7dfd89c02299d9bd47a3be15209e (diff)
downloadgitblit-818973b2baece0ff3245de10091f5ca8bdffebc6.tar.gz
gitblit-818973b2baece0ff3245de10091f5ca8bdffebc6.zip
Do not stamp raw servlet responses with cache-control headers
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/gitblit/servlet/PagesServlet.java27
-rw-r--r--src/main/java/com/gitblit/servlet/RawServlet.java10
2 files changed, 30 insertions, 7 deletions
diff --git a/src/main/java/com/gitblit/servlet/PagesServlet.java b/src/main/java/com/gitblit/servlet/PagesServlet.java
index f578f86f..a8e83418 100644
--- a/src/main/java/com/gitblit/servlet/PagesServlet.java
+++ b/src/main/java/com/gitblit/servlet/PagesServlet.java
@@ -15,10 +15,19 @@
*/
package com.gitblit.servlet;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+
+import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+
import com.gitblit.Constants;
+import com.gitblit.utils.JGitUtils;
/**
* Serves the content of a gh-pages branch.
@@ -73,4 +82,22 @@ public class PagesServlet extends RawServlet {
protected void setContentType(HttpServletResponse response, String contentType) {
response.setContentType(contentType);;
}
+
+ @Override
+ 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");
+
+ super.streamFromRepo(response, repository, commit, requestedPath);
+ }
+
+ @Override
+ protected 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");
+
+ super.sendContent(response, date, is);
+ }
}
diff --git a/src/main/java/com/gitblit/servlet/RawServlet.java b/src/main/java/com/gitblit/servlet/RawServlet.java
index a9e58202..30d33fd7 100644
--- a/src/main/java/com/gitblit/servlet/RawServlet.java
+++ b/src/main/java/com/gitblit/servlet/RawServlet.java
@@ -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;