瀏覽代碼

BF: send files for annex/objects as generic application/octet-stream (i.e binary)

Yaroslav Halchenko 5 年之前
父節點
當前提交
cf0c2f4ef3
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      internal/route/repo/http.go

+ 6 - 1
internal/route/repo/http.go

@@ -325,6 +325,11 @@ func getTextFile(h serviceHandler) {
 	h.sendFile("text/plain")
 }
 
+func getBinaryFile(h serviceHandler) {
+	h.setHeaderNoCache()
+	h.sendFile("application/octet-stream")
+}
+
 func getInfoPacks(h serviceHandler) {
 	h.setHeaderCacheForever()
 	h.sendFile("text/plain; charset=utf-8")
@@ -366,7 +371,7 @@ var routes = []struct {
 	// TODO: we probably just need to provide some getBinaryFile
 	// Note: code below treats HEAD (used by git annex drop to sense presence)
 	// as "GET" for the purpose of allowing or not the route
-	{regexp.MustCompile("(.*?)/annex/objects/.*/.*-s[0-9]*--.*"), "GET", getTextFile},
+	{regexp.MustCompile("(.*?)/annex/objects/.*/.*-s[0-9]*--.*"), "GET", getBinaryFile},
 }
 
 func getGitRepoPath(dir string) (string, error) {