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 2011/08/16 17:00:09 UTC
svn commit: r1158312 - in
/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn:
HttpInetSocketAddress.java scheme/LayeredSchemeSocketFactory.java
scheme/SchemeSocketFactory.java ssl/SSLSocketFactory.java
Author: olegk
Date: Tue Aug 16 15:00:08 2011
New Revision: 1158312
URL: http://svn.apache.org/viewvc?rev=1158312&view=rev
Log:
Tweaked HttpInetSocketAddress class; updated javadocs
Modified:
httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpInetSocketAddress.java
httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/LayeredSchemeSocketFactory.java
httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeSocketFactory.java
httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpInetSocketAddress.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpInetSocketAddress.java?rev=1158312&r1=1158311&r2=1158312&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpInetSocketAddress.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpInetSocketAddress.java Tue Aug 16 15:00:08 2011
@@ -41,24 +41,23 @@ public class HttpInetSocketAddress exten
private static final long serialVersionUID = -6650701828361907957L;
- private final HttpHost host;
+ private final HttpHost httphost;
- public HttpInetSocketAddress(final HttpHost host, final InetAddress addr, int port) {
+ public HttpInetSocketAddress(final HttpHost httphost, final InetAddress addr, int port) {
super(addr, port);
- if (host == null) {
+ if (httphost == null) {
throw new IllegalArgumentException("HTTP host may not be null");
}
- this.host = host;
+ this.httphost = httphost;
}
- public HttpHost getHost() {
- return this.host;
+ public HttpHost getHttpHost() {
+ return this.httphost;
}
@Override
public String toString() {
- return this.host.getHostName() + ":" + getPort();
+ return this.httphost.getHostName() + ":" + getPort();
}
-
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/LayeredSchemeSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/LayeredSchemeSocketFactory.java?rev=1158312&r1=1158311&r2=1158312&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/LayeredSchemeSocketFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/LayeredSchemeSocketFactory.java Tue Aug 16 15:00:08 2011
@@ -32,8 +32,7 @@ import java.net.Socket;
import java.net.UnknownHostException;
/**
- * A {@link SocketFactory SocketFactory} for layered sockets (SSL/TLS).
- * See there for things to consider when implementing a socket factory.
+ * Extended {@link SchemeSocketFactory} interface for layered sockets such as SSL/TLS.
*
* @since 4.1
*/
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeSocketFactory.java?rev=1158312&r1=1158311&r2=1158312&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeSocketFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeSocketFactory.java Tue Aug 16 15:00:08 2011
@@ -32,7 +32,9 @@ import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
+import org.apache.http.HttpHost;
import org.apache.http.conn.ConnectTimeoutException;
+import org.apache.http.conn.HttpInetSocketAddress;
import org.apache.http.params.HttpParams;
/**
@@ -63,12 +65,17 @@ public interface SchemeSocketFactory {
/**
* Connects a socket to the target host with the given remote address.
+ * <p/>
+ * Please note that {@link HttpInetSocketAddress} class should be used in order to pass
+ * the target remote address along with the original {@link HttpHost} value used to resolve
+ * the address. The use of {@link HttpInetSocketAddress} can also ensure that no reverse
+ * DNS lookup will be performed if the target remote address was specified as an IP address.
*
* @param sock the socket to connect, as obtained from
* {@link #createSocket(HttpParams) createSocket}.
* <code>null</code> indicates that a new socket
* should be created and connected.
- * @param remoteAddress the remote address to connect to
+ * @param remoteAddress the remote address to connect to.
* @param localAddress the local address to bind the socket to, or
* <code>null</code> for any
* @param params additional {@link HttpParams parameters} for connecting
@@ -82,6 +89,8 @@ public interface SchemeSocketFactory {
* can not be determined
* @throws ConnectTimeoutException if the socket cannot be connected
* within the time limit defined in the <code>params</code>
+ *
+ * @see HttpInetSocketAddress
*/
Socket connectSocket(
Socket sock,
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java?rev=1158312&r1=1158311&r2=1158312&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java Tue Aug 16 15:00:08 2011
@@ -385,7 +385,7 @@ public class SSLSocketFactory implements
String hostname;
if (remoteAddress instanceof HttpInetSocketAddress) {
- hostname = ((HttpInetSocketAddress) remoteAddress).getHost().getHostName();
+ hostname = ((HttpInetSocketAddress) remoteAddress).getHttpHost().getHostName();
} else {
hostname = remoteAddress.getHostName();
}
@@ -395,8 +395,8 @@ public class SSLSocketFactory implements
if (sock instanceof SSLSocket) {
sslsock = (SSLSocket) sock;
} else {
- sslsock = (SSLSocket) this.socketfactory.createSocket(sock,
- hostname, remoteAddress.getPort(), true);
+ int port = remoteAddress.getPort();
+ sslsock = (SSLSocket) this.socketfactory.createSocket(sock, hostname, port, true);
prepareSocket(sslsock);
}
if (this.hostnameVerifier != null) {