Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

fix(http): accept no content delete responses (#9893)

7y-9a9e4995d762d
diff --git a/weed/util/http/http_global_client_util.go b/weed/util/http/http_global_client_util.go
index a8adddb104..dc778b56e1 100644
--- a/weed/util/http/http_global_client_util.go
+++ b/weed/util/http/http_global_client_util.go
@@ -172,7 +172,7 @@ func Delete(url string, jwt string) error {
return err
}
switch resp.StatusCode {
- case http.StatusNotFound, http.StatusAccepted, http.StatusOK:
+ case http.StatusNotFound, http.StatusNoContent, http.StatusAccepted, http.StatusOK:
return nil
}
m := make(map[string]interface{})
diff --git a/weed/util/http/http_global_client_util_test.go b/weed/util/http/http_global_client_util_test.go
index 487d23768a..74b1035593 100644
--- a/weed/util/http/http_global_client_util_test.go
+++ b/weed/util/http/http_global_client_util_test.go
@@ -103,6 +103,24 @@ func TestDeleteReturnsInvalidRequestErrorBeforeAddingAuth(t *testing.T) {
}
}
+func TestDeleteTreatsNoContentAsSuccess(t *testing.T) {
+ InitGlobalHttpClient()
+
+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if r.Method != http.MethodDelete {
+ t.Errorf("expected DELETE, got %s", r.Method)
+ w.WriteHeader(http.StatusBadRequest)
+ return
+ }
+ w.WriteHeader(http.StatusNoContent)
+ }))
+ defer server.Close()
+
+ if err := Delete(server.URL, ""); err != nil {
+ t.Fatalf("expected 204 DELETE to succeed, got %v", err)
+ }
+}
+
func TestDeleteProxiedReturnsInvalidRequestErrorBeforeAddingAuth(t *testing.T) {
defer func() {
if r := recover(); r != nil {