XFire
  1. XFire
  2. XFIRE-467

CLONE -Added optional gzip content encoding support to CommonsHttpMessageSender.

    Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Duplicate
    • Affects Version/s: 1.1
    • Fix Version/s: 1.2-RC
    • Component/s: Core
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Added optional gzip content encoding support to CommonsHttpMessageSender. To enable set the property CommonsHttpMessageSender.GZIP_ENABLED to Boolean true. When enabled all requests will have the header Accept-Encoding set to 'gzip' and responses with or without Content-Encoding set to 'gzip' will be handled appropriately. Outgoing requests will not be compressed.

      The patch:

      Index: E:/work/eclipseworkspace/xfire/xfire-core/src/main/org/codehaus/xfire/transport/http/CommonsHttpMessageSender.java
      ===================================================================
      --- E:/work/eclipseworkspace/xfire/xfire-core/src/main/org/codehaus/xfire/transport/http/CommonsHttpMessageSender.java	(revision 1590)
      +++ E:/work/eclipseworkspace/xfire/xfire-core/src/main/org/codehaus/xfire/transport/http/CommonsHttpMessageSender.java	(working copy)
      @@ -3,9 +3,11 @@
       import java.io.ByteArrayOutputStream;
       import java.io.IOException;
       import java.io.InputStream;
      +import java.util.zip.GZIPInputStream;
       
       import javax.activation.DataHandler;
       
      +import org.apache.commons.httpclient.Header;
       import org.apache.commons.httpclient.HttpClient;
       import org.apache.commons.httpclient.HttpException;
       import org.apache.commons.httpclient.HttpState;
      @@ -46,6 +48,8 @@
           private HttpClient client;
       
           private HttpState state;
      +    
      +    private static final String GZIP = "gzip";
       
           public static final String HTTP_CLIENT_PARAMS = "httpClient.params";
           public static final String USER_AGENT =  
      @@ -54,6 +58,7 @@
           public static final String HTTP_PROXY_PORT = "http.proxyPort";
           public static final String HTTP_STATE = "httpClient.httpstate";
           public static final String HTTP_CLIENT = "httpClient";
      +    public static final String GZIP_ENABLED = "gzip.enabled";
           
           public CommonsHttpMessageSender(OutMessage message, MessageContext context)
           {
      @@ -140,6 +145,14 @@
               {
                   postMethod.setRequestHeader("Content-Type", HttpChannel.getSoapMimeType(getMessage()));
               }
      +        Object o = context.getContextualProperty(GZIP_ENABLED);
      +        if(null != o)
      +        {
      +	          if(((Boolean)o).booleanValue())
      +	          {
      +		            postMethod.setRequestHeader("Accept-Encoding", GZIP);
      +	          }
      +        }
           }
       
           public void send()
      @@ -215,7 +228,23 @@
               throws IOException
           {
               String ct = postMethod.getResponseHeader("Content-Type").getValue();
      -        InputStream in = postMethod.getResponseBodyAsStream();
      +        Header hce = postMethod.getResponseHeader("Content-Encoding");
      +        InputStream in = null;
      +        if(null != hce)
      +        {
      +	          if(hce.getValue().equals(GZIP))
      +	          {
      +		            in = new GZIPInputStream(postMethod.getResponseBodyAsStream());
      +	          }
      +	          else
      +	          {
      +		            //better hope this never happens
      +	          }
      +        }
      +        else
      +        {
      +            in = postMethod.getResponseBodyAsStream();
      +        }
               if (ct.toLowerCase().indexOf("multipart/related") != -1)
               {
                   Attachments atts = new StreamedAttachments(in, ct);
      

        Activity

        Hide
        Gum Shoe added a comment -

        Tried to clone in order to change the affected version to 1.1.1 but no luck.

        Show
        Gum Shoe added a comment - Tried to clone in order to change the affected version to 1.1.1 but no luck.

          People

          • Assignee:
            Dan Diephouse
            Reporter:
            Gum Shoe
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: