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

Backport #38866 by @Pachinko0

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.

----

Co-authored-by: waterWang <waterWang@users.noreply.github.com>

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Pachink0 <55147665+Pachinko0@users.noreply.github.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Giteabot
2026-08-11 09:43:05 -07:00
committed by GitHub
co-authored by waterWang Pachink0 wxiaoguang
parent 21fda8f5be
commit 51938de973
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