*/\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
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
}
}
- 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 {
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;