hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r178792 - in /jakarta/httpclient/trunk/http-common/src: java/org/apache/http/ java/org/apache/http/executor/ java/org/apache/http/impl/ java/org/apache/http/interceptor/ test/org/apache/http/
Date Fri, 27 May 2005 16:42:03 GMT
Author: olegk
Date: Fri May 27 09:42:01 2005
New Revision: 178792

URL: http://svn.apache.org/viewcvs?rev=178792&view=rev
Log:
(1) Removed direct dependency on impl classes for HttpRequestExecutor and Protocol
(2) *ProtocolSocketFactory interfaces renamed to *SocketFactory

Added:
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/SecureSocketFactory.java
      - copied, changed from r178764, jakarta/httpclient/trunk/http-common/src/java/org/apache/http/SecureProtocolSocketFactory.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/SocketFactory.java
      - copied, changed from r178764, jakarta/httpclient/trunk/http-common/src/java/org/apache/http/ProtocolSocketFactory.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/executor/HttpExecutionContext.java
      - copied, changed from r178764, jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpContext.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOSocketFactory.java
      - copied, changed from r178764, jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOProtocolSocketFactory.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/OldIOSocketFactory.java
      - copied, changed from r178764, jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/OldIOProtocolSocketFactory.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/SSLSocketFactory.java
      - copied, changed from r178764, jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/SSLProtocolSocketFactory.java
