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 HttpMethodDirector.java
Date Thu, 13 Nov 2003 22:24:47 GMT
olegk       2003/11/13 14:24:47

  Modified:    httpclient/src/java/org/apache/commons/httpclient
                        HttpMethodBase.java HttpMethodDirector.java
  Log:
  PR #24352 (NLTM Proxy and basic host authorization)
  
  Fixed the bug causing basic authentication via NLTM Proxy to fail
  
  Contributed by Oleg Kalnichevski
  Reviewed by Michael Becke
  
  Revision  Changes    Path
  1.190     +12 -18    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.189
  retrieving revision 1.190
  diff -u -r1.189 -r1.190
  --- HttpMethodBase.java	5 Nov 2003 20:45:34 -0000	1.189
  +++ HttpMethodBase.java	13 Nov 2003 22:24:46 -0000	1.190
  @@ -67,7 +67,6 @@
   import java.io.ByteArrayOutputStream;
   import java.io.IOException;
   import java.io.InputStream;
  -import java.util.Iterator;
   
   import org.apache.commons.httpclient.auth.AuthScheme;
   import org.apache.commons.httpclient.auth.HttpAuthenticator;
  @@ -1154,6 +1153,14 @@
           LOG.trace("enter HttpMethodBase.addCookieRequestHeader(HttpState, "
                     + "HttpConnection)");
   
  +        Header[] cookieheaders = getRequestHeaderGroup().getHeaders("Cookie");
  +        for (int i = 0; i < cookieheaders.length; i++) {
  +            Header cookieheader = cookieheaders[i];
  +            if (cookieheader.isAutogenerated()) {
  +                getRequestHeaderGroup().removeHeader(cookieheader);
  +            }
  +        }
  +
           CookieSpec matcher = CookiePolicy.getCookieSpec(this.params.getCookiePolicy());
           Cookie[] cookies = matcher.match(conn.getHost(), conn.getPort(),
               getPath(), conn.isSecure(), state.getCookies());
  @@ -2028,7 +2035,6 @@
       throws IOException, HttpException {
           LOG.trace("enter HttpMethodBase.writeRequestHeaders(HttpState,"
               + "HttpConnection)");
  -        clearAutogeneratedHeaders();
           addRequestHeaders(state, conn);
   
           Header[] headers = getRequestHeaders();
  @@ -2324,16 +2330,4 @@
           this.responseStream = responseStream;
       }
       
  -    /**
  -     * Removes all auto-generated headers
  -     */
  -    protected void clearAutogeneratedHeaders() {
  -        Iterator items = getRequestHeaderGroup().getIterator();
  -        while (items.hasNext()) {
  -            Header header = (Header)items.next();
  -            if (header.isAutogenerated()) {
  -                items.remove();
  -            }
  -        }
  -    }
   }
  
  
  
  1.9       +5 -6      jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodDirector.java
  
  Index: HttpMethodDirector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodDirector.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- HttpMethodDirector.java	10 Nov 2003 23:19:49 -0000	1.8
  +++ HttpMethodDirector.java	13 Nov 2003 22:24:47 -0000	1.9
  @@ -344,7 +344,6 @@
               // What is to follow is an ugly hack.
               // I REALLY hate having to resort to such
               // an appalling trick
  -            // TODO: Connect method must be redesigned.
               // The only feasible solution is to split monolithic
               // HttpMethod into HttpRequest/HttpResponse pair.
               // That would allow to execute CONNECT method 
  @@ -525,17 +524,17 @@
                   realmsUsed.add(realm);
               }
   
  +            this.method.removeRequestHeader(HttpAuthenticator.WWW_AUTH_RESP);
  +            this.method.removeRequestHeader(HttpAuthenticator.PROXY_AUTH_RESP);
   			try {
   				//remove preemptive header and reauthenticate
   				switch (statusCode) {
   					case HttpStatus.SC_UNAUTHORIZED:
  -                        this.method.removeRequestHeader(HttpAuthenticator.WWW_AUTH_RESP);
   						authenticated = HttpAuthenticator.authenticate(
   							authscheme, this.method, this.conn, this.state);
   						this.realm = authscheme.getRealm();
   						break;
   					case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
  -                        this.method.removeRequestHeader(HttpAuthenticator.PROXY_AUTH_RESP);
   						authenticated = HttpAuthenticator.authenticateProxy(
   							authscheme, this.method, this.conn, this.state);
   						this.proxyRealm = authscheme.getRealm();
  
  
  

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