Skip to content

Commit 8f396c8

Browse files
committed
Not setting Content-Type if HttpEntity was set, as it breaks eg. multipart/form-data boundaries
1 parent f391839 commit 8f396c8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

library/src/main/java/com/loopj/android/http/AsyncHttpClient.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,11 @@ protected RequestHandle sendRequest(DefaultHttpClient client, HttpContext httpCo
11481148
}
11491149

11501150
if (contentType != null) {
1151-
uriRequest.setHeader(HEADER_CONTENT_TYPE, contentType);
1151+
if (uriRequest instanceof HttpEntityEnclosingRequestBase && ((HttpEntityEnclosingRequestBase) uriRequest).getEntity() != null) {
1152+
Log.w(LOG_TAG, "Passed contentType will be ignored because HttpEntity sets content type");
1153+
} else {
1154+
uriRequest.setHeader(HEADER_CONTENT_TYPE, contentType);
1155+
}
11521156
}
11531157

11541158
responseHandler.setRequestHeaders(uriRequest.getAllHeaders());

0 commit comments

Comments
 (0)