hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r537590 - in /jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http: conn/ssl/SSLSocketFactory.java impl/client/DefaultClientRequestDirector.java impl/conn/DefaultClientConnection.java
Date Sun, 13 May 2007 14:46:13 GMT
Author: olegk
Date: Sun May 13 07:46:12 2007
New Revision: 537590

URL: http://svn.apache.org/viewvc?view=rev&rev=537590
Log:
* Minor bug fixes
* Reviewed HTTP CONNECT logic for compliance with Tunneling TCP based protocols through Web
proxy servers

Modified:
    jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/ssl/SSLSocketFactory.java
    jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/client/DefaultClientRequestDirector.java
    jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/conn/DefaultClientConnection.java

Modified: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/ssl/SSLSocketFactory.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/ssl/SSLSocketFactory.java?view=diff&rev=537590&r1=537589&r2=537590
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/ssl/SSLSocketFactory.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/ssl/SSLSocketFactory.java
Sun May 13 07:46:12 2007
@@ -175,7 +175,7 @@
         }
         TrustManager[] trustmanagers = null;
         if (truststore != null) {
-            trustmanagers = createTrustManagers(keystore);
+            trustmanagers = createTrustManagers(truststore);
         }
         this.sslcontext = SSLContext.getInstance(algorithm);
         this.sslcontext.init(keymanagers, trustmanagers, random);

Modified: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/client/DefaultClientRequestDirector.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/client/DefaultClientRequestDirector.java?view=diff&rev=537590&r1=537589&r2=537590
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/client/DefaultClientRequestDirector.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/client/DefaultClientRequestDirector.java
Sun May 13 07:46:12 2007
@@ -69,10 +69,13 @@
 import org.apache.http.message.BasicHttpRequest;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpProtocolParams;
+import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpExecutionContext;
 import org.apache.http.protocol.HttpProcessor;
 import org.apache.http.protocol.HttpRequestExecutor;
+import org.apache.http.util.CharArrayBuffer;
 
 /**
  * Default implementation of a client-side request director.
@@ -481,17 +484,34 @@
      */
     protected HttpRequest createConnectRequest(HttpRoute route,
                                                HttpContext context) {
-        // see RFC 2817, section 5.2
-        final String authority =
-            route.getTargetHost().getHostName() + ":" +
-            route.getTargetHost().getPort();
-
-        //@@@ do we need a more refined algorithm to choose the HTTP version?
-        //@@@ use a request factory provided by the caller/creator?
+        // see RFC 2817, section 5.2 and 
+        // INTERNET-DRAFT: Tunneling TCP based protocols through 
+        // Web proxy servers
+            
+        HttpHost target = route.getTargetHost();
+        
+        String host = target.getHostName();
+        int port = target.getPort();
+        if (port < 0) {
+            SchemeRegistry schemeREgistry = connManager.getSchemeRegistry();
+            Scheme scheme = schemeREgistry.getScheme(target.getSchemeName());
+            port = scheme.getDefaultPort();
+        }
+        
+        CharArrayBuffer buffer = new CharArrayBuffer(host.length() + 6);
+        buffer.append(host);
+        buffer.append(":");
+        buffer.append(Integer.toString(port));
+        
+        String authority = buffer.toString();
+        HttpVersion ver = HttpProtocolParams.getVersion(params);
         HttpRequest req = new BasicHttpRequest
-            ("CONNECT", authority, HttpVersion.HTTP_1_1);
+            ("CONNECT", authority, ver);
 
-        req.addHeader("Host", authority);
+        String agent = HttpProtocolParams.getUserAgent(params);
+        if (agent != null) {
+            req.addHeader(HTTP.USER_AGENT, agent);
+        }
 
         //@@@ authenticate here, in caller, or in request interceptor?
 

Modified: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/conn/DefaultClientConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/conn/DefaultClientConnection.java?view=diff&rev=537590&r1=537589&r2=537590
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/conn/DefaultClientConnection.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/conn/DefaultClientConnection.java
Sun May 13 07:46:12 2007
@@ -204,10 +204,10 @@
             final HttpParams params) throws HttpException, IOException {
         HttpResponse response = super.receiveResponseHeader(params);
         if (HEADERS_LOG.isDebugEnabled()) {
-            HEADERS_LOG.debug(">> " + response.getStatusLine().toString());
+            HEADERS_LOG.debug("<< " + response.getStatusLine().toString());
             Header[] headers = response.getAllHeaders();
             for (int i = 0; i < headers.length; i++) {
-                HEADERS_LOG.debug(">> " + headers[i].toString());
+                HEADERS_LOG.debug("<< " + headers[i].toString());
             }
         }
         return response;
@@ -217,10 +217,10 @@
     public void sendRequestHeader(HttpRequest request) throws HttpException, IOException
{
         super.sendRequestHeader(request);
         if (HEADERS_LOG.isDebugEnabled()) {
-            HEADERS_LOG.debug("<< " + request.getRequestLine().toString());
+            HEADERS_LOG.debug(">> " + request.getRequestLine().toString());
             Header[] headers = request.getAllHeaders();
             for (int i = 0; i < headers.length; i++) {
-                HEADERS_LOG.debug("<< " + headers[i].toString());
+                HEADERS_LOG.debug(">> " + headers[i].toString());
             }
         }
     }



Mime
View raw message