@@ -99,6 +99,7 @@ public class RequestParams implements Serializable {
99
99
100
100
protected final static String LOG_TAG = "RequestParams" ;
101
101
protected boolean isRepeatable ;
102
+ protected boolean forceMultipartEntity = false ;
102
103
protected boolean useJsonStreamer ;
103
104
protected String elapsedFieldInJsonStreamer = "_elapsed" ;
104
105
protected boolean autoCloseInputStreams ;
@@ -122,6 +123,18 @@ public void setContentEncoding(final String encoding) {
122
123
}
123
124
}
124
125
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
+
125
138
/**
126
139
* Constructs a new empty {@code RequestParams} instance.
127
140
*/
@@ -456,7 +469,7 @@ public void setAutoCloseInputStreams(boolean flag) {
456
469
public HttpEntity getEntity (ResponseHandlerInterface progressHandler ) throws IOException {
457
470
if (useJsonStreamer ) {
458
471
return createJsonStreamerEntity (progressHandler );
459
- } else if (streamParams .isEmpty () && fileParams .isEmpty ()) {
472
+ } else if (! forceMultipartEntity && streamParams .isEmpty () && fileParams .isEmpty ()) {
460
473
return createFormEntity ();
461
474
} else {
462
475
return createMultipartEntity (progressHandler );
@@ -465,9 +478,9 @@ public HttpEntity getEntity(ResponseHandlerInterface progressHandler) throws IOE
465
478
466
479
private HttpEntity createJsonStreamerEntity (ResponseHandlerInterface progressHandler ) throws IOException {
467
480
JsonStreamerEntity entity = new JsonStreamerEntity (
468
- progressHandler ,
469
- !fileParams .isEmpty () || !streamParams .isEmpty (),
470
- elapsedFieldInJsonStreamer );
481
+ progressHandler ,
482
+ !fileParams .isEmpty () || !streamParams .isEmpty (),
483
+ elapsedFieldInJsonStreamer );
471
484
472
485
// Add string params
473
486
for (ConcurrentHashMap .Entry <String , String > entry : urlParams .entrySet ()) {
0 commit comments