hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r159116 - in jakarta/httpclient/trunk/http-common/src/java/org/apache/http: ConnectTimeoutException.java HttpHost.java Protocol.java ProtocolSocketFactory.java SecureProtocolSocketFactory.java impl/DefaultProtocolSocketFactory.java util/LangUtils.java
Date Sat, 26 Mar 2005 21:13:40 GMT
Author: olegk
Date: Sat Mar 26 13:13:37 2005
New Revision: 159116

URL: http://svn.apache.org/viewcvs?view=rev&rev=159116
Log:
SVN copied from Jakarta Commons HttpClient

Added:
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/ConnectTimeoutException.java
      - copied, changed from r159115, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/ConnectTimeoutException.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpHost.java
      - copied, changed from r159115, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpHost.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/Protocol.java
      - copied, changed from r159115, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/Protocol.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/ProtocolSocketFactory.java
      - copied, changed from r159115, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/ProtocolSocketFactory.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/SecureProtocolSocketFactory.java
      - copied, changed from r159115, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/SecureProtocolSocketFactory.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultProtocolSocketFactory.java
      - copied, changed from r159115, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/DefaultProtocolSocketFactory.java
Modified:
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/util/LangUtils.java

Copied: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/ConnectTimeoutException.java
(from r159115, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/ConnectTimeoutException.java)
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/ConnectTimeoutException.java?view=diff&rev=159116&p1=jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/ConnectTimeoutException.java&r1=159115&p2=jakarta/httpclient/trunk/http-common/src/java/org/apache/http/ConnectTimeoutException.java&r2=159116
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/ConnectTimeoutException.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/ConnectTimeoutException.java
Sat Mar 26 13:13:37 2005
@@ -27,12 +27,10 @@
  *
  */
 
-package org.apache.commons.httpclient;
+package org.apache.http;
 
 import java.io.InterruptedIOException;
 
-import org.apache.commons.httpclient.util.ExceptionUtil;
-
 /**
  * A timeout while connecting to an HTTP server or waiting for an
  * available connection from an HttpConnectionManager.
@@ -55,21 +53,8 @@
      * 
      * @param message The exception detail message 
      */
-    public ConnectTimeoutException(String message) {
-        super(message);
-    }
-
-    /**
-     * Creates a new ConnectTimeoutException with the specified detail message and cause.
-     * 
-     * @param message the exception detail message
-     * @param cause the <tt>Throwable</tt> that caused this exception, or <tt>null</tt>
-     * if the cause is unavailable, unknown, or not a <tt>Throwable</tt>
-     */
-    public ConnectTimeoutException(String message, Throwable cause) {
+    public ConnectTimeoutException(final String message) {
         super(message);
-        // If we're running on JDK 1.4 or later, tell Throwable what the cause was
-        ExceptionUtil.initCause(this, cause);
     }
 
 }

Copied: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpHost.java (from
r159115, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpHost.java)
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpHost.java?view=diff&rev=159116&p1=jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpHost.java&r1=159115&p2=jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpHost.java&r2=159116
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpHost.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpHost.java Sat Mar 26
13:13:37 2005
@@ -1,5 +1,5 @@
 /*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/HttpHost.java,v
1.3 2005/01/14 21:16:40 olegk Exp $
+ * $HeadURL$
  * $Revision$
  * $Date$
  *
@@ -27,10 +27,9 @@
  *
  */
 
-package org.apache.commons.httpclient;
+package org.apache.http;
 
