From 7109dffceee4db7cabaa809687c29260bf30c4b7 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 17 Mar 2026 01:09:19 -0700 Subject: [PATCH] Match Go download throttle: return JSON error instead of plain text --- seaweed-volume/src/server/handlers.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/seaweed-volume/src/server/handlers.rs b/seaweed-volume/src/server/handlers.rs index d0767d415..29cdd90ba 100644 --- a/seaweed-volume/src/server/handlers.rs +++ b/seaweed-volume/src/server/handlers.rs @@ -695,6 +695,7 @@ async fn get_or_head_handler_inner( request: Request, ) -> Response { let path = request.uri().path().to_string(); + let raw_query = request.uri().query().map(|q| q.to_string()); let method = request.method().clone(); // JWT check for reads — must happen BEFORE path parsing to match Go behavior. @@ -792,7 +793,11 @@ async fn get_or_head_handler_inner( metrics::HANDLER_COUNTER .with_label_values(&[metrics::DOWNLOAD_LIMIT_COND]) .inc(); - return (StatusCode::TOO_MANY_REQUESTS, "download limit exceeded").into_response(); + return json_error_with_query( + StatusCode::TOO_MANY_REQUESTS, + "download limit exceeded", + raw_query.as_deref(), + ); } } // We'll set the actual bytes after reading the needle (once we know the size)