Skip to content

Commit 0399a07

Browse files
committed
Fix creating entity with dupe and file params
A boundary will not be written after the last file params. If there are additional dupe params, they do not get added to the entity properly. Switching the order and adding the file params last fixes this issue.
1 parent 7333a61 commit 0399a07

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/com/loopj/android/http/RequestParams.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,14 @@ public HttpEntity getEntity() {
236236
multipartEntity.addPart(entry.getKey(), entry.getValue());
237237
}
238238

239+
// Add dupe params
240+
for(ConcurrentHashMap.Entry<String, ArrayList<String>> entry : urlParamsWithArray.entrySet()) {
241+
ArrayList<String> values = entry.getValue();
242+
for (String value : values) {
243+
multipartEntity.addPart(entry.getKey(), value);
244+
}
245+
}
246+
239247
// Add file params
240248
int currentIndex = 0;
241249
int lastIndex = fileParams.entrySet().size() - 1;
@@ -252,14 +260,6 @@ public HttpEntity getEntity() {
252260
currentIndex++;
253261
}
254262

255-
// Add dupe params
256-
for(ConcurrentHashMap.Entry<String, ArrayList<String>> entry : urlParamsWithArray.entrySet()) {
257-
ArrayList<String> values = entry.getValue();
258-
for (String value : values) {
259-
multipartEntity.addPart(entry.getKey(), value);
260-
}
261-
}
262-
263263
entity = multipartEntity;
264264
} else {
265265
try {
@@ -318,4 +318,4 @@ public String getFileName() {
318318
}
319319
}
320320
}
321-
}
321+
}

0 commit comments

Comments
 (0)