You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2005/06/07 00:03:39 UTC

cvs commit: ws-axis/java/src/org/apache/axis/transport/http CommonsHTTPSender.java

dims        2005/06/06 15:03:39

  Modified:    java/src/org/apache/axis/transport/http
                        CommonsHTTPSender.java
  Log:
  Fix for AXIS-2033 - Bug with CommonsHttpClient and 1.2 final & 1.2.1 nigthly build. 1.2RC3 works fine!
  
  Chunking is *ON* by default for HTTP1.1. But you can switch it off using call/stub setproperty.
  
  Revision  Changes    Path
  1.33      +16 -2     ws-axis/java/src/org/apache/axis/transport/http/CommonsHTTPSender.java
  
  Index: CommonsHTTPSender.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/transport/http/CommonsHTTPSender.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- CommonsHTTPSender.java	21 Apr 2005 11:42:38 -0000	1.32
  +++ CommonsHTTPSender.java	6 Jun 2005 22:03:39 -0000	1.33
  @@ -29,6 +29,7 @@
   import org.apache.axis.soap.SOAPConstants;
   import org.apache.axis.utils.Messages;
   import org.apache.axis.utils.NetworkUtils;
  +import org.apache.axis.utils.JavaUtils;
   import org.apache.commons.httpclient.Cookie;
   import org.apache.commons.httpclient.Credentials;
   import org.apache.commons.httpclient.Header;
  @@ -82,6 +83,7 @@
       
       protected HttpConnectionManager connectionManager;
       protected CommonsHTTPClientProperties clientProperties;
  +    boolean httpChunkStream = true; //Use HTTP chunking or not.
       
       public CommonsHTTPSender() {
           initialize();
  @@ -154,7 +156,7 @@
                   addContextInfo(method, httpClient, msgContext, targetURL);
   
                   ((PostMethod)method).setRequestEntity(
  -                                               new MessageRequestEntity(method, reqMessage));
  +                                               new MessageRequestEntity(method, reqMessage, httpChunkStream));
               } else {
                   method = new GetMethod(targetURL.toString());
                   addContextInfo(method, httpClient, msgContext, targetURL);
  @@ -500,6 +502,11 @@
                       value.equalsIgnoreCase(HTTPConstants.HEADER_EXPECT_100_Continue)) {
                       method.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE,
                                                              true);
  +                } else if (key.equalsIgnoreCase(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED)) {
  +                    String val = me.getValue().toString();
  +                    if (null != val)  {
  +                        httpChunkStream = JavaUtils.isTrue(val);
  +                    }
                   } else {
                       method.addRequestHeader(key, value);
                   }
  @@ -727,12 +734,19 @@
           
           private HttpMethodBase method;
           private Message message;
  +        boolean httpChunkStream = true; //Use HTTP chunking or not.
   
           public MessageRequestEntity(HttpMethodBase method, Message message) {
               this.message = message;
               this.method = method;
           }
   
  +        public MessageRequestEntity(HttpMethodBase method, Message message, boolean httpChunkStream) {
  +            this.message = message;
  +            this.method = method;
  +            this.httpChunkStream = httpChunkStream;
  +        }
  +
           public boolean isRepeatable() {
               return true;
           }
  @@ -746,7 +760,7 @@
           }
   
           public long getContentLength() {
  -            if (this.method.getParams().getVersion() == HttpVersion.HTTP_1_0) {
  +            if (this.method.getParams().getVersion() == HttpVersion.HTTP_1_0 || !httpChunkStream) {
                   try {
                       return message.getContentLength();
                   } catch (Exception e) {