hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r453172 - in /jakarta/httpcomponents/httpcore/trunk: module-main/src/examples/org/apache/http/examples/ module-main/src/main/java/org/apache/http/ module-main/src/main/java/org/apache/http/impl/ module-main/src/main/java/org/apache/http/pro...
Date Thu, 05 Oct 2006 10:12:33 GMT
Author: olegk
Date: Thu Oct  5 03:12:32 2006
New Revision: 453172

URL: http://svn.apache.org/viewvc?view=rev&rev=453172
Log:
[HTTPCLIENT-602] refactor HttpClientConnection and HttpProxyConnection

Changelog:
----------
* Removed #getTargetHost() method from the HttpClientConnection interface 

Modified:
    jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpGet.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpPost.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpClientConnection.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpProcessor.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpRequestExecutor.java
    jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/BenchmarkWorker.java
    jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/spring/SpringHttpDemo.java

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpGet.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpGet.java?view=diff&rev=453172&r1=453171&r2=453172
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpGet.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpGet.java
Thu Oct  5 03:12:32 2006
@@ -84,9 +84,12 @@
         httpexecutor.setParams(params);
         
         HttpContext context = new HttpExecutionContext(null);
-        
         HttpHost host = new HttpHost("localhost", 8080);
+        context.setAttribute(HttpExecutionContext.HTTP_TARGET_HOST, host);
+
         DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