Removed:
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/ProtocolSocketFactory.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/SecureProtocolSocketFactory.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpContext.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOProtocolSocketFactory.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/OldIOProtocolSocketFactory.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/SSLProtocolSocketFactory.java
Modified:
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpContext.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/Protocol.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/executor/HttpRequestExecutor.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpClientConnection.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpProxyConnection.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/interceptor/RequestTargetHost.java
    jakarta/httpclient/trunk/http-common/src/test/org/apache/http/TestHttpHost.java

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpContext.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpContext.java?rev=178792&r1=178791&r2=178792&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpContext.java (original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpContext.java Fri May
27 09:42:01 2005
@@ -40,11 +40,6 @@
  */
 public interface HttpContext {
 
-    public static final String HTTP_REQUEST     = "http.request"; 
-    public static final String HTTP_CONNECTION  = "http.connection"; 
-    public static final String HTTP_TARGET_HOST = "http.target_host"; 
-    public static final String HTTP_PROXY_HOST  = "http.proxy_host"; 
-    
     Object getAttribute(String id);
 
     void setAttribute(String id, Object obj);

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/Protocol.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/Protocol.java?rev=178792&r1=178791&r2=178792&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/Protocol.java (original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/Protocol.java Fri May 27
09:42:01 2005
@@ -32,9 +32,6 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.http.impl.NIOProtocolSocketFactory;
-import org.apache.http.impl.OldIOProtocolSocketFactory;
-import org.apache.http.impl.SSLProtocolSocketFactory;
 import org.apache.http.util.LangUtils;
 
 /**
@@ -112,55 +109,18 @@
         if (id == null) {
             throw new IllegalArgumentException("id is null");
         }
-
         Protocol protocol = (Protocol) PROTOCOLS.get(id);
-
         if (protocol == null) {
-            protocol = lazyRegisterProtocol(id);
+            throw new IllegalStateException("Unsupported protocol: '" + id + "'");
         }
-
         return protocol;
     } 
 
-    /**
-     * Lazily registers the protocol with the given id.
-     * 
-     * @param id the protocol ID
-     * 
-     * @return the lazily registered protocol
-     * 
-     * @throws IllegalStateException if the protocol with id is not recognized
-     */
-    private static Protocol lazyRegisterProtocol(String id) 
-        throws IllegalStateException {
-
-        if ("http".equals(id)) {
-            // TODO: remove direct dependency on the impl classes
-            ProtocolSocketFactory socketfactory = null;
-            if (HttpRuntime.isNIOCapable()) {
-                socketfactory = NIOProtocolSocketFactory.getSocketFactory();
-            } else {
-                socketfactory = OldIOProtocolSocketFactory.getSocketFactory();
-            }
-            final Protocol http = new Protocol("http", socketfactory, 80);
-            Protocol.registerProtocol("http", http);
-            return http;
-        }
-        if ("https".equals(id)) {
-            final Protocol https 
-                = new Protocol("https", SSLProtocolSocketFactory.getSocketFactory(), 443);
-            Protocol.registerProtocol("https", https);
-            return https;
-        }
-        throw new IllegalStateException("unsupported protocol: '" + id + "'");
-    }
-    
-
     /** the scheme of this protocol (e.g. http, https) */
     private String scheme;
     
     /** The socket factory for this protocol */
-    private ProtocolSocketFactory socketFactory;
+    private SocketFactory socketFactory;
     
     /** The default port for this protocol */
     private int defaultPort;
@@ -177,7 +137,7 @@
      * this protocol
      * @param defaultPort the port this protocol defaults to
      */
-    public Protocol(String scheme, ProtocolSocketFactory factory, int defaultPort) {
+    public Protocol(final String scheme, final SocketFactory factory, int defaultPort) {
         
         if (scheme == null) {
             throw new IllegalArgumentException("scheme is null");
@@ -192,7 +152,7 @@
         this.scheme = scheme;
         this.socketFactory = factory;
         this.defaultPort = defaultPort;
-        this.secure = (factory instanceof SecureProtocolSocketFactory);
+        this.secure = (factory instanceof SecureSocketFactory);
     }
     
     /**
@@ -204,11 +164,10 @@
     }
 
     /**
-     * Returns the socketFactory.  If secure the factory is a
-     * SecureProtocolSocketFactory.
+     * Returns the socketFactory.  If secure the factory is a SecureSocketFactory.
      * @return SocketFactory
      */
-    public ProtocolSocketFactory getSocketFactory() {
+    public SocketFactory getSocketFactory() {
         return socketFactory;
     }
 

Copied: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/SecureSocketFactory.java
(from r178764, jakarta/httpclient/trunk/http-common/src/java/org/apache/http/SecureProtocolSocketFactory.java)
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/SecureSocketFactory.java?p2=jakarta/httpclient/trunk/http-common/src/java/org/apache/http/SecureSocketFactory.java&p1=jakarta/httpclient/trunk/http-common/src/java/org/apache/http/SecureProtocolSocketFactory.java&r1=178764&r2=178792&rev=178792&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/SecureProtocolSocketFactory.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/SecureSocketFactory.java
Fri May 27 09:42:01 2005
@@ -42,7 +42,7 @@
  * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
  * @since 2.0
  */
-public interface SecureProtocolSocketFactory extends ProtocolSocketFactory {
+public interface SecureSocketFactory extends SocketFactory {
 
     /**
      * Returns a socket connected to the given host that is layered over an

Copied: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/SocketFactory.java (from
r178764, jakarta/httpclient/trunk/http-common/src/java/org/apache/http/ProtocolSocketFactory.java)
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/SocketFactory.java?p2=jakarta/httpclient/trunk/http-common/src/java/org/apache/http/SocketFactory.java&p1=jakarta/httpclient/trunk/http-common/src/java/org/apache/http/ProtocolSocketFactory.java&r1=178764&r2=178792&rev=178792&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/ProtocolSocketFactory.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/SocketFactory.java Fri May
27 09:42:01 2005
@@ -52,7 +52,7 @@
  * 
  * @since 2.0
  */
-public interface ProtocolSocketFactory {
+public interface SocketFactory {
 
     /**
      * Gets a new socket connection to the given host.

Copied: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/executor/HttpExecutionContext.java
(from r178764, jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpContext.java)
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/executor/HttpExecutionContext.java?p2=jakarta/httpclient/trunk/http-common/src/java/org/apache/http/executor/HttpExecutionContext.java&p1=jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpContext.java&r1=178764&r2=178792&rev=178792&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpContext.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/executor/HttpExecutionContext.java
Fri May 27 09:42:01 2005
@@ -27,7 +27,7 @@
  *
  */
 
-package org.apache.http.impl;
+package org.apache.http.executor;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -43,12 +43,17 @@
  * 
  * @since 4.0
  */
-public class BasicHttpContext implements HttpContext {
+public class HttpExecutionContext implements HttpContext {
+    
+    public static final String HTTP_REQUEST     = "http.request"; 
+    public static final String HTTP_CONNECTION  = "http.connection"; 
+    public static final String HTTP_TARGET_HOST = "http.target_host"; 
+    public static final String HTTP_PROXY_HOST  = "http.proxy_host"; 
     
     private final HttpContext parentContext;
     private Map map = null;
     
-    public BasicHttpContext(final HttpContext parentContext) {
+    public HttpExecutionContext(final HttpContext parentContext) {
         super();
         this.parentContext = parentContext;
     }

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/executor/HttpRequestExecutor.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/executor/HttpRequestExecutor.java?rev=178792&r1=178791&r2=178792&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/executor/HttpRequestExecutor.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/executor/HttpRequestExecutor.java
Fri May 27 09:42:01 2005
@@ -43,7 +43,6 @@
 import org.apache.http.HttpRequestInterceptor;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpResponseInterceptor;
-import org.apache.http.impl.BasicHttpContext;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
 
@@ -70,7 +69,7 @@
             throw new IllegalArgumentException("HTTP parameters may not be null");
         }
         this.params = params;
-        this.localContext = new BasicHttpContext(parentContext);
+        this.localContext = new HttpExecutionContext(parentContext);
     }
     
     public HttpRequestExecutor(final HttpParams params) {
@@ -176,9 +175,9 @@
             throw new IllegalArgumentException("Client connection may not be null");
         }
         
-        this.localContext.setAttribute(HttpContext.HTTP_REQUEST, request);
-        this.localContext.setAttribute(HttpContext.HTTP_CONNECTION, conn);
-        this.localContext.setAttribute(HttpContext.HTTP_TARGET_HOST, conn.getHost());
+        this.localContext.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
+        this.localContext.setAttribute(HttpExecutionContext.HTTP_CONNECTION, conn);
+        this.localContext.setAttribute(HttpExecutionContext.HTTP_TARGET_HOST, conn.getHost());
 
         // Link own parameters as defaults 
         request.getParams().setDefaults(this.params);

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpClientConnection.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpClientConnection.java?rev=178792&r1=178791&r2=178792&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpClientConnection.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpClientConnection.java
Fri May 27 09:42:01 2005
@@ -47,7 +47,7 @@
 import org.apache.http.HttpVersion;
 import org.apache.http.NoHttpResponseException;
 import org.apache.http.ProtocolException;
-import org.apache.http.ProtocolSocketFactory;
+import org.apache.http.SocketFactory;
 import org.apache.http.StatusLine;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpProtocolParams;
@@ -91,7 +91,7 @@
         }
         assertNotOpen();
         
-        ProtocolSocketFactory socketfactory = targethost.getProtocol().getSocketFactory();
+        SocketFactory socketfactory = targethost.getProtocol().getSocketFactory();
         Socket socket = socketfactory.createSocket(
                 this.targethost.getHostName(), this.targethost.getPort(), 
                 this.localAddress, 0, 

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpProxyConnection.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpProxyConnection.java?rev=178792&r1=178791&r2=178792&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpProxyConnection.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpProxyConnection.java
Fri May 27 09:42:01 2005
@@ -36,9 +36,9 @@
 import org.apache.http.HttpHost;
 import org.apache.http.HttpProxyConnection;
 import org.apache.http.Protocol;
-import org.apache.http.ProtocolSocketFactory;
 import org.apache.http.ProxyHost;
-import org.apache.http.SecureProtocolSocketFactory;
+import org.apache.http.SecureSocketFactory;
+import org.apache.http.SocketFactory;
 import org.apache.http.params.HttpParams;
 
 /**
@@ -84,9 +84,9 @@
         }
         assertOpen();
         Protocol protocol = targetHost.getProtocol();
-        ProtocolSocketFactory socketfactory = protocol.getSocketFactory();
-        if (socketfactory instanceof SecureProtocolSocketFactory) {
-            Socket socket = ((SecureProtocolSocketFactory)socketfactory)
+        SocketFactory socketfactory = protocol.getSocketFactory();
+        if (socketfactory instanceof SecureSocketFactory) {
+            Socket socket = ((SecureSocketFactory)socketfactory)
                 .createSocket(
                     this.socket, 
                     targetHost.getHostName(), 

Copied: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOSocketFactory.java
(from r178764, jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOProtocolSocketFactory.java)
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOSocketFactory.java?p2=jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOSocketFactory.java&p1=jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOProtocolSocketFactory.java&r1=178764&r2=178792&rev=178792&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOProtocolSocketFactory.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOSocketFactory.java
Fri May 27 09:42:01 2005
@@ -37,7 +37,7 @@
 import java.nio.channels.SocketChannel;
 
 import org.apache.http.ConnectTimeoutException;
-import org.apache.http.ProtocolSocketFactory;
+import org.apache.http.SocketFactory;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
 
@@ -49,25 +49,25 @@
  * 
  * @since 2.0
  */
-public class NIOProtocolSocketFactory implements ProtocolSocketFactory {
+public class NIOSocketFactory implements SocketFactory {
 
     /**
      * The factory singleton.
      */
-    private static final NIOProtocolSocketFactory DEFAULT_FACTORY = new NIOProtocolSocketFactory();
+    private static final NIOSocketFactory DEFAULT_FACTORY = new NIOSocketFactory();
     
     /**
      * Gets an singleton instance of the DefaultProtocolSocketFactory.
      * @return a DefaultProtocolSocketFactory
      */
-    public static NIOProtocolSocketFactory getSocketFactory() {
+    public static NIOSocketFactory getSocketFactory() {
         return DEFAULT_FACTORY;
     }
     
     /**
      * Constructor for DefaultProtocolSocketFactory.
      */
-    private NIOProtocolSocketFactory() {
+    private NIOSocketFactory() {
         super();
     }
 
@@ -115,14 +115,14 @@
      * All instances of DefaultProtocolSocketFactory are the same.
      */
     public boolean equals(Object obj) {
-        return ((obj != null) && obj.getClass().equals(NIOProtocolSocketFactory.class));
+        return ((obj != null) && obj.getClass().equals(NIOSocketFactory.class));
     }
 
     /**
      * All instances of DefaultProtocolSocketFactory have the same hash code.
      */
     public int hashCode() {
-        return NIOProtocolSocketFactory.class.hashCode();
+        return NIOSocketFactory.class.hashCode();
     }
 
 }

Copied: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/OldIOSocketFactory.java
(from r178764, jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/OldIOProtocolSocketFactory.java)
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/OldIOSocketFactory.java?p2=jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/OldIOSocketFactory.java&p1=jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/OldIOProtocolSocketFactory.java&r1=178764&r2=178792&rev=178792&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/OldIOProtocolSocketFactory.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/OldIOSocketFactory.java
Fri May 27 09:42:01 2005
@@ -34,7 +34,7 @@
 import java.net.Socket;
 import java.net.UnknownHostException;
 
-import org.apache.http.ProtocolSocketFactory;
+import org.apache.http.SocketFactory;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
 
@@ -46,25 +46,25 @@
  * 
  * @since 2.0
  */
-public class OldIOProtocolSocketFactory implements ProtocolSocketFactory {
+public class OldIOSocketFactory implements SocketFactory {
 
     /**
      * The factory singleton.
      */
-    private static final OldIOProtocolSocketFactory DEFAULT_FACTORY = new OldIOProtocolSocketFactory();
+    private static final OldIOSocketFactory DEFAULT_FACTORY = new OldIOSocketFactory();
     
     /**
      * Gets an singleton instance of the DefaultProtocolSocketFactory.
      * @return a DefaultProtocolSocketFactory
      */
-    public static OldIOProtocolSocketFactory getSocketFactory() {
+    public static OldIOSocketFactory getSocketFactory() {
         return DEFAULT_FACTORY;
     }
     
     /**
      * Constructor for DefaultProtocolSocketFactory.
      */
-    private OldIOProtocolSocketFactory() {
+    private OldIOSocketFactory() {
         super();
     }
 
@@ -114,14 +114,14 @@
      * All instances of DefaultProtocolSocketFactory are the same.
      */
     public boolean equals(Object obj) {
-        return ((obj != null) && obj.getClass().equals(OldIOProtocolSocketFactory.class));
+        return ((obj != null) && obj.getClass().equals(OldIOSocketFactory.class));
     }
 
     /**
      * All instances of DefaultProtocolSocketFactory have the same hash code.
      */
     public int hashCode() {
-        return OldIOProtocolSocketFactory.class.hashCode();
+        return OldIOSocketFactory.class.hashCode();
     }
 
 }

Copied: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/SSLSocketFactory.java
(from r178764, jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/SSLProtocolSocketFactory.java)
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/SSLSocketFactory.java?p2=jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/SSLSocketFactory.java&p1=jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/SSLProtocolSocketFactory.java&r1=178764&r2=178792&rev=178792&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/SSLProtocolSocketFactory.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/SSLSocketFactory.java
Fri May 27 09:42:01 2005
@@ -45,12 +45,11 @@
 import javax.net.ssl.KeyManager;
 import javax.net.ssl.KeyManagerFactory;
 import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSocketFactory;
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.TrustManagerFactory;
 
 import org.apache.http.ConnectTimeoutException;
-import org.apache.http.SecureProtocolSocketFactory;
+import org.apache.http.SecureSocketFactory;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
 
@@ -131,7 +130,7 @@
  * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
  */
 
-public class SSLProtocolSocketFactory implements SecureProtocolSocketFactory {
+public class SSLSocketFactory implements SecureSocketFactory {
 
     public static final String TLS   = "TLS";
     public static final String SSL   = "SSL";
@@ -140,20 +139,20 @@
     /**
      * The factory singleton.
      */
-    private static final SSLProtocolSocketFactory DEFAULT_FACTORY = new SSLProtocolSocketFactory();
+    private static final SSLSocketFactory DEFAULT_FACTORY = new SSLSocketFactory();
     
     /**
      * Gets an singleton instance of the SSLProtocolSocketFactory.
      * @return a SSLProtocolSocketFactory
      */
-    public static SSLProtocolSocketFactory getSocketFactory() {
+    public static SSLSocketFactory getSocketFactory() {
         return DEFAULT_FACTORY;
     }
     
     private final SSLContext sslcontext;
     private final SocketFactory socketfactory;
 
-    public SSLProtocolSocketFactory(
+    public SSLSocketFactory(
         String algorithm, 
         final KeyStore keystore, 
         final String keystorePassword, 
@@ -178,7 +177,7 @@
         this.socketfactory = this.sslcontext.getSocketFactory();
     }
 
-    public SSLProtocolSocketFactory(
+    public SSLSocketFactory(
             final KeyStore keystore, 
             final String keystorePassword, 
             final KeyStore truststore) 
@@ -187,22 +186,22 @@
         this(TLS, keystore, keystorePassword, truststore, null);
     }
 
-    public SSLProtocolSocketFactory(final KeyStore keystore, final String keystorePassword)

+    public SSLSocketFactory(final KeyStore keystore, final String keystorePassword) 
             throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException
     {
         this(TLS, keystore, keystorePassword, null, null);
     }
 
-    public SSLProtocolSocketFactory(final KeyStore truststore) 
+    public SSLSocketFactory(final KeyStore truststore) 
             throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException
     {
         this(TLS, null, null, truststore, null);
     }
 
-    public SSLProtocolSocketFactory() {
+    public SSLSocketFactory() {
         super();
         this.sslcontext = null;
-        this.socketfactory = SSLSocketFactory.getDefault(); 
+        this.socketfactory = javax.net.ssl.SSLSocketFactory.getDefault(); 
     }
 
     private static KeyManager[] createKeyManagers(final KeyStore keystore, final String password)

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/interceptor/RequestTargetHost.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/interceptor/RequestTargetHost.java?rev=178792&r1=178791&r2=178792&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/interceptor/RequestTargetHost.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/interceptor/RequestTargetHost.java
Fri May 27 09:42:01 2005
@@ -37,6 +37,7 @@
 import org.apache.http.HttpHost;
 import org.apache.http.HttpMutableRequest;
 import org.apache.http.HttpRequestInterceptor;
+import org.apache.http.executor.HttpExecutionContext;
 import org.apache.http.params.HttpProtocolParams;
 
 /**
@@ -65,7 +66,8 @@
             throw new IllegalArgumentException("HTTP context may not be null");
         }
         if (!request.containsHeader(TARGET_HOST)) {
-            HttpHost targethost = (HttpHost) context.getAttribute(HttpContext.HTTP_TARGET_HOST);
+            HttpHost targethost = (HttpHost) context
+                .getAttribute(HttpExecutionContext.HTTP_TARGET_HOST);
             HttpProtocolParams params = new HttpProtocolParams(request.getParams());
             String virtualhost = params.getVirtualHost();
             if (virtualhost != null) {

Modified: jakarta/httpclient/trunk/http-common/src/test/org/apache/http/TestHttpHost.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/test/org/apache/http/TestHttpHost.java?rev=178792&r1=178791&r2=178792&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/test/org/apache/http/TestHttpHost.java (original)
+++ jakarta/httpclient/trunk/http-common/src/test/org/apache/http/TestHttpHost.java Fri May
27 09:42:01 2005
@@ -29,7 +29,8 @@
 
 package org.apache.http;
 
-import org.apache.http.impl.NIOProtocolSocketFactory;
+import org.apache.http.impl.NIOSocketFactory;
+import org.apache.http.impl.OldIOSocketFactory;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
@@ -55,6 +56,18 @@
         return new TestSuite(TestHttpHost.class);
     }
 
+    protected void setUp() throws Exception {
+        super.setUp();
+        SocketFactory socketfactory = null;
+        if (HttpRuntime.isNIOCapable()) {
+            socketfactory = NIOSocketFactory.getSocketFactory();
+        } else {
+            socketfactory = OldIOSocketFactory.getSocketFactory();
+        }
+        final Protocol http = new Protocol("http", socketfactory, 80);
+        Protocol.registerProtocol("http", http);
+    }
+    
     public void testConstructor() {
         Protocol http = Protocol.getProtocol("http");
         HttpHost host1 = new HttpHost("somehost");
@@ -90,7 +103,7 @@
     public void testHashCode() {
         Protocol http = Protocol.getProtocol("http");
         Protocol myhttp = new Protocol("myhttp", 
-                NIOProtocolSocketFactory.getSocketFactory(), 8080);
+                NIOSocketFactory.getSocketFactory(), 8080);
         HttpHost host1 = new HttpHost("somehost", 8080, http);
         HttpHost host2 = new HttpHost("somehost", 80, http);
         HttpHost host3 = new HttpHost("someotherhost", 8080, http);
@@ -109,7 +122,7 @@
     public void testEquals() {
         Protocol http = Protocol.getProtocol("http");
         Protocol myhttp = new Protocol("myhttp", 
-                NIOProtocolSocketFactory.getSocketFactory(), 8080);
+                NIOSocketFactory.getSocketFactory(), 8080);
         HttpHost host1 = new HttpHost("somehost", 8080, http);
         HttpHost host2 = new HttpHost("somehost", 80, http);
         HttpHost host3 = new HttpHost("someotherhost", 8080, http);
@@ -130,7 +143,7 @@
     public void testToString() {
         Protocol http = Protocol.getProtocol("http");
         Protocol myhttp = new Protocol("myhttp", 
-                NIOProtocolSocketFactory.getSocketFactory(), 8080);
+                NIOSocketFactory.getSocketFactory(), 8080);
         HttpHost host1 = new HttpHost("somehost");
         assertEquals("http://somehost", host1.toString());
         HttpHost host2 = new HttpHost("somehost", http.getDefaultPort());



Mime
View raw message