diff options
author | ᴜɴᴋɴᴡᴏɴ <u@gogs.io> | 2020-04-05 00:14:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-05 00:14:22 +0800 |
commit | 53b91ef306166d39dea3c70fb8ce14973c7ae111 (patch) | |
tree | 9accdd3c806ef7e0645bb10810c922e7108f438b /internal/route | |
parent | 34145c990d4fd9f278f29cdf9c61378a75e9b934 (diff) |
lfs: run e2e and fix minor issues (#6059)
Diffstat (limited to 'internal/route')
-rw-r--r-- | internal/route/lfs/basic.go | 3 | ||||
-rw-r--r-- | internal/route/lfs/batch.go | 4 | ||||
-rw-r--r-- | internal/route/lfs/route.go | 4 |
3 files changed, 5 insertions, 6 deletions
diff --git a/internal/route/lfs/basic.go b/internal/route/lfs/basic.go index 98597345..f15873ad 100644 --- a/internal/route/lfs/basic.go +++ b/internal/route/lfs/basic.go @@ -52,14 +52,13 @@ func serveBasicDownload(c *context.Context, repo *db.Repository, oid lfsutil.OID c.Header().Set("Content-Type", "application/octet-stream") c.Header().Set("Content-Length", strconv.FormatInt(object.Size, 10)) + c.Status(http.StatusOK) _, err = io.Copy(c.Resp, r) if err != nil { - c.Status(http.StatusInternalServerError) log.Error("Failed to copy object file: %v", err) return } - c.Status(http.StatusOK) } // PUT /{owner}/{repo}.git/info/lfs/object/basic/{oid} diff --git a/internal/route/lfs/batch.go b/internal/route/lfs/batch.go index ae53f5d3..357aeace 100644 --- a/internal/route/lfs/batch.go +++ b/internal/route/lfs/batch.go @@ -166,13 +166,13 @@ const contentType = "application/vnd.git-lfs+json" func responseJSON(w http.ResponseWriter, status int, v interface{}) { w.Header().Set("Content-Type", contentType) + w.WriteHeader(status) err := jsoniter.NewEncoder(w).Encode(v) if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) + log.Error("Failed to encode JSON: %v", err) return } - w.WriteHeader(status) } func internalServerError(w http.ResponseWriter) { diff --git a/internal/route/lfs/route.go b/internal/route/lfs/route.go index 27224265..b6bd20bf 100644 --- a/internal/route/lfs/route.go +++ b/internal/route/lfs/route.go @@ -134,11 +134,11 @@ func authorize(mode db.AccessMode) macaron.Handler { } } -// verifyHeader checks if the HTTP header value is matching. +// verifyHeader checks if the HTTP header contains given value. // When not, response given "failCode" as status code. func verifyHeader(key, value string, failCode int) macaron.Handler { return func(c *context.Context) { - if c.Req.Header.Get(key) != value { + if !strings.Contains(c.Req.Header.Get(key), value) { c.Status(failCode) return } |