hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1389028 - in /httpcomponents/httpcore/trunk: httpcore-nio/src/main/java/org/apache/http/impl/nio/ httpcore/src/examples/org/apache/http/examples/ httpcore/src/main/java/org/apache/http/impl/ httpcore/src/main/java/org/apache/http/impl/pool...
Date Sun, 23 Sep 2012 12:15:05 GMT
Author: olegk
Date: Sun Sep 23 12:15:04 2012
New Revision: 1389028

URL: http://svn.apache.org/viewvc?rev=1389028&view=rev
Log:
Rewrite of blocking HTTP connection implementations: deprecated DefaultHttpClientConnection / DefaultHttpServerConnection and related classes in favor of DefaultBHttpClientConnection / DefaultBHttpServerConnection

Added:
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java   (with props)
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java   (with props)
Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
    httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpGet.java
    httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpPost.java
    httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpServer.java
    httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalReverseProxy.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpServerConnection.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpServer.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java?rev=1389028&r1=1389027&r2=1389028&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java Sun Sep 23 12:15:04 2012
@@ -85,10 +85,9 @@ import org.apache.http.util.CharsetUtils
 import org.apache.http.util.NetUtils;
 
 /**
- * This class serves as a base for all {@link NHttpConnection} implementations
- * and implements functionality common to both client and server
- * HTTP connections.
- * <p>
+ * This class serves as a base for all {@link NHttpConnection} implementations and provides
+ * functionality common to both client and server HTTP connections.
+ * <p/>
  * The following parameters can be used to customize the behavior of this
  * class:
  * <ul>

Modified: httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpGet.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpGet.java?rev=1389028&r1=1389027&r2=1389028&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpGet.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpGet.java Sun Sep 23 12:15:04 2012
@@ -34,8 +34,8 @@ import org.apache.http.HttpHost;
 import org.apache.http.HttpRequestInterceptor;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpVersion;
+import org.apache.http.impl.DefaultBHttpClientConnection;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
-import org.apache.http.impl.DefaultHttpClientConnection;
 import org.apache.http.message.BasicHttpRequest;
 import org.apache.http.params.HttpCoreConfigBuilder;
 import org.apache.http.params.HttpParams;
@@ -81,7 +81,7 @@ public class ElementalHttpGet {
         HttpContext context = new BasicHttpContext(null);
         HttpHost host = new HttpHost("localhost", 8080);
 
-        DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
+        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(params);
         ConnectionReuseStrategy connStrategy = DefaultConnectionReuseStrategy.INSTANCE;
 
         context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
@@ -97,7 +97,7 @@ public class ElementalHttpGet {
             for (int i = 0; i < targets.length; i++) {
                 if (!conn.isOpen()) {
                     Socket socket = new Socket(host.getHostName(), host.getPort());
-                    conn.bind(socket, params);
+                    conn.bind(socket);
                 }
                 BasicHttpRequest request = new BasicHttpRequest("GET", targets[i]);
                 System.out.println(">> Request URI: " + request.getRequestLine().getUri());

Modified: httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpPost.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpPost.java?rev=1389028&r1=1389027&r2=1389028&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpPost.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpPost.java Sun Sep 23 12:15:04 2012
@@ -39,8 +39,8 @@ import org.apache.http.HttpVersion;
 import org.apache.http.entity.ByteArrayEntity;
 import org.apache.http.entity.InputStreamEntity;
 import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.DefaultBHttpClientConnection;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
-import org.apache.http.impl.DefaultHttpClientConnection;
 import org.apache.http.message.BasicHttpEntityEnclosingRequest;
 import org.apache.http.params.HttpCoreConfigBuilder;
 import org.apache.http.params.HttpParams;
@@ -88,7 +88,7 @@ public class ElementalHttpPost {
 
         HttpHost host = new HttpHost("localhost", 8080);
 
-        DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
+        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(params);
         ConnectionReuseStrategy connStrategy = DefaultConnectionReuseStrategy.INSTANCE;
 
         context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
@@ -110,7 +110,7 @@ public class ElementalHttpPost {
             for (int i = 0; i < requestBodies.length; i++) {
                 if (!conn.isOpen()) {
                     Socket socket = new Socket(host.getHostName(), host.getPort());
-                    conn.bind(socket, params);
+                    conn.bind(socket);
                 }
                 BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST",
                         "/servlets-examples/servlet/RequestInfoExample");

Modified: httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpServer.java?rev=1389028&r1=1389027&r2=1389028&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpServer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpServer.java Sun Sep 23 12:15:04 2012
@@ -49,9 +49,9 @@ import org.apache.http.MethodNotSupporte
 import org.apache.http.entity.ContentType;
 import org.apache.http.entity.FileEntity;
 import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.DefaultBHttpServerConnection;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
-import org.apache.http.impl.DefaultHttpServerConnection;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.CoreConnectionPNames;
 import org.apache.http.params.CoreProtocolPNames;
@@ -190,9 +190,9 @@ public class ElementalHttpServer {
                 try {
                     // Set up HTTP connection
                     Socket socket = this.serversocket.accept();
-                    DefaultHttpServerConnection conn = new DefaultHttpServerConnection();
+                    DefaultBHttpServerConnection conn = new DefaultBHttpServerConnection(this.params);
                     System.out.println("Incoming connection from " + socket.getInetAddress());
-                    conn.bind(socket, this.params);
+                    conn.bind(socket);
 
                     // Start worker thread
                     Thread t = new WorkerThread(this.httpService, conn);

Modified: httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalReverseProxy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalReverseProxy.java?rev=1389028&r1=1389027&r2=1389028&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalReverseProxy.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalReverseProxy.java Sun Sep 23 12:15:04 2012
@@ -42,10 +42,10 @@ import org.apache.http.HttpRequestInterc
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpResponseInterceptor;
 import org.apache.http.HttpServerConnection;
+import org.apache.http.impl.DefaultBHttpClientConnection;
+import org.apache.http.impl.DefaultBHttpServerConnection;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
-import org.apache.http.impl.DefaultHttpClientConnection;
 import org.apache.http.impl.DefaultHttpResponseFactory;
-import org.apache.http.impl.DefaultHttpServerConnection;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.CoreConnectionPNames;
 import org.apache.http.params.CoreProtocolPNames;
@@ -230,14 +230,14 @@ public class ElementalReverseProxy {
                 try {
                     // Set up incoming HTTP connection
                     Socket insocket = this.serversocket.accept();
-                    DefaultHttpServerConnection inconn = new DefaultHttpServerConnection();
+                    DefaultBHttpServerConnection inconn = new DefaultBHttpServerConnection(this.params);
                     System.out.println("Incoming connection from " + insocket.getInetAddress());
-                    inconn.bind(insocket, this.params);
+                    inconn.bind(insocket);
 
                     // Set up outgoing HTTP connection
                     Socket outsocket = new Socket(this.target.getHostName(), this.target.getPort());
-                    DefaultHttpClientConnection outconn = new DefaultHttpClientConnection();
-                    outconn.bind(outsocket, this.params);
+                    DefaultBHttpClientConnection outconn = new DefaultBHttpClientConnection(this.params);
+                    outconn.bind(outsocket);
                     System.out.println("Outgoing connection to " + outsocket.getInetAddress());
 
                     // Start worker thread

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java?rev=1389028&r1=1389027&r2=1389028&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java Sun Sep 23 12:15:04 2012
@@ -71,8 +71,11 @@ import org.apache.http.util.Args;
  * </ul>
  *
  * @since 4.0
+ *
+ * @deprecated (4.3) use {@link DefaultBHttpClientConnection}
  */
 @NotThreadSafe
