6262
6363/**
6464 * Serves the content of a branch.
65- *
65+ *
6666 * @author James Moger
67- *
67+ *
6868 */
6969@ Singleton
7070public class RawServlet extends HttpServlet {
@@ -86,7 +86,7 @@ public RawServlet(IRuntimeManager runtimeManager, IRepositoryManager repositoryM
8686
8787 /**
8888 * Returns an url to this servlet for the specified parameters.
89- *
89+ *
9090 * @param baseURL
9191 * @param repository
9292 * @param branch
@@ -142,7 +142,7 @@ protected boolean renderIndex() {
142142
143143 /**
144144 * Retrieves the specified resource from the specified branch of the repository.
145- *
145+ *
146146 * @param request
147147 * @param response
148148 * @throws javax.servlet.ServletException
@@ -219,6 +219,9 @@ private void processRequest(HttpServletRequest request, HttpServletResponse resp
219219 List <PathModel > pathEntries = JGitUtils .getFilesInPath (r , requestedPath , commit );
220220 if (pathEntries .isEmpty ()) {
221221 // requested a specific resource
222+ if (requestedPath .startsWith ("/" )) {
223+ requestedPath = requestedPath .substring (1 );
224+ }
222225 String file = StringUtils .getLastPathElement (requestedPath );
223226 try {
224227
@@ -274,7 +277,7 @@ private void processRequest(HttpServletRequest request, HttpServletResponse resp
274277 } else {
275278 // stream binary content directly from the repository
276279 if (!streamFromRepo (request , response , r , commit , requestedPath )) {
277- logger .error ("RawServlet Failed to load {} {} {}" , repository , commit .getName (), path );
280+ logger .error ("RawServlet Failed to stream {} {} {}" , repository , commit .getName (), path );
278281 notFound (response , requestedPath , branch );
279282 }
280283 }
@@ -395,13 +398,13 @@ protected boolean isTextDataType(String contentType) {
395398
396399 /**
397400 * Override all text types to be plain text.
398- *
401+ *
399402 * @param response
400403 * @param contentType
401404 */
402405 protected void setContentType (HttpServletResponse response , String contentType ) {
403406 if (isTextType (contentType )) {
404- response .setContentType ("text/plain" );
407+ response .setContentType ("text/plain; charset=" + Constants . ENCODING );
405408 } else {
406409 response .setContentType (contentType );
407410 }
0 commit comments