@@ -34,6 +34,7 @@ a copy of this software and associated documentation files (the
3434import java .util .LinkedList ;
3535import java .util .List ;
3636import java .util .Map ;
37+ import java .util .LinkedHashMap ;
3738
3839import org .apache .http .HttpEntity ;
3940import org .apache .http .client .entity .UrlEncodedFormEntity ;
@@ -51,9 +52,7 @@ a copy of this software and associated documentation files (the
5152import com .mashape .unirest .request .HttpRequest ;
5253
5354public class MultipartBody extends BaseRequest implements Body {
54-
55- private List <String > keyOrder = new ArrayList <String >();
56- private Map <String , List <Object >> parameters = new HashMap <String , List <Object >>();
55+ private Map <String , List <Object >> parameters = new LinkedHashMap <String , List <Object >>();
5756 private Map <String , ContentType > contentTypes = new HashMap <String , ContentType >();
5857
5958 private boolean hasFile ;
@@ -90,8 +89,6 @@ public MultipartBody field(String name, Object value, boolean file) {
9089 }
9190
9291 public MultipartBody field (String name , Object value , boolean file , String contentType ) {
93- keyOrder .add (name );
94-
9592 List <Object > list = parameters .get (name );
9693 if (list == null )
9794 list = new LinkedList <Object >();
@@ -155,7 +152,7 @@ public HttpEntity getEntity() {
155152 if (mode != null ) {
156153 builder .setMode (HttpMultipartMode .BROWSER_COMPATIBLE );
157154 }
158- for (String key : keyOrder ) {
155+ for (String key : parameters . keySet () ) {
159156 List <Object > value = parameters .get (key );
160157 ContentType contentType = contentTypes .get (key );
161158 for (Object cur : value ) {
0 commit comments