From 668f9ef91974424d31a76d0c1c96a41fc307c106 Mon Sep 17 00:00:00 2001 From: Keiichi Watanabe Date: Mon, 19 Dec 2016 01:56:42 +0900 Subject: [PATCH] Fix content-type of get-contents API --- .../gitbucket/core/controller/ApiController.scala | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/scala/gitbucket/core/controller/ApiController.scala b/src/main/scala/gitbucket/core/controller/ApiController.scala index 248f74bc5..d118fa4ae 100644 --- a/src/main/scala/gitbucket/core/controller/ApiController.scala +++ b/src/main/scala/gitbucket/core/controller/ApiController.scala @@ -133,9 +133,12 @@ trait ApiControllerBase extends ControllerBase { val largeFile = params.get("large_file").exists(s => s.equals("true")) val content = getContentFromId(git, f.id, largeFile) request.getHeader("Accept") match { - case "application/vnd.github.v3.raw" => + case "application/vnd.github.v3.raw" => { + contentType = "application/vnd.github.v3.raw" content - case "application/vnd.github.v3.html" if isRenderable(f.name) => + } + case "application/vnd.github.v3.html" if isRenderable(f.name) => { + contentType = "application/vnd.github.v3.html" content.map(c => List( "
", "
", @@ -143,7 +146,9 @@ trait ApiControllerBase extends ControllerBase { "
", "
" ).mkString ) - case "application/vnd.github.v3.html" => + } + case "application/vnd.github.v3.html" => { + contentType = "application/vnd.github.v3.html" content.map(c => List( "
", "
", "
",
@@ -151,6 +156,7 @@ trait ApiControllerBase extends ControllerBase {
                   "
", "
", "
" ).mkString ) + } case _ => Some(JsonFormat(ApiContents(f, content))) }