Commit 275946fe authored by Jacob Vosmaer's avatar Jacob Vosmaer

Un set Content-Length for raw Git blobs

parent 55ce310d
...@@ -38,6 +38,8 @@ func SendBlob(w http.ResponseWriter, r *http.Request, sendData string) { ...@@ -38,6 +38,8 @@ func SendBlob(w http.ResponseWriter, r *http.Request, sendData string) {
} }
defer helper.CleanUpProcessGroup(gitShowCmd) 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 { if _, err := io.Copy(w, stdout); err != nil {
helper.LogError(fmt.Errorf("SendBlob: copy git cat-file stdout: %v", err)) helper.LogError(fmt.Errorf("SendBlob: copy git cat-file stdout: %v", err))
return return
......
...@@ -563,8 +563,6 @@ func TestGetGitBlob(t *testing.T) { ...@@ -563,8 +563,6 @@ func TestGetGitBlob(t *testing.T) {
responseJSON := fmt.Sprintf(`{"RepoPath":"%s","BlobId":"%s"}`, path.Join(testRepoRoot, testRepo), blobId) responseJSON := fmt.Sprintf(`{"RepoPath":"%s","BlobId":"%s"}`, path.Join(testRepoRoot, testRepo), blobId)
encodedJSON := base64.StdEncoding.EncodeToString([]byte(responseJSON)) encodedJSON := base64.StdEncoding.EncodeToString([]byte(responseJSON))
w.Header().Set(headerKey, "git-blob:"+encodedJSON) 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 { if _, err := fmt.Fprintf(w, "GNU General Public License"); err != nil {
t.Fatal(err) 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