HTTPCLIENT-1239: Support for overridable DefaultHttpServerConnection in LocalTestServer

Contributed by Okke Harsta <oharsta at apache.org>

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1393540 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2012-10-03 15:28:08 +00:00
parent 5f9ab2e161
commit aa82dc28ee
1 changed files with 14 additions and 1 deletions

View File

@ -319,6 +319,19 @@ public class LocalTestServer {
return (InetSocketAddress) ssock.getLocalSocketAddress();
}
/**
* Creates an instance of {@link DefaultHttpServerConnection} to be used
* in the Worker thread.
* <p>
* 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);