You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ol...@apache.org on 2006/03/30 12:10:00 UTC

svn commit: r390058 - in /jakarta/commons/proper/httpclient/trunk: ./ src/java/org/apache/commons/httpclient/

Author: olegk
Date: Thu Mar 30 02:09:57 2006
New Revision: 390058

URL: http://svn.apache.org/viewcvs?rev=390058&view=rev
Log:
PR #36918 (Digest auth uses wrong uri in proxy authentication)

Changelog:
Digest auth scheme fixed to generate correct digest uri in HTTP CONNECT requests

Contributed by Oleg Kalnichevski
Reviewed by Ortwin Glück

Modified:
    jakarta/commons/proper/httpclient/trunk/release_notes.txt
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/ConnectMethod.java
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodDirector.java
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/ProxyClient.java

Modified: jakarta/commons/proper/httpclient/trunk/release_notes.txt
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/release_notes.txt?rev=390058&r1=390057&r2=390058&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/release_notes.txt (original)
+++ jakarta/commons/proper/httpclient/trunk/release_notes.txt Thu Mar 30 02:09:57 2006
@@ -1,3 +1,9 @@
+Changes toward 3.1 
+
+ * 36918 - Digest auth scheme now uses correct digest uri in HTTP CONNECT 
+           requests
+           Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 Changes since Release 3.0:
 
  * 38818 - Failed CONNECT no longer leaves connection in an inconsistent state

Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/ConnectMethod.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/ConnectMethod.java?rev=390058&r1=390057&r2=390058&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/ConnectMethod.java (original)
+++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/ConnectMethod.java Thu Mar 30 02:09:57 2006
@@ -49,13 +49,18 @@
     /** the name of this method */
     public static final String NAME = "CONNECT";
 
+    private final HostConfiguration targethost;
+
     /**
+     * @deprecated use #ConnectMethod(HttpHost);
+     * 
      * Create a connect method.
      * 
      * @since 3.0
      */
     public ConnectMethod() {
-        LOG.trace("enter ConnectMethod()");
+        super();
+        this.targethost = null;
     }
 
     /**
@@ -67,7 +72,21 @@
      *      to the server
      */
     public ConnectMethod(HttpMethod method) {
-        LOG.trace("enter ConnectMethod(HttpMethod)");
+        super();
+        this.targethost = null;
+    }
+
+    /**
+     * Create a connect method.
+     * 
+     * @since 3.0
+     */
+    public ConnectMethod(final HostConfiguration targethost) {
+        super();
+        if (targethost == null) {
+            throw new IllegalArgumentException("Target host may not be null");
+        }
+        this.targethost = targethost;
     }
 
     /**
@@ -78,6 +97,26 @@
     public String getName() {
         return NAME;
     }
+    
+    public String getPath() {
+        if (this.targethost != null) {
+            StringBuffer buffer = new StringBuffer();
+            buffer.append(this.targethost.getHost()); 
+            int port = this.targethost.getPort();
+            if (port == -1) {
+                port = this.targethost.getProtocol().getDefaultPort();  
+            }
+            buffer.append(':'); 
+            buffer.append(port);
+            return buffer.toString();
+        } else {
+            return "/";
+        }
+    }
+
+    public URI getURI() throws URIException {
+        return new URI(getPath(), true);
+    }
 
     /**
      * This method does nothing. <tt>CONNECT</tt> request is not supposed 
@@ -158,15 +197,17 @@
      */
     protected void writeRequestLine(HttpState state, HttpConnection conn)
     throws IOException, HttpException {
-        int port = conn.getPort();
-        if (port == -1) {
-            port = conn.getProtocol().getDefaultPort();  
-        }
         StringBuffer buffer = new StringBuffer();
         buffer.append(getName()); 
         buffer.append(' '); 
-        buffer.append(conn.getHost()); 
-        if (port > -1) {
+        if (this.targethost != null) {
+            buffer.append(getPath()); 
+        } else {
+            int port = conn.getPort();
+            if (port == -1) {
+                port = conn.getProtocol().getDefaultPort();  
+            }
+            buffer.append(conn.getHost()); 
             buffer.append(':'); 
             buffer.append(port); 
         }

Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodDirector.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodDirector.java?rev=390058&r1=390057&r2=390058&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodDirector.java (original)
+++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodDirector.java Thu Mar 30 02:09:57 2006
@@ -472,7 +472,7 @@
     private boolean executeConnect() 
         throws IOException, HttpException {
 
-        this.connectMethod = new ConnectMethod();
+        this.connectMethod = new ConnectMethod(this.hostConfiguration);
         this.connectMethod.getParams().setDefaults(this.hostConfiguration.getParams());
         
         int code;

Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/ProxyClient.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/ProxyClient.java?rev=390058&r1=390057&r2=390058&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/ProxyClient.java (original)
+++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/ProxyClient.java Thu Mar 30 02:09:57 2006
@@ -189,7 +189,7 @@
             throw new IllegalStateException("secure protocol socket factory may not be used");
         }
         
-        ConnectMethod method = new ConnectMethod();
+        ConnectMethod method = new ConnectMethod(getHostConfiguration());
         method.getParams().setDefaults(getParams());
         
         DummyConnectionManager connectionManager = new DummyConnectionManager();



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