fix(lfs): accept successful transfer responses (#38866)

Accept all 2xx LFS transfer responses so uploads returning 201 Created
are not handled as errors and decoded as empty error bodies.

Fixes https://github.com/go-gitea/gitea/issues/38865.
---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Pachink0
2026-08-11 11:47:20 +02:00
committed by GitHub
parent 88b2b84cf0
commit eeeb5d7c7b
2 changed files with 11 additions and 2 deletions
+9
View File
@@ -135,6 +135,15 @@ func TestBasicTransferAdapter(t *testing.T) {
}
})
t.Run("Upload created", func(t *testing.T) {
client := &http.Client{Transport: RoundTripFunc(func(req *http.Request) *http.Response {
return &http.Response{StatusCode: http.StatusCreated, Body: io.NopCloser(strings.NewReader(""))}
})}
adapter := &BasicTransferAdapter{client: client}
err := adapter.Upload(t.Context(), &Link{Href: "https://upload-created-request.io"}, p, strings.NewReader("dummy"))
assert.NoError(t, err)
})
t.Run("Verify", func(t *testing.T) {
cases := []struct {
link *Link