Commit 369ad5b4 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Merge branch 'git-raw-content-length' into 'master'

Unset Content-Length for raw Git blobs

Fixes https://gitlab.com/gitlab-org/gitlab-workhorse/merge_requests/30#note_3560130

Failure to get raw Git blob via /api/v3 with error:

error: SendBlob: copy git cat-file stdout: Conn.Write wrote more than the declared Content-Length

See merge request !37
parents 55ce310d 275946fe
......@@ -38,6 +38,8 @@ func SendBlob(w http.ResponseWriter, r *http.Request, sendData string) {
}
defer helper.CleanUpProcessGroup(gitShowCmd)
// Ignore incorrect Content-Length that may have been set by Rails
w.Header().Del("Content-Length")
if _, err := io.Copy(w, stdout); err != nil {
helper.LogError(fmt.Errorf("SendBlob: copy git cat-file stdout: %v", err))
return
......
......@@ -563,8 +563,6 @@ func TestGetGitBlob(t *testing.T) {
responseJSON := fmt.Sprintf(`{"RepoPath":"%s","BlobId":"%s"}`, path.Join(testRepoRoot, testRepo), blobId)
encodedJSON := base64.StdEncoding.EncodeToString([]byte(responseJSON))
w.Header().Set(headerKey, "git-blob:"+encodedJSON)
// Prevent the Go HTTP server from setting the Content-Length to 0.
w.Header().Set("Transfer-Encoding", "chunked")
if _, err := fmt.Fprintf(w, "GNU General Public License"); err != nil {
t.Fatal(err)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment