Skip to content

Commit f37caf9

Browse files
Merge pull request Kong#131 from orlingueorguievivu/patch-1
Potential fix for Kong#87
2 parents 6ae7905 + 7eeea8a commit f37caf9

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

src/main/java/com/mashape/unirest/request/body/MultipartBody.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ a copy of this software and associated documentation files (the
3434
import java.util.LinkedList;
3535
import java.util.List;
3636
import java.util.Map;
37+
import java.util.LinkedHashMap;
3738

3839
import org.apache.http.HttpEntity;
3940
import org.apache.http.client.entity.UrlEncodedFormEntity;
@@ -51,9 +52,7 @@ a copy of this software and associated documentation files (the
5152
import com.mashape.unirest.request.HttpRequest;
5253

5354
public 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

Comments
 (0)