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:
Android (Google) Code Review
2009-05-11 10:11:50 -07:00

View File

@@ -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());