diff --git a/nginx_request_checker.py b/nginx_request_checker.py index c65c992..eeadc8e 100644 --- a/nginx_request_checker.py +++ b/nginx_request_checker.py @@ -63,16 +63,30 @@ async def proxy_request(path: str, request: Request): return Response(content=error_xml, status_code=403, media_type="application/xml") # Proxy request to MinIO + minio_url = f"{MINIO_ENDPOINT}/{path}" + headers = dict(request.headers) + async with httpx.AsyncClient(timeout=300.0) as client: - minio_url = f"{MINIO_ENDPOINT}/{path}" - headers = dict(request.headers) - body = await request.body() - logging.info(f"Proxying request to MinIO: {minio_url}") + if request.method in ["PUT", "POST"]: + # Stream request body to MinIO + async def request_stream(): + async for chunk in request.stream(): + yield chunk - minio_response = await client.request( - method=request.method, url=minio_url, headers=headers, content=body - ) + minio_response = await client.request( + method=request.method, + url=minio_url, + headers=headers, + content=request_stream() + ) + else: + # For GET and DELETE, we don’t send a body + minio_response = await client.request( + method=request.method, + url=minio_url, + headers=headers + ) logging.info(f"MinIO response: {minio_response.status_code}")