Skip to content

Commit

Permalink
fix: allow DELETE method requests to send body (#2571)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregataa authored Jul 31, 2024
1 parent 187cf9e commit 95c7dc8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changes/2571.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Add POST `/folders` API endpoints to replace DELETE APIs that require request body.
* Allow `DELETE` requests to have body data.
2 changes: 1 addition & 1 deletion src/ai/backend/manager/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ async def wrapped(request: web.Request, *args: P.args, **kwargs: P.kwargs) -> TA
body: str = ""
try:
body_exists = request.can_read_body
if body_exists and request.method not in ("GET", "DELETE", "HEAD"):
if body_exists and request.method not in ("GET", "HEAD"):
body = await request.text()
if request.content_type == "text/yaml":
orig_params = yaml.load(body, Loader=yaml.BaseLoader)
Expand Down
4 changes: 4 additions & 0 deletions src/ai/backend/manager/api/vfolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3511,13 +3511,15 @@ def create_app(default_cors_options):
cors.add(add_route("POST", r"/{name}/request-download", create_download_session))
cors.add(add_route("POST", r"/{name}/move-file", move_file))
cors.add(add_route("POST", r"/{name}/rename-file", rename_file))
cors.add(add_route("POST", r"/{name}/delete-files", delete_files))
cors.add(add_route("DELETE", r"/{name}/delete-files", delete_files))
cors.add(add_route("POST", r"/{name}/rename_file", rename_file)) # legacy underbar
cors.add(add_route("DELETE", r"/{name}/delete_files", delete_files)) # legacy underbar
cors.add(add_route("GET", r"/{name}/files", list_files))
cors.add(add_route("POST", r"/{name}/invite", invite))
cors.add(add_route("POST", r"/{name}/leave", leave))
cors.add(add_route("POST", r"/{name}/share", share))
cors.add(add_route("POST", r"/{name}/unshare", unshare))
cors.add(add_route("DELETE", r"/{name}/unshare", unshare))
cors.add(add_route("POST", r"/{name}/clone", clone))
cors.add(add_route("POST", r"/purge", purge))
Expand All @@ -3528,12 +3530,14 @@ def create_app(default_cors_options):
cors.add(add_route("POST", r"/invitations/update/{inv_id}", update_invitation))
cors.add(add_route("GET", r"/invitations/list", invitations))
cors.add(add_route("POST", r"/invitations/accept", accept_invitation))
cors.add(add_route("POST", r"/invitations/delete", delete_invitation))
cors.add(add_route("DELETE", r"/invitations/delete", delete_invitation))
cors.add(add_route("GET", r"/_/shared", list_shared_vfolders))
cors.add(add_route("POST", r"/_/shared", update_shared_vfolder))
cors.add(add_route("GET", r"/_/fstab", get_fstab_contents))
cors.add(add_route("GET", r"/_/mounts", list_mounts))
cors.add(add_route("POST", r"/_/mounts", mount_host))
cors.add(add_route("POST", r"/_/umounts", umount_host))
cors.add(add_route("DELETE", r"/_/mounts", umount_host))
cors.add(add_route("POST", r"/_/change-ownership", change_vfolder_ownership))
cors.add(add_route("GET", r"/_/quota", get_quota))
Expand Down

0 comments on commit 95c7dc8

Please sign in to comment.