commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java
Date Fri, 11 Jul 2003 20:23:30 GMT
olegk       2003/07/11 13:23:30

  Modified:    httpclient/src/java/org/apache/commons/httpclient Tag:
                        HTTPCLIENT_2_0_BRANCH HttpMethodBase.java
  Log:
  One more try at handling non chunked transfer encodings.
  PR: 21378
  Submitted by Oleg Kalnichevski
  Reviewed by Michael Becke
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.159.2.3 +19 -21    jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java
  
  Index: HttpMethodBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
  retrieving revision 1.159.2.2
  retrieving revision 1.159.2.3
  diff -u -r1.159.2.2 -r1.159.2.3
  --- HttpMethodBase.java	8 Jul 2003 22:05:25 -0000	1.159.2.2
  +++ HttpMethodBase.java	11 Jul 2003 20:23:29 -0000	1.159.2.3
  @@ -71,6 +71,7 @@
   import java.util.BitSet;
   import java.util.HashSet;
   import java.util.Set;
  +
   import org.apache.commons.httpclient.auth.AuthScheme;
   import org.apache.commons.httpclient.auth.AuthenticationException;
   import org.apache.commons.httpclient.auth.HttpAuthenticator;
  @@ -2041,26 +2042,23 @@
               is = new WireLogInputStream(is);
           }
           InputStream result = null;
  -        Header[] transferEncodingHeaders = responseHeaders.getHeaders("Transfer-Encoding");
  +        Header transferEncodingHeader = responseHeaders.getFirstHeader("Transfer-Encoding");
           // We use Transfer-Encoding if present and ignore Content-Length.
           // RFC2616, 4.4 item number 3
  -        if (transferEncodingHeaders.length > 0) {
  -            boolean containsChunked = false;
  -            for (int i = 0; i < transferEncodingHeaders.length; i++) {
  -                String encoding = transferEncodingHeaders[i].getValue();
  -                if ("chunked".equalsIgnoreCase(encoding)) {
  -                    containsChunked = true;
  -                    break;
  -                } else if ("identity".equalsIgnoreCase(encoding)) {
  -                    //No content transformation needed
  -                } else {
  -                    if (LOG.isWarnEnabled()) {
  -                        LOG.warn("Unsupported transfer encoding: " + encoding);
  -                    }
  +        if (transferEncodingHeader != null) {
  +
  +            String transferEncoding = transferEncodingHeader.getValue();
  +            if (!"chunked".equalsIgnoreCase(transferEncoding) && 
  +                !"identity".equalsIgnoreCase(transferEncoding)) {
  +                if (LOG.isWarnEnabled()) {
  +                    LOG.warn("Unsupported transfer encoding: " + transferEncoding);
                   }
               }
  -            if (containsChunked) {
  -                // Some HTTP servers do not bother sending a closing chunk 
  +            HeaderElement[] encodings = transferEncodingHeader.getValues();
  +            // The chunck encoding must be the last one applied
  +            // RFC2616, 14.41
  +            int len = encodings.length;            
  +            if ((len > 0) && ("chunked".equalsIgnoreCase(encodings[len - 1].getName()
))) { 
                   // if response body is empty
                   if (conn.isResponseAvailable(conn.getSoTimeout())) {
                       result = new ChunkedInputStream(is, this);
  @@ -2074,7 +2072,7 @@
               } else {
                   if (isStrictMode() && LOG.isWarnEnabled()) {
                       LOG.warn("Transfer-Encoding is set but does not contain \"chunked\":
"
  -                        + getResponseHeader("Transfer-Encoding"));
  +                        + transferEncoding);
                   }
                   // The connection must be terminated by closing 
                   // the socket as per RFC 2616, 3.6
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message