Merge change 1324
* changes: Fix #1807059. If it is "POST", always use BasicHttpEntityEnclosingRequest even bodyProvider is null. This ensures the content-type, content-encoding and content-length are set correctly.
This commit is contained in:
@@ -116,12 +116,17 @@ class Request {
|
||||
mBodyProvider = bodyProvider;
|
||||
mBodyLength = bodyLength;
|
||||
|
||||
if (bodyProvider == null) {
|
||||
if (bodyProvider == null && !"POST".equalsIgnoreCase(method)) {
|
||||
mHttpRequest = new BasicHttpRequest(method, getUri());
|
||||
} else {
|
||||
mHttpRequest = new BasicHttpEntityEnclosingRequest(
|
||||
method, getUri());
|
||||
setBodyProvider(bodyProvider, bodyLength);
|
||||
// it is ok to have null entity for BasicHttpEntityEnclosingRequest.
|
||||
// By using BasicHttpEntityEnclosingRequest, it will set up the
|
||||
// correct content-length, content-type and content-encoding.
|
||||
if (bodyProvider != null) {
|
||||
setBodyProvider(bodyProvider, bodyLength);
|
||||
}
|
||||
}
|
||||
addHeader(HOST_HEADER, getHostPort());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user