+        ConnectionReuseStrategy connStrategy = new DefaultConnectionReuseStrategy();
+        
         try {
             
             String[] targets = {
@@ -94,12 +97,10 @@
                     "/servlets-examples/servlet/RequestInfoExample", 
                     "/somewhere%20in%20pampa"};
             
-            ConnectionReuseStrategy connStrategy = new DefaultConnectionReuseStrategy();
-            
             for (int i = 0; i < targets.length; i++) {
                 if (!conn.isOpen()) {
                     Socket socket = new Socket(host.getHostName(), host.getPort());
-                    conn.bind(socket, host, params);
+                    conn.bind(socket, params);
                 }
                 HttpGet request = new HttpGet(targets[i]);
                 System.out.println(">> Request URI: " + request.getRequestLine().getUri());

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpPost.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpPost.java?view=diff&rev=453172&r1=453171&r2=453172
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpPost.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpPost.java
Thu Oct  5 03:12:32 2006
@@ -91,7 +91,11 @@
         HttpContext context = new HttpExecutionContext(null);
         
         HttpHost host = new HttpHost("localhost", 8080);
+        context.setAttribute(HttpExecutionContext.HTTP_TARGET_HOST, host);
+        
         DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
+        ConnectionReuseStrategy connStrategy = new DefaultConnectionReuseStrategy();
+
         try {
             
             HttpEntity[] requestBodies = {
@@ -105,12 +109,10 @@
                                     .getBytes("UTF-8")), -1)
             };
             
-            ConnectionReuseStrategy connStrategy = new DefaultConnectionReuseStrategy();
-            
             for (int i = 0; i < requestBodies.length; i++) {
                 if (!conn.isOpen()) {
                     Socket socket = new Socket(host.getHostName(), host.getPort());
-                    conn.bind(socket, host, params);
+                    conn.bind(socket, params);
                 }
                 HttpPost request = new HttpPost("/servlets-examples/servlet/RequestInfoExample");
                 request.setEntity(requestBodies[i]);

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpClientConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpClientConnection.java?view=diff&rev=453172&r1=453171&r2=453172
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpClientConnection.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpClientConnection.java
Thu Oct  5 03:12:32 2006
@@ -48,13 +48,6 @@
 public interface HttpClientConnection extends HttpConnection {
 
     /**
-     * Returns the current target host.
-     *
-     * @return the target host of this connection
-     */
-    HttpHost getTargetHost();
-
-    /**
      * Checks if response data is available from the connection. May wait for
      * the specified time until some data becomes available. Note that some
      * implementations may completely ignore the timeout parameter.

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java?view=diff&rev=453172&r1=453171&r2=453172
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java
Thu Oct  5 03:12:32 2006
@@ -32,7 +32,6 @@
 import java.io.IOException;
 import java.net.Socket;
 
-import org.apache.http.HttpHost;
 import org.apache.http.params.HttpParams;
 
 /**
@@ -52,9 +51,8 @@
     
     public void bind(
             final Socket socket, 
-            final HttpHost targethost, 
             final HttpParams params) throws IOException {
-        super.bind(socket, targethost, params);
+        super.bind(socket, params);
     }
 
 }

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java?view=diff&rev=453172&r1=453171&r2=453172
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
Thu Oct  5 03:12:32 2006
@@ -32,7 +32,6 @@
 import java.io.IOException;
 import java.net.Socket;
 
-import org.apache.http.HttpHost;
 import org.apache.http.impl.entity.DefaultEntityDeserializer;
 import org.apache.http.impl.entity.DefaultEntitySerializer;
 import org.apache.http.impl.io.SocketHttpDataReceiver;
@@ -54,8 +53,6 @@
  */
 public class SocketHttpClientConnection extends AbstractHttpClientConnection {
 
-    private HttpHost targethost = null;
-
     protected volatile boolean open;
     protected Socket socket = null;
     
@@ -77,14 +74,10 @@
 
     protected void bind(
             final Socket socket, 
-            final HttpHost targethost, 
             final HttpParams params) throws IOException {
         if (socket == null) {
             throw new IllegalArgumentException("Socket may not be null");
         }
-        if (targethost == null) {
-            throw new IllegalArgumentException("Target host may not be null");
-        }
         if (params == null) {
             throw new IllegalArgumentException("HTTP parameters may not be null");
         }
@@ -99,7 +92,6 @@
         }
 
         this.socket = socket;
-        this.targethost = targethost;
         
         int buffersize = HttpConnectionParams.getSocketBufferSize(params);
         HttpDataTransmitter transmitter = new SocketHttpDataTransmitter(socket, buffersize);
@@ -116,10 +108,6 @@
         this.open = true;
     }
 
-    public HttpHost getTargetHost() {
-        return this.targethost;
-    }
-    
     public boolean isOpen() {
         return this.open;
     }

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpProcessor.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpProcessor.java?view=diff&rev=453172&r1=453171&r2=453172
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpProcessor.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpProcessor.java
Thu Oct  5 03:12:32 2006
@@ -29,14 +29,8 @@
 
 package org.apache.http.protocol;
 
-import java.io.IOException;
-
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
 import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.HttpResponse;
 import org.apache.http.HttpResponseInterceptor;
-
 
 /**
  * Performs interceptor processing of requests and responses.

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpRequestExecutor.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpRequestExecutor.java?view=diff&rev=453172&r1=453171&r2=453172
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpRequestExecutor.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpRequestExecutor.java
Thu Oct  5 03:12:32 2006
@@ -141,7 +141,6 @@
             throw new IllegalArgumentException("HTTP context may not be null");
         }
 
-        context.setAttribute(HttpExecutionContext.HTTP_TARGET_HOST, conn.getTargetHost());
         context.setAttribute(HttpExecutionContext.HTTP_CONNECTION, conn);
         context.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
         

Modified: jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/BenchmarkWorker.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/BenchmarkWorker.java?view=diff&rev=453172&r1=453171&r2=453172
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/BenchmarkWorker.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/BenchmarkWorker.java
Thu Oct  5 03:12:32 2006
@@ -112,12 +112,14 @@
             port = 80;
         }
         
+        this.context.setAttribute(HttpExecutionContext.HTTP_TARGET_HOST, targetHost);
+        
         for (int i = 0; i < count; i++) {
             try {
                 resetHeader(request);
                 if (!conn.isOpen()) {
                     Socket socket = new Socket(hostname, port);
-                    conn.bind(socket, targetHost, params);
+                    conn.bind(socket, params);
                 }
                 response = this.httpexecutor.execute(request, conn, this.context);
                 if (this.verbosity >= 3) {

Modified: jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/spring/SpringHttpDemo.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/spring/SpringHttpDemo.java?view=diff&rev=453172&r1=453171&r2=453172
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/spring/SpringHttpDemo.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/spring/SpringHttpDemo.java
Thu Oct  5 03:12:32 2006
@@ -71,12 +71,14 @@
         HttpContext context = new HttpExecutionContext(null);
         DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
         
+        context.setAttribute(HttpExecutionContext.HTTP_TARGET_HOST, host);
+        
         HttpRequestFactory requestfactory = (HttpRequestFactory) beanfactory.getBean("http-request-factory");
         ConnectionReuseStrategy connStrategy = (ConnectionReuseStrategy) beanfactory.getBean("conn-reuse-strategy");
         try {
             if (!conn.isOpen()) {
                 Socket socket = new Socket(host.getHostName(), host.getPort());
-                conn.bind(socket, host, params);
+                conn.bind(socket, params);
             }
             HttpRequest request1 = requestfactory.newHttpRequest("GET", "/");
             HttpResponse response1 = httpexec.execute(request1, conn, context);
@@ -91,7 +93,7 @@
             }
             if (!conn.isOpen()) {
                 Socket socket = new Socket(host.getHostName(), host.getPort());
-                conn.bind(socket, host, params);
+                conn.bind(socket, params);
             }
             HttpRequest request2 = requestfactory.newHttpRequest("GET", "/stuff");
             HttpResponse response2 = httpexec.execute(request2, conn, context);



Mime
View raw message