-import org.apache.commons.httpclient.protocol.Protocol;
-import org.apache.commons.httpclient.util.LangUtils;
+import org.apache.http.util.LangUtils;
 
 /**
  * Holds all of the variables needed to describe an HTTP connection to a host. This includes

@@ -97,15 +96,6 @@
         this(hostname, -1, Protocol.getProtocol("http"));
     }
     
-    /**
-     * URI constructor for HttpHost.
-     *   
-     * @param uri the URI.
-     */
-    public  HttpHost(final URI uri) throws URIException {
-        this(uri.getHost(), uri.getPort(), Protocol.getProtocol(uri.getScheme()));
-    }
-
     /**
      * Copy constructor for HttpHost
      * 

Copied: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/Protocol.java (from
r159115, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/Protocol.java)
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/Protocol.java?view=diff&rev=159116&p1=jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/Protocol.java&r1=159115&p2=jakarta/httpclient/trunk/http-common/src/java/org/apache/http/Protocol.java&r2=159116
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/Protocol.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/Protocol.java Sat Mar 26
13:13:37 2005
@@ -1,5 +1,5 @@
 /*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/protocol/Protocol.java,v
1.10 2004/04/18 23:51:38 jsdever Exp $
+ * $HeadURL$
  * $Revision$
  * $Date$
  *
@@ -26,13 +26,14 @@
  * <http://www.apache.org/>.
  *
  */
