Author: lryan
Date: Thu Apr 23 00:12:20 2009
New Revision: 767735
URL: http://svn.apache.org/viewvc?rev=767735&view=rev
Log:
Only set Content-Length if there is a content body. Some web-servers were
rejecting GET requests with a Content-Length:0
Modified:
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/BasicHttpFetcher.java
Modified:
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/BasicHttpFetcher.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/BasicHttpFetcher.java?rev=767735&r1=767734&r2=767735&view=diff
==============================================================================
---
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/BasicHttpFetcher.java
(original)
+++
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/BasicHttpFetcher.java
Thu Apr 23 00:12:20 2009
@@ -175,8 +175,9 @@
if (request.getPostBodyLength() > 0) {
enclosingMethod.setRequestEntity(new
InputStreamRequestEntity(request.getPostBody()));
+ enclosingMethod.setRequestHeader("Content-Length",
+ String.valueOf(request.getPostBodyLength()));
}
-
httpMethod = enclosingMethod;
} else if ("DELETE".equals(methodType)) {
httpMethod = new DeleteMethod(requestUri);
@@ -186,7 +187,6 @@
httpMethod.setFollowRedirects(false);
httpMethod.getParams().setSoTimeout(connectionTimeoutMs);
- httpMethod.setRequestHeader("Content-Length",
String.valueOf(request.getPostBodyLength()));
httpMethod.setRequestHeader("Accept-Encoding", "gzip, deflate");
for (Map.Entry<String, List<String>> entry :
request.getHeaders().entrySet()) {