+@Deprecated
 public abstract class AbstractHttpClientConnection implements HttpClientConnection {
 
     private final EntitySerializer entityserializer;

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java?rev=1389028&r1=1389027&r2=1389028&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java Sun Sep 23 12:15:04 2012
@@ -71,8 +71,11 @@ import org.apache.http.util.Args;
  * </ul>
  *
  * @since 4.0
+ *
+ * @deprecated (4.3) use {@link DefaultBHttpServerConnection}
  */
 @NotThreadSafe
+@Deprecated
 public abstract class AbstractHttpServerConnection implements HttpServerConnection {
 
     private final EntitySerializer entityserializer;

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java?rev=1389028&r1=1389027&r2=1389028&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java Sun Sep 23 12:15:04 2012
@@ -75,10 +75,9 @@ import org.apache.http.util.CharsetUtils
 import org.apache.http.util.NetUtils;
 
 /**
- * Implementation of a client-side HTTP connection that can be bound to an
- * arbitrary {@link Socket} for receiving data from and transmitting data to
- * a remote server.
- * <p>
+ * This class serves as a base for all {@link HttpConnection} implementations and provides
+ * functionality common to both client and server HTTP connections.
+ * <p/>
  * The following parameters can be used to customize the behavior of this
  * class:
  * <ul>
@@ -104,9 +103,6 @@ public class BHttpConnectionBase impleme
     private final ContentLengthStrategy incomingContentStrategy;
     private final ContentLengthStrategy outgoingContentStrategy;
 
-    private InputStream instream;
-    private OutputStream outstream;
-
     private volatile boolean open;
     private volatile Socket socket;
 
@@ -175,6 +171,18 @@ public class BHttpConnectionBase impleme
         this.outbuffer.bind(socket.getOutputStream());
     }
 
+    protected SessionInputBuffer getSessionInputBuffer() {
+        return this.inbuffer;
+    }
+
+    protected SessionOutputBuffer getSessionOutputBuffer() {
+        return this.outbuffer;
+    }
+
+    protected void doFlush() throws IOException {
+        this.outbuffer.flush();
+    }
+
     public boolean isOpen() {
         return this.open;
     }
@@ -201,16 +209,6 @@ public class BHttpConnectionBase impleme
         return new StrictContentLengthStrategy();
     }
 
-    protected OutputStream getOutputStream() {
-        Asserts.check(this.outstream != null, "Output stream");
-        return this.outstream;
-    }
-
-    protected InputStream getInputStream() {
-        Asserts.check(this.instream != null, "Input stream");
-        return this.instream;
-    }
-
     protected OutputStream createOutputStream(
             final long len,
             final SessionOutputBuffer outbuffer) {
@@ -223,30 +221,9 @@ public class BHttpConnectionBase impleme
         }
     }
 
-    protected HttpEntity prepareOutputStream(final HttpMessage message) throws HttpException {
-        BasicHttpEntity entity = new BasicHttpEntity();
+    protected OutputStream prepareOutput(final HttpMessage message) throws HttpException {
         long len = this.outgoingContentStrategy.determineLength(message);
-        this.outstream = createOutputStream(len, this.outbuffer);
-        if (len == ContentLengthStrategy.CHUNKED) {
-            entity.setChunked(true);
-            entity.setContentLength(-1);
-        } else if (len == ContentLengthStrategy.IDENTITY) {
-            entity.setChunked(false);
-            entity.setContentLength(-1);
-        } else {
-            entity.setChunked(false);
-            entity.setContentLength(len);
-        }
-
-        Header contentTypeHeader = message.getFirstHeader(HTTP.CONTENT_TYPE);
-        if (contentTypeHeader != null) {
-            entity.setContentType(contentTypeHeader);
-        }
-        Header contentEncodingHeader = message.getFirstHeader(HTTP.CONTENT_ENCODING);
-        if (contentEncodingHeader != null) {
-            entity.setContentEncoding(contentEncodingHeader);
-        }
-        return entity;
+        return createOutputStream(len, this.outbuffer);
     }
 
     protected InputStream createInputStream(
@@ -261,23 +238,23 @@ public class BHttpConnectionBase impleme
         }
     }
 
-    protected HttpEntity prepareInputStream(final HttpMessage message) throws HttpException {
+    protected HttpEntity prepareInput(final HttpMessage message) throws HttpException {
         BasicHttpEntity entity = new BasicHttpEntity();
 
         long len = this.incomingContentStrategy.determineLength(message);
-        this.instream = createInputStream(len, this.inbuffer);
+        InputStream instream = createInputStream(len, this.inbuffer);
         if (len == ContentLengthStrategy.CHUNKED) {
             entity.setChunked(true);
             entity.setContentLength(-1);
-            entity.setContent(this.instream);
+            entity.setContent(instream);
         } else if (len == ContentLengthStrategy.IDENTITY) {
             entity.setChunked(false);
             entity.setContentLength(-1);
-            entity.setContent(this.instream);
+            entity.setContent(instream);
         } else {
             entity.setChunked(false);
             entity.setContentLength(len);
-            entity.setContent(this.instream);
+            entity.setContent(instream);
         }
 
         Header contentTypeHeader = message.getFirstHeader(HTTP.CONTENT_TYPE);
@@ -381,24 +358,26 @@ public class BHttpConnectionBase impleme
         }
     }
 
+    protected boolean awaitInput(int timeout) throws IOException {
+        if (this.inbuffer.hasBufferedData()) {
+            return true;
+        }
+        int oldtimeout = this.socket.getSoTimeout();
+        try {
+            this.socket.setSoTimeout(1);
+            int i = this.inbuffer.fillBuffer();
+            return i != -1;
+        } finally {
+            this.socket.setSoTimeout(oldtimeout);
+        }
+    }
+
     public boolean isStale() {
         if (!isOpen()) {
             return true;
         }
-        if (this.inbuffer.hasBufferedData()) {
-            return false;
-        }
         try {
-            int oldtimeout = this.socket.getSoTimeout();
-            try {
-                this.socket.setSoTimeout(1);
-                int i = this.inbuffer.fillBuffer();
-                return i == -1;
-            } catch (SocketTimeoutException ex) {
-                throw ex;
-            } finally {
-                this.socket.setSoTimeout(oldtimeout);
-            }
+            return !awaitInput(1);
         } catch (SocketTimeoutException ex) {
             return false;
         } catch (IOException ex) {
@@ -406,6 +385,14 @@ public class BHttpConnectionBase impleme
         }
     }
 
+    protected void incrementRequestCount() {
+        this.connMetrics.incrementRequestCount();
+    }
+
+    protected void incrementResponseCount() {
+        this.connMetrics.incrementResponseCount();
+    }
+
     public HttpConnectionMetrics getMetrics() {
         return this.connMetrics;
     }

Added: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java?rev=1389028&view=auto
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java (added)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java Sun Sep 23 12:15:04 2012
@@ -0,0 +1,194 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.impl;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.net.SocketTimeoutException;
+
+import org.apache.http.HttpClientConnection;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpEntityEnclosingRequest;
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpResponseFactory;
+import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.impl.io.DefaultHttpRequestWriter;
+import org.apache.http.impl.io.DefaultHttpResponseParser;
+import org.apache.http.io.HttpMessageParser;
+import org.apache.http.io.HttpMessageWriter;
+import org.apache.http.io.SessionInputBuffer;
+import org.apache.http.io.SessionOutputBuffer;
+import org.apache.http.message.BasicLineFormatter;
+import org.apache.http.message.BasicLineParser;
+import org.apache.http.message.LineFormatter;
+import org.apache.http.message.LineParser;
+import org.apache.http.params.CoreConnectionPNames;
+import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
+
+/**
+ * Default implementation of {@link HttpClientConnection}.
+ * <p/>
+ * The following parameters can be used to customize the behavior of this
+ * class:
+ * <ul>
+ *  <li>{@link org.apache.http.params.CoreProtocolPNames#HTTP_ELEMENT_CHARSET}</li>
+ *  <li>{@link org.apache.http.params.CoreProtocolPNames#HTTP_MALFORMED_INPUT_ACTION}</li>
+ *  <li>{@link org.apache.http.params.CoreProtocolPNames#HTTP_UNMAPPABLE_INPUT_ACTION}</li>
+ *  <li>{@link org.apache.http.params.CoreConnectionPNames#SOCKET_BUFFER_SIZE}</li>
+ *  <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_LINE_LENGTH}</li>
+ *  <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_HEADER_COUNT}</li>
+ *  <li>{@link org.apache.http.params.CoreConnectionPNames#MIN_CHUNK_LIMIT}</li>
+ * </ul>
+ *
+ * @since 4.3
+ */
+@NotThreadSafe
+public class DefaultBHttpClientConnection extends BHttpConnectionBase
+                                                   implements HttpClientConnection {
+
+    private final HttpMessageParser<HttpResponse> responseParser;
+    private final HttpMessageWriter<HttpRequest> requestWriter;
+
+    public DefaultBHttpClientConnection(
+            final LineParser lineParser,
+            final LineFormatter lineFormatter,
+            final HttpResponseFactory responseFactory,
+            final HttpParams params) {
+        super(params);
+        this.responseParser = createResponseParser(
+                getSessionInputBuffer(), lineParser, responseFactory, params);
+        this.requestWriter = createRequestWriter(
+                getSessionOutputBuffer(), lineFormatter, params);
+    }
+
+    public DefaultBHttpClientConnection(final HttpParams params) {
+        this(null, null, null, params);
+    }
+
+    /**
+     * Creates an instance of {@link HttpMessageParser} to be used for parsing
+     * HTTP responses received over this connection.
+     *
+     * @param buffer the session input buffer.
+     * @param lineParser the line parser. If <code>null</code> {@link BasicLineParser#INSTANCE}
+     *   will be used
+     * @param responseFactory the response factory. If <code>null</code>
+     *   {@link DefaultHttpResponseFactory#INSTANCE} will be used.
+     * @param params HTTP parameters.
+     * @return HTTP response parser.
+     */
+    protected HttpMessageParser<HttpResponse> createResponseParser(
+            final SessionInputBuffer buffer,
+            final LineParser lineParser,
+            final HttpResponseFactory responseFactory,
+            final HttpParams params) {
+        int maxHeaderCount = params.getIntParameter(CoreConnectionPNames.MAX_HEADER_COUNT, -1);
+        int maxLineLen = params.getIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, -1);
+        return new DefaultHttpResponseParser(
+                buffer, maxHeaderCount, maxLineLen, lineParser, responseFactory);
+    }
+
+    /**
+     * Creates an instance of {@link HttpMessageWriter} to be used for
+     * writing out HTTP requests sent over this connection.
+     *
+     * @param buffer the session output buffer
+     * @param lineFormatter the line formatter. If <code>null</code>
+     *   {@link BasicLineFormatter#INSTANCE} will be used.
+     * @param params HTTP parameters
+     * @return HTTP request writer
+     */
+    protected HttpMessageWriter<HttpRequest> createRequestWriter(
+            final SessionOutputBuffer buffer,
+            final LineFormatter lineFormatter,
+            final HttpParams params) {
+        return new DefaultHttpRequestWriter(buffer, lineFormatter);
+    }
+
+    @Override
+    public void bind(final Socket socket) throws IOException {
+        super.bind(socket);
+    }
+
+    public boolean isResponseAvailable(int timeout) throws IOException {
+        assertOpen();
+        try {
+            return awaitInput(timeout);
+        } catch (SocketTimeoutException ex) {
+            return false;
+        }
+    }
+
+    public void sendRequestHeader(final HttpRequest request)
+            throws HttpException, IOException {
+        Args.notNull(request, "HTTP request");
+        assertOpen();
+        this.requestWriter.write(request);
+        incrementRequestCount();
+    }
+
+    public void sendRequestEntity(final HttpEntityEnclosingRequest request)
+            throws HttpException, IOException {
+        Args.notNull(request, "HTTP request");
+        assertOpen();
+        HttpEntity entity = request.getEntity();
+        if (entity == null) {
+            return;
+        }
+        OutputStream outstream = prepareOutput(request);
+        entity.writeTo(outstream);
+        outstream.close();
+    }
+
+    public HttpResponse receiveResponseHeader() throws HttpException, IOException {
+        assertOpen();
+        HttpResponse response = this.responseParser.parse();
+        if (response.getStatusLine().getStatusCode() >= 200) {
+            incrementResponseCount();
+        }
+        return response;
+    }
+
+    public void receiveResponseEntity(
+            final HttpResponse response) throws HttpException, IOException {
+        Args.notNull(response, "HTTP response");
+        assertOpen();
+        HttpEntity entity = prepareInput(response);
+        response.setEntity(entity);
+    }
+
+    public void flush() throws IOException {
+        assertOpen();
+        doFlush();
+    }
+
+}

Propchange: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java?rev=1389028&view=auto
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java (added)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java Sun Sep 23 12:15:04 2012
@@ -0,0 +1,193 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.impl;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.Socket;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpEntityEnclosingRequest;
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpRequestFactory;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpServerConnection;
+import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.entity.ContentLengthStrategy;
+import org.apache.http.impl.entity.DisallowIdentityContentLengthStrategy;
+import org.apache.http.impl.entity.LaxContentLengthStrategy;
+import org.apache.http.impl.io.DefaultHttpRequestParser;
+import org.apache.http.impl.io.DefaultHttpResponseWriter;
+import org.apache.http.io.HttpMessageParser;
+import org.apache.http.io.HttpMessageWriter;
+import org.apache.http.io.SessionInputBuffer;
+import org.apache.http.io.SessionOutputBuffer;
+import org.apache.http.message.BasicLineFormatter;
+import org.apache.http.message.BasicLineParser;
+import org.apache.http.message.LineFormatter;
+import org.apache.http.message.LineParser;
+import org.apache.http.params.CoreConnectionPNames;
+import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
+
+/**
+ * Default implementation of {@link HttpServerConnection}.
+ * <p/>
+ * The following parameters can be used to customize the behavior of this
+ * class:
+ * <ul>
+ *  <li>{@link org.apache.http.params.CoreProtocolPNames#HTTP_ELEMENT_CHARSET}</li>
+ *  <li>{@link org.apache.http.params.CoreProtocolPNames#HTTP_MALFORMED_INPUT_ACTION}</li>
+ *  <li>{@link org.apache.http.params.CoreProtocolPNames#HTTP_UNMAPPABLE_INPUT_ACTION}</li>
+ *  <li>{@link org.apache.http.params.CoreConnectionPNames#SOCKET_BUFFER_SIZE}</li>
+ *  <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_LINE_LENGTH}</li>
+ *  <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_HEADER_COUNT}</li>
+ *  <li>{@link org.apache.http.params.CoreConnectionPNames#MIN_CHUNK_LIMIT}</li>
+ * </ul>
+ *
+ * @since 4.3
+ */
+@NotThreadSafe
+public class DefaultBHttpServerConnection extends BHttpConnectionBase
+                                                   implements HttpServerConnection {
+
+    private final HttpMessageParser<HttpRequest> requestParser;
+    private final HttpMessageWriter<HttpResponse> responseWriter;
+
+    public DefaultBHttpServerConnection(
+            final LineParser lineParser,
+            final LineFormatter lineFormatter,
+            final HttpRequestFactory requestFactory,
+            final HttpParams params) {
+        super(params);
+        this.requestParser = createRequestParser(
+                getSessionInputBuffer(), lineParser, requestFactory, params);
+        this.responseWriter = createResponseWriter(
+                getSessionOutputBuffer(), lineFormatter, params);
+    }
+
+    public DefaultBHttpServerConnection(final HttpParams params) {
+        this(null, null, null, params);
+    }
+
+    @Override
+    protected ContentLengthStrategy createIncomingContentStrategy() {
+        return new DisallowIdentityContentLengthStrategy(new LaxContentLengthStrategy(0));
+    }
+
+    /**
+     * Creates an instance of {@link HttpMessageParser} to be used for parsing
+     * HTTP requests received over this connection.
+     *
+     * @param buffer the session input buffer.
+     * @param lineParser the line parser. If <code>null</code> {@link BasicLineParser#INSTANCE}
+     *   will be used
+     * @param responseFactory the response factory. If <code>null</code>
+     *   {@link DefaultHttpRequestFactory#INSTANCE} will be used.
+     * @param params HTTP parameters.
+     * @return HTTP message parser.
+     */
+    protected HttpMessageParser<HttpRequest> createRequestParser(
+            final SessionInputBuffer buffer,
+            final LineParser lineParser,
+            final HttpRequestFactory requestFactory,
+            final HttpParams params) {
+        int maxHeaderCount = params.getIntParameter(CoreConnectionPNames.MAX_HEADER_COUNT, -1);
+        int maxLineLen = params.getIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, -1);
+        return new DefaultHttpRequestParser(
+                buffer, maxHeaderCount, maxLineLen, lineParser, requestFactory);
+    }
+
+    /**
+     * Creates an instance of {@link HttpMessageWriter} to be used for
+     * writing out HTTP responses sent over this connection.
+     *
+     * @param buffer the session output buffer
+     * @param lineFormatter the line formatter. If <code>null</code>
+     *   {@link BasicLineFormatter#INSTANCE} will be used.
+     * @param params HTTP parameters
+     * @return HTTP message writer
+     */
+    protected HttpMessageWriter<HttpResponse> createResponseWriter(
+            final SessionOutputBuffer buffer,
+            final LineFormatter lineFormatter,
+            final HttpParams params) {
+        return new DefaultHttpResponseWriter(buffer, lineFormatter);
+    }
+
+    @Override
+    public void bind(final Socket socket) throws IOException {
+        super.bind(socket);
+    }
+
+    public HttpRequest receiveRequestHeader()
+            throws HttpException, IOException {
+        assertOpen();
+        HttpRequest request = this.requestParser.parse();
+        incrementRequestCount();
+        return request;
+    }
+
+    public void receiveRequestEntity(final HttpEntityEnclosingRequest request)
+            throws HttpException, IOException {
+        Args.notNull(request, "HTTP request");
+        assertOpen();
+        HttpEntity entity = prepareInput(request);
+        request.setEntity(entity);
+    }
+
+    public void sendResponseHeader(final HttpResponse response)
+            throws HttpException, IOException {
+        Args.notNull(response, "HTTP response");
+        assertOpen();
+        this.responseWriter.write(response);
+        if (response.getStatusLine().getStatusCode() >= 200) {
+            incrementResponseCount();
+        }
+    }
+
+    public void sendResponseEntity(final HttpResponse response)
+            throws HttpException, IOException {
+        Args.notNull(response, "HTTP response");
+        assertOpen();
+        HttpEntity entity = response.getEntity();
+        if (entity == null) {
+            return;
+        }
+        OutputStream outstream = prepareOutput(response);
+        entity.writeTo(outstream);
+        outstream.close();
+    }
+
+    public void flush() throws IOException {
+        assertOpen();
+        doFlush();
+    }
+
+}

