|
@@ -1,3 +1,29 @@
|
|
|
|
+/*
|
|
|
|
+ * 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 <http://www.gnu.org/licenses/>.
|
|
|
|
+ *
|
|
|
|
+ * 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;
|
|
package com.nextcloud.android.sso;
|
|
|
|
|
|
import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
|
|
import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
|
|
@@ -5,26 +31,16 @@ import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
|
|
import org.apache.commons.httpclient.methods.PostMethod;
|
|
import org.apache.commons.httpclient.methods.PostMethod;
|
|
import org.apache.commons.httpclient.methods.RequestEntity;
|
|
import org.apache.commons.httpclient.methods.RequestEntity;
|
|
import org.apache.commons.httpclient.util.EncodingUtil;
|
|
import org.apache.commons.httpclient.util.EncodingUtil;
|
|
-import org.apache.commons.logging.Log;
|
|
|
|
-import org.apache.commons.logging.LogFactory;
|
|
|
|
|
|
|
|
import java.util.Vector;
|
|
import java.util.Vector;
|
|
|
|
|
|
public class PatchMethod extends PostMethod {
|
|
public class PatchMethod extends PostMethod {
|
|
- // -------------------------------------------------------------- Constants
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Log object for this class.
|
|
|
|
- */
|
|
|
|
- private static final Log LOG = LogFactory.getLog(PatchMethod.class);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* The buffered request body consisting of <code>NameValuePair</code>s.
|
|
* The buffered request body consisting of <code>NameValuePair</code>s.
|
|
*/
|
|
*/
|
|
private Vector params = new Vector();
|
|
private Vector params = new Vector();
|
|
|
|
|
|
- // ----------------------------------------------------------- Constructors
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* No-arg constructor.
|
|
* No-arg constructor.
|
|
*/
|
|
*/
|
|
@@ -41,13 +57,10 @@ public class PatchMethod extends PostMethod {
|
|
super(uri);
|
|
super(uri);
|
|
}
|
|
}
|
|
|
|
|
|
- // ----------------------------------------------------- Instance Methods
|
|
|
|
-
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
- * Returns <tt>"POST"</tt>.
|
|
|
|
|
|
+ * Returns <tt>"PATCH"</tt>.
|
|
*
|
|
*
|
|
- * @return <tt>"POST"</tt>
|
|
|
|
|
|
+ * @return <tt>"PATCH"</tt>
|
|
* @since 2.0
|
|
* @since 2.0
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@@ -55,19 +68,13 @@ public class PatchMethod extends PostMethod {
|
|
return "PATCH";
|
|
return "PATCH";
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Returns <tt>true</tt> if there is a request body to be sent.
|
|
* Returns <tt>true</tt> if there is a request body to be sent.
|
|
*
|
|
*
|
|
- * <P>This method must be overwritten by sub-classes that implement
|
|
|
|
- * alternative request content input methods
|
|
|
|
- * </p>
|
|
|
|
- *
|
|
|
|
* @return boolean
|
|
* @return boolean
|
|
* @since 2.0beta1
|
|
* @since 2.0beta1
|
|
*/
|
|
*/
|
|
protected boolean hasRequestContent() {
|
|
protected boolean hasRequestContent() {
|
|
- LOG.trace("enter PatchMethod.hasRequestContent()");
|
|
|
|
if (!this.params.isEmpty()) {
|
|
if (!this.params.isEmpty()) {
|
|
return true;
|
|
return true;
|
|
} else {
|
|
} else {
|
|
@@ -75,22 +82,16 @@ public class PatchMethod extends PostMethod {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Clears request body.
|
|
* Clears request body.
|
|
*
|
|
*
|
|
- * <p>This method must be overwritten by sub-classes that implement
|
|
|
|
- * alternative request content input methods</p>
|
|
|
|
- *
|
|
|
|
* @since 2.0beta1
|
|
* @since 2.0beta1
|
|
*/
|
|
*/
|
|
protected void clearRequestBody() {
|
|
protected void clearRequestBody() {
|
|
- LOG.trace("enter PatchMethod.clearRequestBody()");
|
|
|
|
this.params.clear();
|
|
this.params.clear();
|
|
super.clearRequestBody();
|
|
super.clearRequestBody();
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Generates a request entity from the patch parameters, if present. Calls {@link
|
|
* Generates a request entity from the patch parameters, if present. Calls {@link
|
|
* EntityEnclosingMethod#generateRequestBody()} if parameters have not been set.
|
|
* EntityEnclosingMethod#generateRequestBody()} if parameters have not been set.
|