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 2007/01/26 09:39:21 UTC
svn commit: r500181 -
/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpClientHandler.java
Author: olegk
Date: Fri Jan 26 00:39:20 2007
New Revision: 500181
URL: http://svn.apache.org/viewvc?view=rev&rev=500181
Log:
Populate the context with a default HTTP host based on the inet address of the target host
Modified:
jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpClientHandler.java
Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpClientHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpClientHandler.java?view=diff&rev=500181&r1=500180&r2=500181
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpClientHandler.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpClientHandler.java Fri Jan 26 00:39:20 2007
@@ -40,6 +40,7 @@
import org.apache.http.HttpEntity;
import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.HttpException;
+import org.apache.http.HttpHost;
import org.apache.http.HttpInetConnection;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
@@ -116,6 +117,17 @@
public void connected(final NHttpClientConnection conn, final Object attachment) {
HttpContext context = conn.getContext();
+ // Populate the context with a default HTTP host based on the
+ // inet address of the target host
+ if (conn instanceof HttpInetConnection) {
+ InetAddress address = ((HttpInetConnection) conn).getRemoteAddress();
+ int port = ((HttpInetConnection) conn).getRemotePort();
+ if (address != null) {
+ HttpHost host = new HttpHost(address.getHostName(), port);
+ context.setAttribute(HttpExecutionContext.HTTP_TARGET_HOST, host);
+ }
+ }
+
initialize(conn, attachment);
InputBuffer inbuffer = new InputBuffer(2048);