From aa82dc28ee8be63d2a3c6542fb45f2bde4b933cd Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Wed, 3 Oct 2012 15:28:08 +0000 Subject: [PATCH] HTTPCLIENT-1239: Support for overridable DefaultHttpServerConnection in LocalTestServer Contributed by Okke Harsta git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1393540 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/http/localserver/LocalTestServer.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/httpclient/src/test/java/org/apache/http/localserver/LocalTestServer.java b/httpclient/src/test/java/org/apache/http/localserver/LocalTestServer.java index 85aa355a1..8e12bd427 100644 --- a/httpclient/src/test/java/org/apache/http/localserver/LocalTestServer.java +++ b/httpclient/src/test/java/org/apache/http/localserver/LocalTestServer.java @@ -319,6 +319,19 @@ public class LocalTestServer { return (InetSocketAddress) ssock.getLocalSocketAddress(); } + /** + * Creates an instance of {@link DefaultHttpServerConnection} to be used + * in the Worker thread. + *

+ * This method can be overridden in a super class in order to provide + * a different implementation of the {@link DefaultHttpServerConnection}. + * + * @return DefaultHttpServerConnection. + */ + protected DefaultHttpServerConnection createHttpServerConnection() { + return new DefaultHttpServerConnection(); + } + /** * The request listener. * Accepts incoming connections and launches a service thread. @@ -337,7 +350,7 @@ public class LocalTestServer { while (!interrupted()) { Socket socket = servicedSocket.accept(); acceptedConnections.incrementAndGet(); - DefaultHttpServerConnection conn = new DefaultHttpServerConnection(); + DefaultHttpServerConnection conn = createHttpServerConnection(); conn.bind(socket, httpservice.getParams()); // Start worker thread Worker worker = new Worker(conn);