@@ -99,6 +99,7 @@ public class RequestParams implements Serializable {
9999
100100 protected final static String LOG_TAG = "RequestParams" ;
101101 protected boolean isRepeatable ;
102+ protected boolean forceMultipartEntity = false ;
102103 protected boolean useJsonStreamer ;
103104 protected String elapsedFieldInJsonStreamer = "_elapsed" ;
104105 protected boolean autoCloseInputStreams ;
@@ -122,6 +123,18 @@ public void setContentEncoding(final String encoding) {
122123 }
123124 }
124125
126+ /**
127+ * If set to true will force Content-Type header to `multipart/form-data`
128+ * even if there are not Files or Streams to be send
129+ *
130+ * Default value is false
131+ *
132+ * @param force boolean, should declare content-type multipart/form-data even without files or streams present
133+ */
134+ public void setForceMultipartEntityContentType (boolean force ) {
135+ this .forceMultipartEntity = force ;
136+ }
137+
125138 /**
126139 * Constructs a new empty {@code RequestParams} instance.
127140 */
@@ -456,7 +469,7 @@ public void setAutoCloseInputStreams(boolean flag) {
456469 public HttpEntity getEntity (ResponseHandlerInterface progressHandler ) throws IOException {
457470 if (useJsonStreamer ) {
458471 return createJsonStreamerEntity (progressHandler );
459- } else if (streamParams .isEmpty () && fileParams .isEmpty ()) {
472+ } else if (! forceMultipartEntity && streamParams .isEmpty () && fileParams .isEmpty ()) {
460473 return createFormEntity ();
461474 } else {
462475 return createMultipartEntity (progressHandler );
@@ -465,9 +478,9 @@ public HttpEntity getEntity(ResponseHandlerInterface progressHandler) throws IOE
465478
466479 private HttpEntity createJsonStreamerEntity (ResponseHandlerInterface progressHandler ) throws IOException {
467480 JsonStreamerEntity entity = new JsonStreamerEntity (
468- progressHandler ,
469- !fileParams .isEmpty () || !streamParams .isEmpty (),
470- elapsedFieldInJsonStreamer );
481+ progressHandler ,
482+ !fileParams .isEmpty () || !streamParams .isEmpty (),
483+ elapsedFieldInJsonStreamer );
471484
472485 // Add string params
473486 for (ConcurrentHashMap .Entry <String , String > entry : urlParams .entrySet ()) {
0 commit comments