From 252dc07d7f85cc344b5919bb7c6166ef84b2102e Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gmail.com>
Date: Mon, 25 Jan 2016 11:55:58 -0500
Subject: [PATCH] Merge pull request #988 from gitblit/976-raw-download-filestore-item

---
 src/main/java/com/gitblit/servlet/GitFilter.java |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/gitblit/servlet/GitFilter.java b/src/main/java/com/gitblit/servlet/GitFilter.java
index 27408f0..9522893 100644
--- a/src/main/java/com/gitblit/servlet/GitFilter.java
+++ b/src/main/java/com/gitblit/servlet/GitFilter.java
@@ -102,8 +102,8 @@
 	}
 
 	/**
-	 * Analyze the url and returns the action of the request. Return values are
-	 * either "/git-receive-pack" or "/git-upload-pack".
+	 * Analyze the url and returns the action of the request. Return values are:
+	 * "/git-receive-pack", "/git-upload-pack" or "/info/lfs".
 	 *
 	 * @param serverUrl
 	 * @return action of the request
@@ -316,18 +316,22 @@
 	
 	/**
 	 * Git lfs action uses an alternative authentication header, 
+	 * dependent on the viewing method.
 	 * 
+	 * @param httpRequest
 	 * @param action
 	 * @return
 	 */
 	@Override
-	protected String getAuthenticationHeader(String action) {
+	protected String getAuthenticationHeader(HttpServletRequest httpRequest, String action) {
 
 		if (action.equals(gitLfs)) {
-			return "LFS-Authenticate";
+			if (hasContentInRequestHeader(httpRequest, "Accept", FilestoreServlet.GIT_LFS_META_MIME)) {
+				return "LFS-Authenticate";
+			}
 		}
 		
-		return super.getAuthenticationHeader(action);
+		return super.getAuthenticationHeader(httpRequest, action);
 	}
 	
 	/**

--
Gitblit v1.9.1