hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r451396 - in /jakarta/httpcomponents/httpcore/trunk: module-main/src/main/java/org/apache/http/ module-main/src/main/java/org/apache/http/params/ module-main/src/main/java/org/apache/http/protocol/ module-main/src/test/java/org/apache/http/...
Date Fri, 29 Sep 2006 19:27:42 GMT
Author: olegk
Date: Fri Sep 29 12:27:41 2006
New Revision: 451396

URL: http://svn.apache.org/viewvc?view=rev&rev=451396
Log:
[HTTPCORE-14] Consider decoupling HttpHost and Scheme and moving Scheme, SocketFactory and
SecureSocketFactory to HttpConn

Changelog:
----------
* HttpHost is no longer coupled with the Scheme class
* ProxyHost removed 

Removed:
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/ProxyHost.java
Modified:
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpHost.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpProtocolParams.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/RequestTargetHost.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/TestHttpHost.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
    jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/BenchmarkWorker.java
    jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/HttpBenchmark.java
    jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/spring/SpringHttpDemo.java
    jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/spring/http-beans.xml

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpHost.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpHost.java?view=diff&rev=451396&r1=451395&r2=451396
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpHost.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpHost.java
Fri Sep 29 12:27:41 2006
@@ -45,6 +45,8 @@
  */
 public class HttpHost {
 
+    public static final String DEFAULT_SCHEME_NAME = "http";
+    
     /** The host to use. */
     private String hostname = null;
 
@@ -52,30 +54,28 @@
     private int port = -1;
 
     /** The scheme */
-    private Scheme scheme = null;
+    private String schemeName = null;
 
     /**
      * Constructor for HttpHost.
      *   
      * @param hostname the hostname (IP or DNS name). Can be <code>null</code>.
      * @param port the port. Value <code>-1</code> can be used to set default
scheme port
-     * @param scheme the scheme. Value <code>null</code> can be used to set default
scheme
+     * @param schemeName the name of the scheme. Value <code>null</code> can
be used to set 
+     *        default scheme
      */
-    public HttpHost(final String hostname, int port, final Scheme scheme) {
+    public HttpHost(final String hostname, int port, final String schemeName) {
         super();
         if (hostname == null) {
             throw new IllegalArgumentException("Host name may not be null");
         }
-        if (scheme == null) {
-            throw new IllegalArgumentException("Protocol may not be null");
-        }
         this.hostname = hostname;
-        this.scheme = scheme;
-        if (port >= 0) {
-            this.port = port;
+        if (schemeName != null) {
+            this.schemeName = schemeName.toLowerCase();
         } else {
-            this.port = this.scheme.getDefaultPort();
+            this.schemeName = DEFAULT_SCHEME_NAME;
         }
+        this.port = port;
     }
 
     /**
@@ -85,7 +85,7 @@
      * @param port the port. Value <code>-1</code> can be used to set default
scheme port
      */
     public HttpHost(final String hostname, int port) {
-        this(hostname, port, Scheme.getScheme("http"));
+        this(hostname, port, null);
     }
     
     /**
@@ -94,7 +94,7 @@
      * @param hostname the hostname (IP or DNS name). Can be <code>null</code>.
      */
     public HttpHost(final String hostname) {
-        this(hostname, -1, Scheme.getScheme("http"));
+        this(hostname, -1, null);
     }
     
     /**
@@ -106,7 +106,7 @@
         super();
         this.hostname = httphost.hostname;
         this.port = httphost.port;
-        this.scheme = httphost.scheme;
+        this.schemeName = httphost.schemeName;
     }
 
     /**
@@ -131,8 +131,8 @@
      * Returns the scheme.
      * @return The scheme.
      */
-    public Scheme getScheme() {
-        return this.scheme;
+    public String getSchemeName() {
+        return this.schemeName;
     }
 
     /**
@@ -142,10 +142,10 @@
      */
     public String toURI() {
     	CharArrayBuffer buffer = new CharArrayBuffer(32);        
-        buffer.append(this.scheme.getName());
+        buffer.append(this.schemeName);
         buffer.append("://");
         buffer.append(this.hostname);
-        if (this.port != this.scheme.getDefaultPort()) {
+        if (this.port != -1) {
             buffer.append(':');
             buffer.append(Integer.toString(this.port));
         }
@@ -155,7 +155,7 @@
     public String toHostString() {
     	CharArrayBuffer buffer = new CharArrayBuffer(32);        
         buffer.append(this.hostname);
-        if (this.port != this.scheme.getDefaultPort()) {
+        if (this.port != -1) {
             buffer.append(':');
             buffer.append(Integer.toString(this.port));
         }
@@ -179,7 +179,7 @@
             HttpHost that = (HttpHost) obj;
             return this.hostname.equalsIgnoreCase(that.hostname) 
                 && this.port == that.port
-                && this.scheme.equals(that.scheme);
+                && this.schemeName.equals(that.schemeName);
         } else {
             return false;
         }
@@ -192,7 +192,7 @@
         int hash = LangUtils.HASH_SEED;
         hash = LangUtils.hashCode(hash, this.hostname.toUpperCase());
         hash = LangUtils.hashCode(hash, this.port);
-        hash = LangUtils.hashCode(hash, this.scheme);
+        hash = LangUtils.hashCode(hash, this.schemeName);
         return hash;
     }
 

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpProtocolParams.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpProtocolParams.java?view=diff&rev=451396&r1=451395&r2=451396
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpProtocolParams.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpProtocolParams.java
Fri Sep 29 12:27:41 2006
@@ -105,14 +105,6 @@
     public static final String STATUS_LINE_GARBAGE_LIMIT = "http.protocol.status-line-garbage-limit";
 
     /**
-     * Defines the virtual host name.
-     * <p>
-     * This parameter expects a value of type {@link java.lang.String}. 
-     * </p>
-     */
-    public static final String VIRTUAL_HOST = "http.virtual-host"; 
-
-    /**
      * Defines whether responses with an invalid <tt>Transfer-Encoding</tt> header
should be 
      * rejected.
      * <p>
@@ -237,30 +229,6 @@
         params.setParameter(PROTOCOL_VERSION, version);
     }
 
-    /**
-     * Sets the virtual host name.
-     * 
-     * @param hostname The host name
-     */
-    public static void setVirtualHost(final HttpParams params, final String hostname) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
-        params.setParameter(VIRTUAL_HOST, hostname);
-    }
-
-    /**
-     * Returns the virtual host name.
-     * 
-     * @return The virtual host name
-     */
-    public static String getVirtualHost(final HttpParams params) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
-        return (String) params.getParameter(VIRTUAL_HOST);
-    }
-    
     public static String getUserAgent(final HttpParams params) { 
         if (params == null) {
             throw new IllegalArgumentException("HTTP parameters may not be null");

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/RequestTargetHost.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/RequestTargetHost.java?view=diff&rev=451396&r1=451395&r2=451396
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/RequestTargetHost.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/RequestTargetHost.java
Fri Sep 29 12:27:41 2006
@@ -37,7 +37,6 @@
 import org.apache.http.HttpRequestInterceptor;
 import org.apache.http.HttpVersion;
 import org.apache.http.ProtocolException;
-import org.apache.http.params.HttpProtocolParams;
 
 /**
  * A request interceptor that sets the Host header for HTTP/1.1 requests.
@@ -72,11 +71,6 @@
                 } else {
                     throw new ProtocolException("Target host missing");
                 }
-            }
-            String virtualhost = HttpProtocolParams.getVirtualHost(request.getParams());
-            if (virtualhost != null) {
-                targethost = new HttpHost(virtualhost, 
-                        targethost.getPort(), targethost.getScheme());
             }
             request.addHeader(HTTP.TARGET_HOST, targethost.toHostString());
         }

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/TestHttpHost.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/TestHttpHost.java?view=diff&rev=451396&r1=451395&r2=451396
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/TestHttpHost.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/TestHttpHost.java
Fri Sep 29 12:27:41 2006
@@ -29,9 +29,6 @@
 
 package org.apache.http;
 
-import org.apache.http.impl.io.PlainSocketFactory;
-import org.apache.http.io.SocketFactory;
-
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
@@ -56,69 +53,38 @@
         return new TestSuite(TestHttpHost.class);
     }
 
-    protected void setUp() throws Exception {
-        super.setUp();
-        SocketFactory socketfactory = PlainSocketFactory.getSocketFactory();
-        final Scheme http = new Scheme("http", socketfactory, 80);
-        Scheme.registerScheme("http", http);
-    }
-    
     public void testConstructor() {
-        Scheme http = Scheme.getScheme("http");
         HttpHost host1 = new HttpHost("somehost");
         assertEquals("somehost", host1.getHostName()); 
-        assertEquals(http.getDefaultPort(), host1.getPort()); 
-        assertEquals(http, host1.getScheme()); 
+        assertEquals(-1, host1.getPort()); 
+        assertEquals("http", host1.getSchemeName()); 
         HttpHost host2 = new HttpHost("somehost", 8080);
         assertEquals("somehost", host2.getHostName()); 
         assertEquals(8080, host2.getPort()); 
-        assertEquals(http, host2.getScheme()); 
+        assertEquals("http", host2.getSchemeName()); 
         HttpHost host3 = new HttpHost("somehost", -1);
         assertEquals("somehost", host3.getHostName()); 
-        assertEquals(http.getDefaultPort(), host3.getPort()); 
-        assertEquals(http, host3.getScheme()); 
-        HttpHost host4 = new HttpHost("somehost", 8080, http);
+        assertEquals(-1, host3.getPort()); 
+        assertEquals("http", host3.getSchemeName()); 
+        HttpHost host4 = new HttpHost("somehost", 443, "https");
         assertEquals("somehost", host4.getHostName()); 
-        assertEquals(8080, host4.getPort()); 
-        assertEquals(http, host4.getScheme()); 
+        assertEquals(443, host4.getPort()); 
+        assertEquals("https", host4.getSchemeName()); 
         try {
             new HttpHost(null, -1, null);
             fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             //expected
         }
-        try {
-            new HttpHost("somehost", -1, null);
-            fail("IllegalArgumentException should have been thrown");
-        } catch (IllegalArgumentException ex) {
-            //expected
-        }
-        ProxyHost proxyhost1 = new ProxyHost("somehost");
-        assertEquals("somehost", proxyhost1.getHostName()); 
-        assertEquals(http.getDefaultPort(), proxyhost1.getPort()); 
-        assertEquals(http, proxyhost1.getScheme()); 
-
-        ProxyHost proxyhost2 = new ProxyHost("somehost", 8080);
-        assertEquals("somehost", proxyhost2.getHostName()); 
-        assertEquals(8080, proxyhost2.getPort()); 
-        assertEquals(http, proxyhost2.getScheme()); 
-
-        ProxyHost proxyhost3 = new ProxyHost(proxyhost2);
-        assertEquals("somehost", proxyhost3.getHostName()); 
-        assertEquals(8080, proxyhost3.getPort()); 
-        assertEquals(http, proxyhost3.getScheme()); 
     }
     
     public void testHashCode() {
-        Scheme http = Scheme.getScheme("http");
-        Scheme myhttp = new Scheme("myhttp", 
-                PlainSocketFactory.getSocketFactory(), 8080);
-        HttpHost host1 = new HttpHost("somehost", 8080, http);
-        HttpHost host2 = new HttpHost("somehost", 80, http);
-        HttpHost host3 = new HttpHost("someotherhost", 8080, http);
-        HttpHost host4 = new HttpHost("somehost", 80, http);
-        HttpHost host5 = new HttpHost("SomeHost", 80, http);
-        HttpHost host6 = new HttpHost("SomeHost", 80, myhttp);
+        HttpHost host1 = new HttpHost("somehost", 8080, "http");
+        HttpHost host2 = new HttpHost("somehost", 80, "http");
+        HttpHost host3 = new HttpHost("someotherhost", 8080, "http");
+        HttpHost host4 = new HttpHost("somehost", 80, "http");
+        HttpHost host5 = new HttpHost("SomeHost", 80, "http");
+        HttpHost host6 = new HttpHost("SomeHost", 80, "myhttp");
 
         assertTrue(host1.hashCode() == host1.hashCode());
         assertTrue(host1.hashCode() != host2.hashCode());
@@ -129,15 +95,12 @@
     }
     
     public void testEquals() {
-        Scheme http = Scheme.getScheme("http");
-        Scheme myhttp = new Scheme("myhttp", 
-        		PlainSocketFactory.getSocketFactory(), 8080);
-        HttpHost host1 = new HttpHost("somehost", 8080, http);
-        HttpHost host2 = new HttpHost("somehost", 80, http);
-        HttpHost host3 = new HttpHost("someotherhost", 8080, http);
-        HttpHost host4 = new HttpHost("somehost", 80, http);
-        HttpHost host5 = new HttpHost("SomeHost", 80, http);
-        HttpHost host6 = new HttpHost("SomeHost", 80, myhttp);
+        HttpHost host1 = new HttpHost("somehost", 8080, "http");
+        HttpHost host2 = new HttpHost("somehost", 80, "http");
+        HttpHost host3 = new HttpHost("someotherhost", 8080, "http");
+        HttpHost host4 = new HttpHost("somehost", 80, "http");
+        HttpHost host5 = new HttpHost("SomeHost", 80, "http");
+        HttpHost host6 = new HttpHost("SomeHost", 80, "myhttp");
 
         assertTrue(host1.equals(host1));
         assertFalse(host1.equals(host2));
@@ -150,28 +113,24 @@
     }
     
     public void testToString() {
-        Scheme http = Scheme.getScheme("http");
-        Scheme myhttp = new Scheme("myhttp", 
-        		PlainSocketFactory.getSocketFactory(), 8080);
         HttpHost host1 = new HttpHost("somehost");
         assertEquals("http://somehost", host1.toString());
-        HttpHost host2 = new HttpHost("somehost", http.getDefaultPort());
+        HttpHost host2 = new HttpHost("somehost", -1);
         assertEquals("http://somehost", host2.toString());
         HttpHost host3 = new HttpHost("somehost", -1);
         assertEquals("http://somehost", host3.toString());
         HttpHost host4 = new HttpHost("somehost", 8888);
         assertEquals("http://somehost:8888", host4.toString());
-        HttpHost host5 = new HttpHost("somehost", -1, myhttp);
+        HttpHost host5 = new HttpHost("somehost", -1, "myhttp");
         assertEquals("myhttp://somehost", host5.toString());
-        HttpHost host6 = new HttpHost("somehost", 80, myhttp);
+        HttpHost host6 = new HttpHost("somehost", 80, "myhttp");
         assertEquals("myhttp://somehost:80", host6.toString());
     }
 
     public void testToHostString() {
-        Scheme http = Scheme.getScheme("http");
         HttpHost host1 = new HttpHost("somehost");
         assertEquals("somehost", host1.toHostString());
-        HttpHost host2 = new HttpHost("somehost", http.getDefaultPort());
+        HttpHost host2 = new HttpHost("somehost");
         assertEquals("somehost", host2.toHostString());
         HttpHost host3 = new HttpHost("somehost", -1);
         assertEquals("somehost", host3.toHostString());

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java?view=diff&rev=451396&r1=451395&r2=451396
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
Fri Sep 29 12:27:41 2006
@@ -39,10 +39,8 @@
 import org.apache.http.HttpStatus;
 import org.apache.http.HttpVersion;
 import org.apache.http.ProtocolException;
-import org.apache.http.Scheme;
 import org.apache.http.entity.BasicHttpEntity;
 import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.io.PlainSocketFactory;
 import org.apache.http.message.BasicHeader;
 import org.apache.http.message.BasicHttpEntityEnclosingRequest;
 import org.apache.http.message.BasicHttpRequest;
@@ -339,8 +337,7 @@
 
     public void testRequestTargetHostGenerated() throws Exception {
         HttpContext context = new HttpExecutionContext(null);
-        Scheme http = new Scheme("http", PlainSocketFactory.getSocketFactory(), 80);
-        HttpHost host = new HttpHost("somehost", 8080, http);
+        HttpHost host = new HttpHost("somehost", 8080, "http");
         context.setAttribute(HttpExecutionContext.HTTP_TARGET_HOST, host);
         BasicHttpRequest request = new BasicHttpRequest("GET", "/");
         RequestTargetHost interceptor = new RequestTargetHost();
@@ -352,8 +349,7 @@
 
     public void testRequestTargetHostNotGenerated() throws Exception {
         HttpContext context = new HttpExecutionContext(null);
-        Scheme http = new Scheme("http", PlainSocketFactory.getSocketFactory(), 80);
-        HttpHost host = new HttpHost("somehost", 8080, http);
+        HttpHost host = new HttpHost("somehost", 8080, "http");
         context.setAttribute(HttpExecutionContext.HTTP_TARGET_HOST, host);
         BasicHttpRequest request = new BasicHttpRequest("GET", "/");
         request.addHeader(new BasicHeader(HTTP.TARGET_HOST, "whatever"));
@@ -384,20 +380,6 @@
         } catch (ProtocolException ex) {
             // expected
         }
-    }
-
-    public void testRequestTargetHostVirtualHost() throws Exception {
-        HttpContext context = new HttpExecutionContext(null);
-        Scheme http = new Scheme("http", PlainSocketFactory.getSocketFactory(), 80);
-        HttpHost host = new HttpHost("somehost", 8080, http);
-        context.setAttribute(HttpExecutionContext.HTTP_TARGET_HOST, host);
-        BasicHttpRequest request = new BasicHttpRequest("GET", "/");
-        request.getParams().setParameter(HttpProtocolParams.VIRTUAL_HOST, "whatever");
-        RequestTargetHost interceptor = new RequestTargetHost();
-        interceptor.process(request, context);
-        Header header = request.getFirstHeader(HTTP.TARGET_HOST);
-        assertNotNull(header);
-        assertEquals("whatever:8080", header.getValue());
     }
 
     public void testRequestTargetHostInvalidInput() throws Exception {

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=451396&r1=451395&r2=451396
==============================================================================
--- 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
Fri Sep 29 12:27:41 2006
@@ -42,7 +42,6 @@
 import org.apache.http.HttpResponse;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpClientConnection;
-import org.apache.http.io.SocketFactory;
 import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.BasicHttpProcessor;
 import org.apache.http.protocol.HTTP;
@@ -106,14 +105,18 @@
         DefaultHttpClientConnection conn = new DefaultHttpClientConnection(); 
         Stats stats = new Stats();
         stats.start();
+        
+        String hostname = targetHost.getHostName();
+        int port = targetHost.getPort();
+        if (port == -1) {
+            port = 80;
+        }
+        
         for (int i = 0; i < count; i++) {
             try {
                 resetHeader(request);
                 if (!conn.isOpen()) {
-                    SocketFactory socketfactory = targetHost.getScheme().getSocketFactory();
-                    Socket socket = socketfactory.createSocket(
-                            targetHost.getHostName(), targetHost.getPort(), 
-                            null, 0, params);
+                    Socket socket = new Socket(hostname, port);
                     conn.bind(socket, targetHost, params);
                 }
                 response = this.httpexecutor.execute(request, conn, this.context);

Modified: jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/HttpBenchmark.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/HttpBenchmark.java?view=diff&rev=451396&r1=451395&r2=451396
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/HttpBenchmark.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/HttpBenchmark.java
Fri Sep 29 12:27:41 2006
@@ -41,11 +41,8 @@
 import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpVersion;
-import org.apache.http.Scheme;
 import org.apache.http.entity.FileEntity;
 import org.apache.http.impl.DefaultHttpParams;
-import org.apache.http.impl.io.PlainSocketFactory;
-import org.apache.http.impl.io.SSLSocketFactory;
 import org.apache.http.message.HttpGet;
 import org.apache.http.message.HttpHead;
 import org.apache.http.message.HttpPost;
@@ -174,17 +171,11 @@
         // Parse the target url 
         URL url = new URL(args[0]); 
         
-        // Register standard protocol schemes 
-        Scheme.registerScheme("http", 
-                new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
-        Scheme.registerScheme("https", 
-                new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
-
         // Prepare connection
         HttpHost host = new HttpHost(
                 url.getHost(), 
                 url.getPort(), 
-                Scheme.getScheme(url.getProtocol()));
+                url.getProtocol());
         
         // Prepare request
         HttpRequest request = null;
@@ -248,7 +239,7 @@
         if (host.getPort() > 0) {
             System.out.println(host.getPort());
         } else {
-            System.out.println(host.getScheme().getDefaultPort());
+            System.out.println("80");
         }
         System.out.println();
         System.out.print("Document Path:\t\t");

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=451396&r1=451395&r2=451396
==============================================================================
--- 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
Fri Sep 29 12:27:41 2006
@@ -36,9 +36,7 @@
 import org.apache.http.HttpRequestFactory;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpVersion;
-import org.apache.http.Scheme;
 import org.apache.http.impl.DefaultHttpClientConnection;
-import org.apache.http.io.SocketFactory;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpProtocolParams;
 import org.apache.http.protocol.HttpContext;
@@ -68,20 +66,16 @@
         HttpRequestExecutor httpexec = (HttpRequestExecutor)beanfactory.getBean("http-executor");
         httpexec.setParams(params);
         
-        Scheme http = (Scheme) beanfactory.getBean("http-scheme");
-        HttpHost host = new HttpHost("www.yahoo.com", 80, http);
+        HttpHost host = new HttpHost("www.yahoo.com", 80);
 
         HttpContext context = new HttpExecutionContext(null);
+        DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
         
         HttpRequestFactory requestfactory = (HttpRequestFactory) beanfactory.getBean("http-request-factory");
-        DefaultHttpClientConnection conn = (DefaultHttpClientConnection) beanfactory.getBean("http-connection");
         ConnectionReuseStrategy connStrategy = (ConnectionReuseStrategy) beanfactory.getBean("conn-reuse-strategy");
         try {
             if (!conn.isOpen()) {
-                SocketFactory socketfactory = host.getScheme().getSocketFactory();
-                Socket socket = socketfactory.createSocket(
-                        host.getHostName(), host.getPort(), 
-                        null, 0, params);
+                Socket socket = new Socket(host.getHostName(), host.getPort());
                 conn.bind(socket, host, params);
             }
             HttpRequest request1 = requestfactory.newHttpRequest("GET", "/");
@@ -96,10 +90,7 @@
                 System.out.println("Connection closed...");
             }
             if (!conn.isOpen()) {
-                SocketFactory socketfactory = host.getScheme().getSocketFactory();
-                Socket socket = socketfactory.createSocket(
-                        host.getHostName(), host.getPort(), 
-                        null, 0, params);
+                Socket socket = new Socket(host.getHostName(), host.getPort());
                 conn.bind(socket, host, params);
             }
             HttpRequest request2 = requestfactory.newHttpRequest("GET", "/stuff");

Modified: jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/spring/http-beans.xml
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/spring/http-beans.xml?view=diff&rev=451396&r1=451395&r2=451396
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/spring/http-beans.xml
(original)
+++ jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/spring/http-beans.xml
Fri Sep 29 12:27:41 2006
@@ -13,17 +13,6 @@
     <property name="defaults"><ref bean="global-params"/></property>
   </bean>
 
-  <bean id="socket-factory" 
-    class="org.apache.http.impl.io.PlainSocketFactory" 
-    singleton="true" />
-    
-  <bean id="http-scheme" 
-    class="org.apache.http.Scheme">
-    <constructor-arg index="0"><value>http</value></constructor-arg>
-    <constructor-arg index="1"><ref bean="socket-factory"/></constructor-arg>
-    <constructor-arg index="2"><value>80</value></constructor-arg>
-  </bean>
-  
   <bean id="http-processor" 
     class="org.apache.http.protocol.BasicHttpProcessor" 
     singleton="true" >
@@ -54,11 +43,6 @@
     class="org.apache.http.impl.DefaultHttpResponseFactory" 
     singleton="false" />
   
-  <bean id="http-connection" 
-    class="org.apache.http.impl.DefaultHttpClientConnection" 
-    singleton="false">
-  </bean>
-
   <bean id="conn-reuse-strategy"
     class="org.apache.http.impl.DefaultConnectionReuseStrategy" 
     singleton="true" />



Mime
View raw message