Propchange: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java?rev=1389028&r1=1389027&r2=1389028&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java Sun Sep 23 12:15:04 2012
@@ -53,8 +53,11 @@ import org.apache.http.util.Args;
  * </ul>
  *
  * @since 4.0
+ *
+ * @deprecated (4.3) use {@link DefaultBHttpClientConnection}
  */
 @NotThreadSafe
+@Deprecated
 public class DefaultHttpClientConnection extends SocketHttpClientConnection {
 
     public DefaultHttpClientConnection() {

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpServerConnection.java?rev=1389028&r1=1389027&r2=1389028&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpServerConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpServerConnection.java Sun Sep 23 12:15:04 2012
@@ -53,8 +53,11 @@ import org.apache.http.util.Args;
  * </ul>
  *
  * @since 4.0
+ *
+ * @deprecated (4.3) use {@link DefaultBHttpServerConnection}
  */
 @NotThreadSafe
+@Deprecated
 public class DefaultHttpServerConnection extends SocketHttpServerConnection {
 
     public DefaultHttpServerConnection() {

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java?rev=1389028&r1=1389027&r2=1389028&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java Sun Sep 23 12:15:04 2012
@@ -61,8 +61,11 @@ import org.apache.http.util.Args;
  * </ul>
  *
  * @since 4.0
+ *
+ * @deprecated (4.3) use {@link DefaultBHttpClientConnection}
  */
 @NotThreadSafe
+@Deprecated
 public class SocketHttpClientConnection
         extends AbstractHttpClientConnection implements HttpInetConnection {
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java?rev=1389028&r1=1389027&r2=1389028&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java Sun Sep 23 12:15:04 2012
@@ -60,8 +60,11 @@ import org.apache.http.util.Args;
  * </ul>
  *
  * @since 4.0
+ *
+ * @deprecated (4.3) use {@link DefaultBHttpServerConnection}
  */
 @NotThreadSafe
+@Deprecated
 public class SocketHttpServerConnection extends
         AbstractHttpServerConnection implements HttpInetConnection {
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java?rev=1389028&r1=1389027&r2=1389028&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java Sun Sep 23 12:15:04 2012
@@ -35,7 +35,7 @@ import javax.net.ssl.SSLSocketFactory;
 import org.apache.http.HttpClientConnection;
 import org.apache.http.HttpHost;
 import org.apache.http.annotation.Immutable;
-import org.apache.http.impl.DefaultHttpClientConnection;
+import org.apache.http.impl.DefaultBHttpClientConnection;
 import org.apache.http.params.CoreConnectionPNames;
 import org.apache.http.params.HttpParams;
 import org.apache.http.pool.ConnFactory;
@@ -76,8 +76,8 @@ public class BasicConnFactory implements
     }
 
     protected HttpClientConnection create(final Socket socket, final HttpParams params) throws IOException {
-        DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
-        conn.bind(socket, params);
+        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(params);
+        conn.bind(socket);
         return conn;
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java?rev=1389028&r1=1389027&r2=1389028&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java Sun Sep 23 12:15:04 2012
@@ -54,7 +54,7 @@ import org.apache.http.entity.AbstractHt
 import org.apache.http.entity.ByteArrayEntity;
 import org.apache.http.entity.ContentType;
 import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.DefaultHttpClientConnection;
+import org.apache.http.impl.DefaultBHttpClientConnection;
 import org.apache.http.message.BasicHttpEntityEnclosingRequest;
 import org.apache.http.message.BasicHttpRequest;
 import org.apache.http.params.CoreProtocolPNames;
@@ -139,14 +139,14 @@ public class TestSyncHttp {
 
         this.server.start();
 
-        DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
+        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(this.client.getParams());
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 
         try {
             for (int r = 0; r < reqNo; r++) {
                 if (!conn.isOpen()) {
                     Socket socket = new Socket(host.getHostName(), host.getPort());
-                    conn.bind(socket, this.client.getParams());
+                    conn.bind(socket);
                 }
 
                 BasicHttpRequest get = new BasicHttpRequest("GET", "/?" + r);
@@ -219,14 +219,14 @@ public class TestSyncHttp {
 
         this.server.start();
 
-        DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
+        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(this.client.getParams());
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 
         try {
             for (int r = 0; r < reqNo; r++) {
                 if (!conn.isOpen()) {
                     Socket socket = new Socket(host.getHostName(), host.getPort());
-                    conn.bind(socket, this.client.getParams());
+                    conn.bind(socket);
                 }
 
                 BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/");
@@ -302,14 +302,14 @@ public class TestSyncHttp {
 
         this.server.start();
 
-        DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
+        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(this.client.getParams());
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 
         try {
             for (int r = 0; r < reqNo; r++) {
                 if (!conn.isOpen()) {
                     Socket socket = new Socket(host.getHostName(), host.getPort());
-                    conn.bind(socket, this.client.getParams());
+                    conn.bind(socket);
                 }
 
                 BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/");
@@ -388,14 +388,14 @@ public class TestSyncHttp {
         this.client.getParams().setParameter(
                 CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_0);
 
-        DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
+        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(this.client.getParams());
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 
         try {
             for (int r = 0; r < reqNo; r++) {
                 if (!conn.isOpen()) {
                     Socket socket = new Socket(host.getHostName(), host.getPort());
-                    conn.bind(socket, this.client.getParams());
+                    conn.bind(socket);
                 }
 
                 BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/");
@@ -475,14 +475,14 @@ public class TestSyncHttp {
         // Activate 'expect: continue' handshake
         this.client.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true);
 
-        DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
+        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(this.client.getParams());
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 
         try {
             for (int r = 0; r < reqNo; r++) {
                 if (!conn.isOpen()) {
                     Socket socket = new Socket(host.getHostName(), host.getPort());
-                    conn.bind(socket, this.client.getParams());
+                    conn.bind(socket);
                 }
 
                 BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/");
@@ -569,14 +569,14 @@ public class TestSyncHttp {
         // Activate 'expect: continue' handshake
         this.client.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true);
 
-        DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
+        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(this.client.getParams());
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 
         try {
             for (int r = 0; r < reqNo; r++) {
                 if (!conn.isOpen()) {
                     Socket socket = new Socket(host.getHostName(), host.getPort());
-                    conn.bind(socket, this.client.getParams());
+                    conn.bind(socket);
                 }
 
                 BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/");
@@ -727,7 +727,7 @@ public class TestSyncHttp {
         });
 
         this.server.start();
-        DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
+        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(this.client.getParams());
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 
         try {
@@ -736,7 +736,7 @@ public class TestSyncHttp {
                 for (int n = 1000; n < 1020; n++) {
                     if (!conn.isOpen()) {
                         Socket socket = new Socket(host.getHostName(), host.getPort());
-                        conn.bind(socket, this.client.getParams());
+                        conn.bind(socket);
                     }
 
                     BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest(
@@ -799,13 +799,13 @@ public class TestSyncHttp {
 
         this.server.start();
 
-        DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
+        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(this.client.getParams());
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 
         try {
             if (!conn.isOpen()) {
                 Socket socket = new Socket(host.getHostName(), host.getPort());
-                conn.bind(socket, this.client.getParams());
+                conn.bind(socket);
             }
 
             BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/");
@@ -845,13 +845,13 @@ public class TestSyncHttp {
 
         this.server.start();
 
-        DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
+        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(this.client.getParams());
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 
         try {
             if (!conn.isOpen()) {
                 Socket socket = new Socket(host.getHostName(), host.getPort());
-                conn.bind(socket, this.client.getParams());
+                conn.bind(socket);
             }
 
             BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/");
@@ -898,13 +898,13 @@ public class TestSyncHttp {
 
         this.server.start();
 
-        DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
+        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(this.client.getParams());
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 
         try {
             if (!conn.isOpen()) {
                 Socket socket = new Socket(host.getHostName(), host.getPort());
-                conn.bind(socket, this.client.getParams());
+                conn.bind(socket);
             }
 
             BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/");
@@ -953,14 +953,14 @@ public class TestSyncHttp {
 
         this.server.start();
 
-        DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
+        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(this.client.getParams());
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 
         try {
             for (int r = 0; r < reqNo; r++) {
                 if (!conn.isOpen()) {
                     Socket socket = new Socket(host.getHostName(), host.getPort());
-                    conn.bind(socket, this.client.getParams());
+                    conn.bind(socket);
                 }
 
                 BasicHttpRequest get = new BasicHttpRequest("GET", "/?" + r);

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpServer.java?rev=1389028&r1=1389027&r2=1389028&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpServer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpServer.java Sun Sep 23 12:15:04 2012
@@ -39,9 +39,9 @@ import org.apache.http.HttpException;
 import org.apache.http.HttpResponseFactory;
 import org.apache.http.HttpResponseInterceptor;
 import org.apache.http.HttpServerConnection;
+import org.apache.http.impl.DefaultBHttpServerConnection;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
-import org.apache.http.impl.DefaultHttpServerConnection;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.CoreConnectionPNames;
 import org.apache.http.params.CoreProtocolPNames;
@@ -107,8 +107,8 @@ public class HttpServer {
 
     private HttpServerConnection acceptConnection() throws IOException {
         Socket socket = this.serversocket.accept();
-        DefaultHttpServerConnection conn = new DefaultHttpServerConnection();
-        conn.bind(socket, this.params);
+        DefaultBHttpServerConnection conn = new DefaultBHttpServerConnection(this.params);
+        conn.bind(socket);
         return conn;
     }
 



Mime
View raw message