diff --git a/scripts/analysis/findbugs-results.txt b/scripts/analysis/findbugs-results.txt
index 1b6db1e86340..a8114de9cfe6 100644
--- a/scripts/analysis/findbugs-results.txt
+++ b/scripts/analysis/findbugs-results.txt
@@ -1 +1 @@
-460
\ No newline at end of file
+462
\ No newline at end of file
diff --git a/src/main/java/com/nextcloud/android/sso/InputStreamBinder.java b/src/main/java/com/nextcloud/android/sso/InputStreamBinder.java
index 386b497faaef..2d05af31f7c5 100644
--- a/src/main/java/com/nextcloud/android/sso/InputStreamBinder.java
+++ b/src/main/java/com/nextcloud/android/sso/InputStreamBinder.java
@@ -263,6 +263,20 @@ private HttpMethodBase buildMethod(NextcloudRequest request, Uri baseUri, InputS
}
break;
+ case "PATCH":
+ method = new PatchMethod(requestUrl);
+ if (requestBodyInputStream != null) {
+ RequestEntity requestEntity = new InputStreamRequestEntity(requestBodyInputStream);
+ ((PatchMethod) method).setRequestEntity(requestEntity);
+ } else if (request.getRequestBody() != null) {
+ StringRequestEntity requestEntity = new StringRequestEntity(
+ request.getRequestBody(),
+ CONTENT_TYPE_APPLICATION_JSON,
+ CHARSET_UTF8);
+ ((PatchMethod) method).setRequestEntity(requestEntity);
+ }
+ break;
+
case "PUT":
method = new PutMethod(requestUrl);
if (requestBodyInputStream != null) {
@@ -298,8 +312,8 @@ private HttpMethodBase buildMethod(NextcloudRequest request, Uri baseUri, InputS
break;
case "HEAD":
- method = new HeadMethod(requestUrl);
- break;
+ method = new HeadMethod(requestUrl);
+ break;
default:
throw new UnsupportedOperationException(EXCEPTION_UNSUPPORTED_METHOD);
diff --git a/src/main/java/com/nextcloud/android/sso/PatchMethod.java b/src/main/java/com/nextcloud/android/sso/PatchMethod.java
new file mode 100644
index 000000000000..fb0cbe724fd2
--- /dev/null
+++ b/src/main/java/com/nextcloud/android/sso/PatchMethod.java
@@ -0,0 +1,118 @@
+/*
+ * Nextcloud SingleSignOn
+ *
+ * @author Timo Triebensky
+ * Copyright (C) 2021 Timo Triebensky
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * More information here: https://github.com/abeluck/android-streams-ipc
+ *
+ * ====================================================================
+ *
+ * The required methods of this class are copied and customized from PostMethod.
+ */
+
+package com.nextcloud.android.sso;
+
+import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
+import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.RequestEntity;
+import org.apache.commons.httpclient.util.EncodingUtil;
+
+import java.util.Vector;
+
+public class PatchMethod extends PostMethod {
+
+ /**
+ * The buffered request body consisting of NameValuePair
s.
+ */
+ private Vector params = new Vector();
+
+ /**
+ * No-arg constructor.
+ */
+ public PatchMethod() {
+ super();
+ }
+
+ /**
+ * Constructor specifying a URI.
+ *
+ * @param uri either an absolute or relative URI
+ */
+ public PatchMethod(String uri) {
+ super(uri);
+ }
+
+ /**
+ * Returns "PATCH".
+ *
+ * @return "PATCH"
+ * @since 2.0
+ */
+ @Override
+ public String getName() {
+ return "PATCH";
+ }
+
+ /**
+ * Returns true if there is a request body to be sent.
+ *
+ * @return boolean
+ * @since 2.0beta1
+ */
+ protected boolean hasRequestContent() {
+ if (!this.params.isEmpty()) {
+ return true;
+ } else {
+ return super.hasRequestContent();
+ }
+ }
+
+ /**
+ * Clears request body.
+ *
+ * @since 2.0beta1
+ */
+ protected void clearRequestBody() {
+ this.params.clear();
+ super.clearRequestBody();
+ }
+
+ /**
+ * Generates a request entity from the patch parameters, if present. Calls {@link
+ * EntityEnclosingMethod#generateRequestBody()} if parameters have not been set.
+ *
+ * @since 3.0
+ */
+ protected RequestEntity generateRequestEntity() {
+ if (!this.params.isEmpty()) {
+ // Use a ByteArrayRequestEntity instead of a StringRequestEntity.
+ // This is to avoid potential encoding issues. Form url encoded strings
+ // are ASCII by definition but the content type may not be. Treating the content
+ // as bytes allows us to keep the current charset without worrying about how
+ // this charset will effect the encoding of the form url encoded string.
+ String content = EncodingUtil.formUrlEncode(getParameters(), getRequestCharSet());
+ ByteArrayRequestEntity entity = new ByteArrayRequestEntity(
+ EncodingUtil.getAsciiBytes(content),
+ FORM_URL_ENCODED_CONTENT_TYPE
+ );
+ return entity;
+ } else {
+ return super.generateRequestEntity();
+ }
+ }
+}