From 8087f1d06a4e711152b0621ca97a6bbafe917a49 Mon Sep 17 00:00:00 2001 From: dipshit-enterprises <160212554+dipshit-enterprises@users.noreply.github.com> Date: Thu, 4 Jul 2024 16:15:22 -0700 Subject: [PATCH] Set content-length to -1 for InputStream request bodies This prevents large request bodies from crashing the app. Without this the entire request body would be buffered and the app would out of memory. Signed-off-by: dipshit-enterprises <160212554+dipshit-enterprises@users.noreply.github.com> --- .../java/com/nextcloud/android/sso/InputStreamBinder.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/nextcloud/android/sso/InputStreamBinder.java b/app/src/main/java/com/nextcloud/android/sso/InputStreamBinder.java index 22195227bb..d04ac9ab4d 100644 --- a/app/src/main/java/com/nextcloud/android/sso/InputStreamBinder.java +++ b/app/src/main/java/com/nextcloud/android/sso/InputStreamBinder.java @@ -237,7 +237,7 @@ public class InputStreamBinder extends IInputStreamService.Stub { case "POST": method = new PostMethod(requestUrl); if (requestBodyInputStream != null) { - RequestEntity requestEntity = new InputStreamRequestEntity(requestBodyInputStream); + RequestEntity requestEntity = new InputStreamRequestEntity(requestBodyInputStream, -1); ((PostMethod) method).setRequestEntity(requestEntity); } else if (request.getRequestBody() != null) { StringRequestEntity requestEntity = new StringRequestEntity( @@ -251,7 +251,7 @@ public class InputStreamBinder extends IInputStreamService.Stub { case "PATCH": method = new PatchMethod(requestUrl); if (requestBodyInputStream != null) { - RequestEntity requestEntity = new InputStreamRequestEntity(requestBodyInputStream); + RequestEntity requestEntity = new InputStreamRequestEntity(requestBodyInputStream, -1); ((PatchMethod) method).setRequestEntity(requestEntity); } else if (request.getRequestBody() != null) { StringRequestEntity requestEntity = new StringRequestEntity( @@ -265,7 +265,7 @@ public class InputStreamBinder extends IInputStreamService.Stub { case "PUT": method = new PutMethod(requestUrl); if (requestBodyInputStream != null) { - RequestEntity requestEntity = new InputStreamRequestEntity(requestBodyInputStream); + RequestEntity requestEntity = new InputStreamRequestEntity(requestBodyInputStream, -1); ((PutMethod) method).setRequestEntity(requestEntity); } else if (request.getRequestBody() != null) { StringRequestEntity requestEntity = new StringRequestEntity(