You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by li...@apache.org on 2009/10/31 01:01:39 UTC

svn commit: r831491 - /incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/BasicHttpFetcher.java

Author: lindner
Date: Sat Oct 31 00:01:39 2009
New Revision: 831491

URL: http://svn.apache.org/viewvc?rev=831491&view=rev
Log:
SHINDIG-1195 | BasicHttpFetcher requests compressed encoding on HEAD requests

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=831491&r1=831490&r2=831491&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 Sat Oct 31 00:01:39 2009
@@ -24,6 +24,7 @@
 import org.apache.commons.httpclient.methods.DeleteMethod;
 import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
 import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.HeadMethod;
 import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
 import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.commons.httpclient.methods.PutMethod;
@@ -162,6 +163,10 @@
       httpClient.getHostConfiguration().setProxy(address.getHostName(), address.getPort());
     }
 
+
+    // true for non-HEAD requests
+    boolean requestCompressedContent = true;
+
     if ("POST".equals(methodType) || "PUT".equals(methodType)) {
       EntityEnclosingMethod enclosingMethod = ("POST".equals(methodType))
               ? new PostMethod(requestUri)
@@ -175,13 +180,17 @@
       httpMethod = enclosingMethod;
     } else if ("DELETE".equals(methodType)) {
       httpMethod = new DeleteMethod(requestUri);
+    } else if ("HEAD".equals(methodType)) {
+      httpMethod = new HeadMethod(requestUri);
     } else {
       httpMethod = new GetMethod(requestUri);
     }
 
     httpMethod.setFollowRedirects(false);
     httpMethod.getParams().setSoTimeout(connectionTimeoutMs);
-    httpMethod.setRequestHeader("Accept-Encoding", "gzip, deflate");
+
+    if (requestCompressedContent)
+      httpMethod.setRequestHeader("Accept-Encoding", "gzip, deflate");
 
     for (Map.Entry<String, List<String>> entry : request.getHeaders().entrySet()) {
       httpMethod.setRequestHeader(entry.getKey(), StringUtils.join(entry.getValue(), ','));