You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2005/03/26 22:18:40 UTC
svn commit: r159117 - in
jakarta/httpclient/trunk/http-common/src/java/org/apache/http:
ProtocolSocketFactory.java impl/DefaultProtocolSocketFactory.java
Author: olegk
Date: Sat Mar 26 13:18:39 2005
New Revision: 159117
URL: http://svn.apache.org/viewcvs?view=rev&rev=159117
Log:
ProtocolSocketFactory interface simplified
Modified:
jakarta/httpclient/trunk/http-common/src/java/org/apache/http/ProtocolSocketFactory.java
jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultProtocolSocketFactory.java
Modified: 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/ProtocolSocketFactory.java?view=diff&r1=159116&r2=159117
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/ProtocolSocketFactory.java (original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/ProtocolSocketFactory.java Sat Mar 26 13:18:39 2005
@@ -61,27 +61,6 @@
* @param port the port on the host
* @param localAddress the local host name/IP to bind the socket to
* @param localPort the port on the local machine
- *
- * @return Socket a new socket
- *
- * @throws IOException if an I/O error occurs while creating the socket
- * @throws UnknownHostException if the IP address of the host cannot be
- * determined
- */
- Socket createSocket(
- String host,
- int port,
- InetAddress localAddress,
- int localPort
- ) throws IOException, UnknownHostException;
-
- /**
- * Gets a new socket connection to the given host.
- *
- * @param host the host name/IP
- * @param port the port on the host
- * @param localAddress the local host name/IP to bind the socket to
- * @param localPort the port on the local machine
* @param params {@link HttpConnectionParams Http connection parameters}
*
* @return Socket a new socket
@@ -101,22 +80,5 @@
int localPort,
HttpParams params
) throws IOException, UnknownHostException, ConnectTimeoutException;
-
- /**
- * Gets a new socket connection to the given host.
- *
- * @param host the host name/IP
- * @param port the port on the host
- *
- * @return Socket a new socket
- *
- * @throws IOException if an I/O error occurs while creating the socket
- * @throws UnknownHostException if the IP address of the host cannot be
- * determined
- */
- Socket createSocket(
- String host,
- int port
- ) throws IOException, UnknownHostException;
}
Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultProtocolSocketFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultProtocolSocketFactory.java?view=diff&r1=159116&r2=159117
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultProtocolSocketFactory.java (original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultProtocolSocketFactory.java Sat Mar 26 13:18:39 2005
@@ -71,18 +71,6 @@
}
/**
- * @see #createSocket(java.lang.String,int,java.net.InetAddress,int)
- */
- public Socket createSocket(
- String host,
- int port,
- InetAddress localAddress,
- int localPort
- ) throws IOException, UnknownHostException {
- return new Socket(host, port, localAddress, localPort);
- }
-
- /**
* Attempts to get a new socket connection to the given host within the given time limit.
* <p>
* This method employs several techniques to circumvent the limitations of older JREs that
@@ -119,26 +107,14 @@
if (params == null) {
throw new IllegalArgumentException("Parameters may not be null");
}
+ Socket socket = new Socket();
+ if (localAddress != null) {
+ socket.bind(new InetSocketAddress(localAddress, localPort));
+ }
HttpConnectionParams connparams = new HttpConnectionParams(params);
int timeout = connparams.getConnectionTimeout();
- if (timeout == 0) {
- return createSocket(host, port, localAddress, localPort);
- } else {
- Socket socket = new Socket();
- if (localAddress != null) {
- socket.bind(new InetSocketAddress(localAddress, localPort));
- }
- socket.connect(new InetSocketAddress(host, port), timeout);
- return socket;
- }
- }
-
- /**
- * @see ProtocolSocketFactory#createSocket(java.lang.String,int)
- */
- public Socket createSocket(String host, int port)
- throws IOException, UnknownHostException {
- return new Socket(host, port);
+ socket.connect(new InetSocketAddress(host, port), timeout);
+ return socket;
}
/**