-package org.apache.commons.httpclient.protocol;
+package org.apache.http;
 
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.commons.httpclient.util.LangUtils;
+import org.apache.http.impl.DefaultProtocolSocketFactory;
+import org.apache.http.util.LangUtils;
 
 /**
  * A class to encapsulate the specifics of a protocol.  This class class also
@@ -137,14 +138,14 @@
             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 + "'");
     }
     
@@ -263,11 +264,8 @@
      * @return true if the objects are equal.
      */
     public boolean equals(Object obj) {
-        
         if (obj instanceof Protocol) {
-            
             Protocol p = (Protocol) obj;
-            
             return (
                 defaultPort == p.getDefaultPort()
                 && scheme.equalsIgnoreCase(p.getScheme())

Copied: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/ProtocolSocketFactory.java
(from r159115, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/ProtocolSocketFactory.java)
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/ProtocolSocketFactory.java?view=diff&rev=159116&p1=jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/ProtocolSocketFactory.java&r1=159115&p2=jakarta/httpclient/trunk/http-common/src/java/org/apache/http/ProtocolSocketFactory.java&r2=159116
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/ProtocolSocketFactory.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/ProtocolSocketFactory.java
Sat Mar 26 13:13:37 2005
@@ -1,5 +1,5 @@
 /*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/protocol/ProtocolSocketFactory.java,v
1.10 2004/05/13 04:01:22 mbecke Exp $
+ * $HeadURL$
  * $Revision$
  * $Date$
  *
@@ -27,15 +27,14 @@
  *
  */
 
-package org.apache.commons.httpclient.protocol;
+package org.apache.http;
 
 import java.io.IOException;
 import java.net.InetAddress;
 import java.net.Socket;
 import java.net.UnknownHostException;
 
-import org.apache.commons.httpclient.ConnectTimeoutException;
-import org.apache.commons.httpclient.params.HttpConnectionParams;
+import org.apache.http.params.HttpParams;
 
 /**
  * A factory for creating Sockets.
@@ -100,7 +99,7 @@
         int port, 
         InetAddress localAddress, 
         int localPort,
-        HttpConnectionParams params
+        HttpParams params
     ) throws IOException, UnknownHostException, ConnectTimeoutException;
 
     /**

Copied: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/SecureProtocolSocketFactory.java
(from r159115, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/SecureProtocolSocketFactory.java)
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/SecureProtocolSocketFactory.java?view=diff&rev=159116&p1=jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/SecureProtocolSocketFactory.java&r1=159115&p2=jakarta/httpclient/trunk/http-common/src/java/org/apache/http/SecureProtocolSocketFactory.java&r2=159116
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/SecureProtocolSocketFactory.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/SecureProtocolSocketFactory.java
Sat Mar 26 13:13:37 2005
@@ -1,5 +1,5 @@
 /*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/protocol/SecureProtocolSocketFactory.java,v
1.6 2004/04/18 23:51:38 jsdever Exp $
+ * $HeadURL$
  * $Revision$
  * $Date$
  *
@@ -27,7 +27,7 @@
  *
  */
 
-package org.apache.commons.httpclient.protocol;
+package org.apache.http;
 
 import java.io.IOException;
 import java.net.Socket;

Copied: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultProtocolSocketFactory.java
(from r159115, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/DefaultProtocolSocketFactory.java)
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultProtocolSocketFactory.java?view=diff&rev=159116&p1=jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/DefaultProtocolSocketFactory.java&r1=159115&p2=jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultProtocolSocketFactory.java&r2=159116
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/DefaultProtocolSocketFactory.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultProtocolSocketFactory.java
Sat Mar 26 13:13:37 2005
@@ -1,5 +1,5 @@
 /*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/protocol/DefaultProtocolSocketFactory.java,v
1.10 2004/05/13 04:01:22 mbecke Exp $
+ * $HeadURL$
  * $Revision$
  * $Date$
  *
@@ -27,15 +27,18 @@
  *
  */
 
-package org.apache.commons.httpclient.protocol;
+package org.apache.http.impl;
 
 import java.io.IOException;
 import java.net.InetAddress;
+import java.net.InetSocketAddress;
 import java.net.Socket;
 import java.net.UnknownHostException;
 
-import org.apache.commons.httpclient.ConnectTimeoutException;
-import org.apache.commons.httpclient.params.HttpConnectionParams;
+import org.apache.http.ConnectTimeoutException;
+import org.apache.http.ProtocolSocketFactory;
+import org.apache.http.params.HttpConnectionParams;
+import org.apache.http.params.HttpParams;
 
 /**
  * The default class for creating protocol sockets.  This class just uses the
@@ -56,14 +59,14 @@
      * Gets an singleton instance of the DefaultProtocolSocketFactory.
      * @return a DefaultProtocolSocketFactory
      */
-    static DefaultProtocolSocketFactory getSocketFactory() {
+    public static DefaultProtocolSocketFactory getSocketFactory() {
         return factory;
     }
     
     /**
      * Constructor for DefaultProtocolSocketFactory.
      */
-    public DefaultProtocolSocketFactory() {
+    private DefaultProtocolSocketFactory() {
         super();
     }
 
@@ -111,22 +114,21 @@
         final int port,
         final InetAddress localAddress,
         final int localPort,
-        final HttpConnectionParams params
+        final HttpParams params
     ) throws IOException, UnknownHostException, ConnectTimeoutException {
         if (params == null) {
             throw new IllegalArgumentException("Parameters may not be null");
         }
-        int timeout = params.getConnectionTimeout();
+        HttpConnectionParams connparams = new HttpConnectionParams(params); 
+        int timeout = connparams.getConnectionTimeout();
         if (timeout == 0) {
             return createSocket(host, port, localAddress, localPort);
         } else {
-            // To be eventually deprecated when migrated to Java 1.4 or above
-            Socket socket = ReflectionSocketFactory.createSocket(
-                "javax.net.SocketFactory", host, port, localAddress, localPort, timeout);
-            if (socket == null) {
-                socket = ControllerThreadSocketFactory.createSocket(
-                    this, host, port, localAddress, localPort, timeout);
+            Socket socket = new Socket();
+            if (localAddress != null) {
+                socket.bind(new InetSocketAddress(localAddress, localPort));
             }
+            socket.connect(new InetSocketAddress(host, port), timeout);
             return socket;
         }
     }

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/util/LangUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/util/LangUtils.java?view=diff&r1=159115&r2=159116
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/util/LangUtils.java (original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/util/LangUtils.java Sat
Mar 26 13:13:37 2005
@@ -50,6 +50,10 @@
         return seed * HASH_OFFSET + hashcode;
     }
 
+    public static int hashCode(final int seed, final boolean b) {
+        return hashCode(seed, b ? 1 : 0);
+    }
+    
     public static int hashCode(final int seed, final Object obj) {
         return hashCode(seed, obj != null ? obj.hashCode() : 0);
     }



Mime
View raw message