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 ConnectMethod.java HttpMethodBase.java
Date Mon, 28 Apr 2003 20:39:40 GMT
olegk       2003/04/28 13:39:39

  Modified:    httpclient/src/java/org/apache/commons/httpclient
                        ConnectMethod.java HttpMethodBase.java
  Log:
  Proxy connection keep-alive fix
  
  Contributed by Oleg Kalnichevski
  
  Revision  Changes    Path
  1.13      +5 -4      jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ConnectMethod.java
  
  Index: ConnectMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ConnectMethod.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ConnectMethod.java	25 Apr 2003 18:03:28 -0000	1.12
  +++ ConnectMethod.java	28 Apr 2003 20:39:39 -0000	1.13
  @@ -186,6 +186,7 @@
           addUserAgentRequestHeader(state, conn);
           addHostRequestHeader(state, conn);
           addProxyAuthorizationRequestHeader(state, conn);
  +        addProxyConnectionHeader(state, conn);
       }
   
       /**
  
  
  
  1.140     +37 -6     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.139
  retrieving revision 1.140
  diff -u -r1.139 -r1.140
  --- HttpMethodBase.java	27 Apr 2003 19:43:41 -0000	1.139
  +++ HttpMethodBase.java	28 Apr 2003 20:39:39 -0000	1.140
  @@ -1532,6 +1532,27 @@
       }
   
       /**
  +     * Adds a <tt>Proxy-Connection: Keep-Alive</tt> request when 
  +     * communicating via a proxy server.
  +     *
  +     * @param state current state of http requests
  +     * @param conn the connection to use for I/O
  +     *
  +     * @throws IOException when errors occur reading or writing to/from the
  +     *         connection
  +     * @throws HttpException when a recoverable error occurs
  +     */
  +    protected void addProxyConnectionHeader(HttpState state,
  +                                            HttpConnection conn)
  +    throws IOException, HttpException {
  +        LOG.trace("enter HttpMethodBase.addProxyConnectionHeader("
  +                  + "HttpState, HttpConnection)");
  +        if (!conn.isTransparent()) {
  +            setRequestHeader("Proxy-Connection", "Keep-Alive");
  +        }
  +    }
  +
  +    /**
        * Populates the request headers map to with additional {@link Header
        * headers} to be submitted to the given {@link HttpConnection}.
        *
  @@ -1565,6 +1586,7 @@
           addCookieRequestHeader(state, conn);
           addAuthorizationRequestHeader(state, conn);
           addProxyAuthorizationRequestHeader(state, conn);
  +        addProxyConnectionHeader(state, conn);
           addContentLengthRequestHeader(state, conn);
       }
   
  @@ -2056,10 +2078,19 @@
   
           //check for a valid HTTP-Version
           String httpVersion = statusLine.getHttpVersion();
  +        // TODO: Once a better HTTP protocol versioning scheme is 
  +        // introduced, rework the code below 
  +        boolean proxied = 
  +         statusLine.getStatusCode() == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED; 
  +        
           if (httpVersion.equals("HTTP/1.0")) {
  -            http11 = false;
  +            if (!proxied) {
  +                http11 = false;
  +            }
           } else if (httpVersion.equals("HTTP/1.1")) {
  -            http11 = true;
  +            if (!proxied) {
  +                http11 = true;
  +            }
           } else if (httpVersion.equals("HTTP")) {
               // some servers do not specify the version correctly, we will just assume 1.0
               http11 = false;
  
  
  

---------------------------------------------------------------------
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