You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2012/02/06 10:14:02 UTC
svn commit: r1240940 [1/2] - in /httpcomponents/httpasyncclient/trunk: ./
httpasyncclient/src/main/java/org/apache/http/impl/nio/client/
httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/
httpasyncclient/src/main/java/org/apache/http/nio/clie...
Author: olegk
Date: Mon Feb 6 09:14:01 2012
New Revision: 1240940
URL: http://svn.apache.org/viewvc?rev=1240940&view=rev
Log:
Upgraded HttpCore to 4.2-beta1
Added:
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/LoggingAsyncRequestExecutor.java (contents, props changed)
- copied, changed from r1240744, httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/LoggingClientProtocolHandler.java
Removed:
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/LoggingClientProtocolHandler.java
Modified:
httpcomponents/httpasyncclient/trunk/.gitignore
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultResultCallback.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalIOReactorExceptionHandler.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/ResultCallback.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/LoggingIOSession.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncByteConsumer.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseZeroCopyRequestProducer.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncMethods.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyConsumer.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/OperatedAsyncClientConnection.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/HttpAsyncTestBase.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestClientAuthentication.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpAsync.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpsAsync.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpsRedirects.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestRedirects.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestStatefulConnManagement.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/localserver/HttpServerNio.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestZeroCopy.java
httpcomponents/httpasyncclient/trunk/pom.xml
Modified: httpcomponents/httpasyncclient/trunk/.gitignore
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/.gitignore?rev=1240940&r1=1240939&r2=1240940&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/.gitignore (original)
+++ httpcomponents/httpasyncclient/trunk/.gitignore Mon Feb 6 09:14:01 2012
@@ -4,3 +4,5 @@
.clover
.externalToolBuilders
target
+maven-eclipse.xml
+
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java?rev=1240940&r1=1240939&r2=1240940&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java Mon Feb 6 09:14:01 2012
@@ -75,7 +75,7 @@ import org.apache.http.impl.cookie.Ignor
import org.apache.http.impl.cookie.NetscapeDraftSpecFactory;
import org.apache.http.impl.cookie.RFC2109SpecFactory;
import org.apache.http.impl.cookie.RFC2965SpecFactory;
-import org.apache.http.impl.nio.DefaultClientIODispatch;
+import org.apache.http.impl.nio.DefaultHttpClientIODispatch;
import org.apache.http.impl.nio.conn.DefaultHttpAsyncRoutePlanner;
import org.apache.http.impl.nio.conn.PoolingAsyncClientConnectionManager;
import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor;
@@ -83,7 +83,7 @@ import org.apache.http.impl.nio.reactor.
import org.apache.http.nio.client.HttpAsyncClient;
import org.apache.http.nio.client.methods.HttpAsyncMethods;
import org.apache.http.nio.conn.ClientAsyncConnectionManager;
-import org.apache.http.nio.protocol.HttpAsyncClientExchangeHandler;
+import org.apache.http.nio.protocol.HttpAsyncRequestExecutionHandler;
import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
import org.apache.http.nio.protocol.HttpAsyncResponseConsumer;
import org.apache.http.nio.reactor.IOEventDispatch;
@@ -101,7 +101,7 @@ public abstract class AbstractHttpAsyncC
private final Log log = LogFactory.getLog(getClass());;
private final ClientAsyncConnectionManager connmgr;
- private final Queue<HttpAsyncClientExchangeHandler<?>> queue;
+ private final Queue<HttpAsyncRequestExecutionHandler<?>> queue;
private Thread reactorThread;
private BasicHttpProcessor mutableProcessor;
@@ -124,7 +124,7 @@ public abstract class AbstractHttpAsyncC
protected AbstractHttpAsyncClient(final ClientAsyncConnectionManager connmgr) {
super();
this.connmgr = connmgr;
- this.queue = new ConcurrentLinkedQueue<HttpAsyncClientExchangeHandler<?>>();
+ this.queue = new ConcurrentLinkedQueue<HttpAsyncRequestExecutionHandler<?>>();
}
protected AbstractHttpAsyncClient(final IOReactorConfig config) throws IOReactorException {
@@ -132,7 +132,7 @@ public abstract class AbstractHttpAsyncC
DefaultConnectingIOReactor defaultioreactor = new DefaultConnectingIOReactor(config);
defaultioreactor.setExceptionHandler(new InternalIOReactorExceptionHandler(this.log));
this.connmgr = new PoolingAsyncClientConnectionManager(defaultioreactor);
- this.queue = new ConcurrentLinkedQueue<HttpAsyncClientExchangeHandler<?>>();
+ this.queue = new ConcurrentLinkedQueue<HttpAsyncRequestExecutionHandler<?>>();
}
protected abstract HttpParams createHttpParams();
@@ -454,16 +454,16 @@ public abstract class AbstractHttpAsyncC
}
private void doExecute() {
- LoggingClientProtocolHandler handler = new LoggingClientProtocolHandler();
+ LoggingAsyncRequestExecutor handler = new LoggingAsyncRequestExecutor();
try {
- IOEventDispatch ioEventDispatch = new DefaultClientIODispatch(handler, getParams());
+ IOEventDispatch ioEventDispatch = new DefaultHttpClientIODispatch(handler, getParams());
this.connmgr.execute(ioEventDispatch);
} catch (Exception ex) {
this.log.error("I/O reactor terminated abnormally", ex);
} finally {
this.terminated = true;
while (!this.queue.isEmpty()) {
- HttpAsyncClientExchangeHandler<?> exchangeHandler = this.queue.remove();
+ HttpAsyncRequestExecutionHandler<?> exchangeHandler = this.queue.remove();
exchangeHandler.cancel();
}
}
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java?rev=1240940&r1=1240939&r2=1240940&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java Mon Feb 6 09:14:01 2012
@@ -80,8 +80,8 @@ import org.apache.http.nio.IOControl;
import org.apache.http.nio.conn.ClientAsyncConnectionManager;
import org.apache.http.nio.conn.ManagedAsyncClientConnection;
import org.apache.http.nio.conn.scheme.AsyncScheme;
-import org.apache.http.nio.protocol.HttpAsyncClientExchangeHandler;
-import org.apache.http.nio.protocol.HttpAsyncClientProtocolHandler;
+import org.apache.http.nio.protocol.HttpAsyncRequestExecutionHandler;
+import org.apache.http.nio.protocol.HttpAsyncRequestExecutor;
import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
import org.apache.http.nio.protocol.HttpAsyncResponseConsumer;
import org.apache.http.params.HttpConnectionParams;
@@ -91,7 +91,7 @@ import org.apache.http.protocol.Executio
import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.HttpProcessor;
-class DefaultAsyncRequestDirector<T> implements HttpAsyncClientExchangeHandler<T> {
+class DefaultAsyncRequestDirector<T> implements HttpAsyncRequestExecutionHandler<T> {
private final Log log;
@@ -171,6 +171,10 @@ class DefaultAsyncRequestDirector<T> imp
public synchronized void start() {
try {
+
+ this.localContext.setAttribute(ClientContext.TARGET_AUTH_STATE, this.targetAuthState);
+ this.localContext.setAttribute(ClientContext.PROXY_AUTH_STATE, this.proxyAuthState);
+
HttpHost target = this.requestProducer.getTarget();
HttpRequest request = this.requestProducer.generateRequest();
this.params = new ClientParamsStack(null, this.clientParams, request.getParams(), null);
@@ -229,7 +233,10 @@ class DefaultAsyncRequestDirector<T> imp
target = route.getTargetHost();
}
HttpHost proxy = route.getProxyHost();
-
+ this.localContext.setAttribute(ExecutionContext.HTTP_TARGET_HOST, target);
+ this.localContext.setAttribute(ExecutionContext.HTTP_PROXY_HOST, proxy);
+ this.localContext.setAttribute(ExecutionContext.HTTP_CONNECTION, this.managedConn);
+
if (this.currentRequest == null) {
this.currentRequest = this.mainRequest.getRequest();
// Re-write request URI if needed
@@ -238,14 +245,6 @@ class DefaultAsyncRequestDirector<T> imp
// Reset headers on the request wrapper
this.currentRequest.resetHeaders();
- this.localContext.setAttribute(ExecutionContext.HTTP_REQUEST, this.currentRequest);
- this.localContext.setAttribute(ExecutionContext.HTTP_TARGET_HOST, target);
- this.localContext.setAttribute(ExecutionContext.HTTP_PROXY_HOST, proxy);
- this.localContext.setAttribute(ExecutionContext.HTTP_CONNECTION, this.managedConn);
- this.localContext.setAttribute(ClientContext.TARGET_AUTH_STATE, this.targetAuthState);
- this.localContext.setAttribute(ClientContext.PROXY_AUTH_STATE, this.proxyAuthState);
-
- this.httppocessor.process(this.currentRequest, this.localContext);
this.currentRequest.incrementExecCount();
if (this.currentRequest.getExecCount() > 1
&& !this.requestProducer.isRepeatable()
@@ -277,7 +276,7 @@ class DefaultAsyncRequestDirector<T> imp
return this.requestProducer.isRepeatable();
}
- public void resetRequest() {
+ public void resetRequest() throws IOException {
this.requestProducer.resetRequest();
}
@@ -288,8 +287,6 @@ class DefaultAsyncRequestDirector<T> imp
}
this.currentResponse = response;
this.currentResponse.setParams(this.params);
- this.localContext.setAttribute(ExecutionContext.HTTP_RESPONSE, this.currentResponse);
- this.httppocessor.process(this.currentResponse, this.localContext);
int status = this.currentResponse.getStatusLine().getStatusCode();
@@ -339,7 +336,7 @@ class DefaultAsyncRequestDirector<T> imp
private void releaseConnection() {
if (this.managedConn != null) {
try {
- this.managedConn.getContext().removeAttribute(HttpAsyncClientProtocolHandler.HTTP_HANDLER);
+ this.managedConn.getContext().removeAttribute(HttpAsyncRequestExecutor.HTTP_HANDLER);
this.managedConn.releaseConnection();
} catch (IOException ioex) {
this.log.debug("I/O error releasing connection", ioex);
@@ -361,7 +358,16 @@ class DefaultAsyncRequestDirector<T> imp
this.connFuture.cancel(true);
this.connFuture = null;
}
- this.requestProducer.resetRequest();
+ try {
+ this.requestProducer.close();
+ } catch (IOException ex) {
+ this.log.debug("I/O error closing request producer", ex);
+ }
+ try {
+ this.responseConsumer.close();
+ } catch (IOException ex) {
+ this.log.debug("I/O error closing response consumer", ex);
+ }
}
public synchronized void failed(final Exception ex) {
@@ -485,7 +491,7 @@ class DefaultAsyncRequestDirector<T> imp
conn.open(route, this.localContext, this.params);
}
this.managedConn = conn;
- this.managedConn.getContext().setAttribute(HttpAsyncClientProtocolHandler.HTTP_HANDLER, this);
+ this.managedConn.getContext().setAttribute(HttpAsyncRequestExecutor.HTTP_HANDLER, this);
this.managedConn.requestOutput();
this.routeEstablished = route.equals(conn.getRoute());
} catch (IOException ex) {
@@ -499,20 +505,18 @@ class DefaultAsyncRequestDirector<T> imp
private synchronized void connectionRequestFailed(final Exception ex) {
this.log.debug("Connection request failed", ex);
try {
- this.requestProducer.resetRequest();
- this.responseConsumer.failed(ex);
- } finally {
this.resultCallback.failed(ex, this);
+ } finally {
+ releaseResources();
}
}
private synchronized void connectionRequestCancelled() {
this.log.debug("Connection request cancelled");
try {
- this.requestProducer.resetRequest();
- this.responseConsumer.cancel();
- } finally {
this.resultCallback.cancelled(this);
+ } finally {
+ releaseResources();
}
}
@@ -856,6 +860,10 @@ class DefaultAsyncRequestDirector<T> imp
return this.localContext;
}
+ public HttpProcessor getHttpProcessor() {
+ return this.httppocessor;
+ }
+
public ConnectionReuseStrategy getConnectionReuseStrategy() {
return this.reuseStrategy;
}
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultResultCallback.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultResultCallback.java?rev=1240940&r1=1240939&r2=1240940&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultResultCallback.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultResultCallback.java Mon Feb 6 09:14:01 2012
@@ -29,31 +29,31 @@ package org.apache.http.impl.nio.client;
import java.util.Queue;
import org.apache.http.concurrent.BasicFuture;
-import org.apache.http.nio.protocol.HttpAsyncClientExchangeHandler;
+import org.apache.http.nio.protocol.HttpAsyncRequestExecutionHandler;
class DefaultResultCallback<T> implements ResultCallback<T> {
private final BasicFuture<T> future;
- private final Queue<HttpAsyncClientExchangeHandler<?>> queue;
+ private final Queue<HttpAsyncRequestExecutionHandler<?>> queue;
DefaultResultCallback(
- final BasicFuture<T> future, final Queue<HttpAsyncClientExchangeHandler<?>> queue) {
+ final BasicFuture<T> future, final Queue<HttpAsyncRequestExecutionHandler<?>> queue) {
super();
this.future = future;
this.queue = queue;
}
- public void completed(final T result, final HttpAsyncClientExchangeHandler<T> handler) {
+ public void completed(final T result, final HttpAsyncRequestExecutionHandler<T> handler) {
this.future.completed(result);
this.queue.remove(handler);
}
- public void failed(final Exception ex, final HttpAsyncClientExchangeHandler<T> handler) {
+ public void failed(final Exception ex, final HttpAsyncRequestExecutionHandler<T> handler) {
this.future.failed(ex);
this.queue.remove(handler);
}
- public void cancelled(final HttpAsyncClientExchangeHandler<T> handler) {
+ public void cancelled(final HttpAsyncRequestExecutionHandler<T> handler) {
this.future.cancel(true);
this.queue.remove(handler);
}
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalIOReactorExceptionHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalIOReactorExceptionHandler.java?rev=1240940&r1=1240939&r2=1240940&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalIOReactorExceptionHandler.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalIOReactorExceptionHandler.java Mon Feb 6 09:14:01 2012
@@ -50,4 +50,4 @@ class InternalIOReactorExceptionHandler
return false;
}
-}
\ No newline at end of file
+}
Copied: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/LoggingAsyncRequestExecutor.java (from r1240744, httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/LoggingClientProtocolHandler.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/LoggingAsyncRequestExecutor.java?p2=httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/LoggingAsyncRequestExecutor.java&p1=httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/LoggingClientProtocolHandler.java&r1=1240744&r2=1240940&rev=1240940&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/LoggingClientProtocolHandler.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/LoggingAsyncRequestExecutor.java Mon Feb 6 09:14:01 2012
@@ -35,23 +35,25 @@ import org.apache.http.HttpException;
import org.apache.http.nio.ContentDecoder;
import org.apache.http.nio.ContentEncoder;
import org.apache.http.nio.NHttpClientConnection;
-import org.apache.http.nio.protocol.HttpAsyncClientProtocolHandler;
+import org.apache.http.nio.protocol.HttpAsyncRequestExecutor;
-class LoggingClientProtocolHandler extends HttpAsyncClientProtocolHandler {
+class LoggingAsyncRequestExecutor extends HttpAsyncRequestExecutor {
- private final Log log = LogFactory.getLog(HttpAsyncClientProtocolHandler.class);
+ private final Log log = LogFactory.getLog(HttpAsyncRequestExecutor.class);
- public LoggingClientProtocolHandler() {
+ public LoggingAsyncRequestExecutor() {
super();
}
@Override
- protected void onException(final Exception ex) {
+ protected void log(final Exception ex) {
this.log.debug(ex.getMessage(), ex);
}
@Override
- public void connected(final NHttpClientConnection conn, final Object attachment) {
+ public void connected(
+ final NHttpClientConnection conn,
+ final Object attachment) throws IOException, HttpException {
if (this.log.isDebugEnabled()) {
this.log.debug(conn + ": Connected");
}
@@ -63,10 +65,11 @@ class LoggingClientProtocolHandler exten
if (this.log.isDebugEnabled()) {
this.log.debug(conn + ": Disconnected");
}
+ super.closed(conn);
}
@Override
- public void exception(final NHttpClientConnection conn, final HttpException ex) {
+ public void exception(final NHttpClientConnection conn, final Exception ex) {
if (this.log.isErrorEnabled()) {
this.log.error(conn + " HTTP protocol exception: " + ex.getMessage(), ex);
}
@@ -74,15 +77,8 @@ class LoggingClientProtocolHandler exten
}
@Override
- public void exception(final NHttpClientConnection conn, final IOException ex) {
- if (this.log.isErrorEnabled()) {
- this.log.error(conn + " I/O error: " + ex.getMessage(), ex);
- }
- super.exception(conn, ex);
- }
-
- @Override
- public void requestReady(final NHttpClientConnection conn) {
+ public void requestReady(
+ final NHttpClientConnection conn) throws IOException, HttpException {
if (this.log.isDebugEnabled()) {
this.log.debug(conn + " Request ready");
}
@@ -90,7 +86,9 @@ class LoggingClientProtocolHandler exten
}
@Override
- public void inputReady(final NHttpClientConnection conn, final ContentDecoder decoder) {
+ public void inputReady(
+ final NHttpClientConnection conn,
+ final ContentDecoder decoder) throws IOException {
if (this.log.isDebugEnabled()) {
this.log.debug(conn + " Input ready " + decoder);
}
@@ -98,7 +96,9 @@ class LoggingClientProtocolHandler exten
}
@Override
- public void outputReady(final NHttpClientConnection conn, final ContentEncoder encoder) {
+ public void outputReady(
+ final NHttpClientConnection conn,
+ final ContentEncoder encoder) throws IOException {
if (this.log.isDebugEnabled()) {
this.log.debug(conn + " Output ready " + encoder);
}
@@ -106,7 +106,8 @@ class LoggingClientProtocolHandler exten
}
@Override
- public void responseReceived(final NHttpClientConnection conn) {
+ public void responseReceived(
+ final NHttpClientConnection conn) throws HttpException, IOException {
if (this.log.isDebugEnabled()) {
this.log.debug(conn + " Response received");
}
@@ -114,7 +115,7 @@ class LoggingClientProtocolHandler exten
}
@Override
- public void timeout(final NHttpClientConnection conn) {
+ public void timeout(final NHttpClientConnection conn) throws IOException {
if (this.log.isDebugEnabled()) {
this.log.debug(conn + " Timeout");
}
Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/LoggingAsyncRequestExecutor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/LoggingAsyncRequestExecutor.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/LoggingAsyncRequestExecutor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/ResultCallback.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/ResultCallback.java?rev=1240940&r1=1240939&r2=1240940&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/ResultCallback.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/ResultCallback.java Mon Feb 6 09:14:01 2012
@@ -26,15 +26,15 @@
*/
package org.apache.http.impl.nio.client;
-import org.apache.http.nio.protocol.HttpAsyncClientExchangeHandler;
+import org.apache.http.nio.protocol.HttpAsyncRequestExecutionHandler;
interface ResultCallback<T> {
- void completed(T result, HttpAsyncClientExchangeHandler<T> handler);
+ void completed(T result, HttpAsyncRequestExecutionHandler<T> handler);
- void failed(Exception ex, HttpAsyncClientExchangeHandler<T> handler);
+ void failed(Exception ex, HttpAsyncRequestExecutionHandler<T> handler);
- void cancelled(HttpAsyncClientExchangeHandler<T> handler);
+ void cancelled(HttpAsyncRequestExecutionHandler<T> handler);
boolean isDone();
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/LoggingIOSession.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/LoggingIOSession.java?rev=1240940&r1=1240939&r2=1240940&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/LoggingIOSession.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/LoggingIOSession.java Mon Feb 6 09:14:01 2012
@@ -226,4 +226,4 @@ class LoggingIOSession implements IOSess
}
-}
\ No newline at end of file
+}
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncByteConsumer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncByteConsumer.java?rev=1240940&r1=1240939&r2=1240940&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncByteConsumer.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncByteConsumer.java Mon Feb 6 09:14:01 2012
@@ -29,6 +29,8 @@ package org.apache.http.nio.client.metho
import java.io.IOException;
import java.nio.ByteBuffer;
+import org.apache.http.HttpEntity;
+import org.apache.http.entity.ContentType;
import org.apache.http.nio.ContentDecoder;
import org.apache.http.nio.IOControl;
import org.apache.http.nio.protocol.AbstractAsyncResponseConsumer;
@@ -48,13 +50,19 @@ public abstract class AsyncByteConsumer<
}
protected abstract void onByteReceived(
- final ByteBuffer buf, final IOControl ioctrl) throws IOException;
+ ByteBuffer buf, IOControl ioctrl) throws IOException;
@Override
- protected void onContentReceived(
+ protected final void onEntityEnclosed(
+ final HttpEntity entity, final ContentType contentType) {
+ this.bbuf = ByteBuffer.allocate(this.bufSize);
+ }
+
+ @Override
+ protected final void onContentReceived(
final ContentDecoder decoder, final IOControl ioctrl) throws IOException {
if (this.bbuf == null) {
- this.bbuf = ByteBuffer.allocate(this.bufSize);
+ throw new IllegalStateException("Byte buffer is null");
}
for (;;) {
int bytesRead = decoder.read(this.bbuf);
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java?rev=1240940&r1=1240939&r2=1240940&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java Mon Feb 6 09:14:01 2012
@@ -36,8 +36,6 @@ import java.nio.charset.CoderResult;
import java.nio.charset.UnsupportedCharsetException;
import org.apache.http.HttpEntity;
-import org.apache.http.HttpException;
-import org.apache.http.HttpResponse;
import org.apache.http.entity.ContentType;
import org.apache.http.nio.ContentDecoder;
import org.apache.http.nio.IOControl;
@@ -48,7 +46,6 @@ public abstract class AsyncCharConsumer<
private final int bufSize;
private ContentType contentType;
- private Charset charset;
private CharsetDecoder chardecoder;
private ByteBuffer bbuf;
private CharBuffer cbuf;
@@ -63,32 +60,31 @@ public abstract class AsyncCharConsumer<
}
protected abstract void onCharReceived(
- final CharBuffer buf, final IOControl ioctrl) throws IOException;
+ CharBuffer buf, IOControl ioctrl) throws IOException;
@Override
- public synchronized void responseReceived(
- final HttpResponse response) throws IOException, HttpException {
- HttpEntity entity = response.getEntity();
- this.contentType = ContentType.getOrDefault(entity);
- super.responseReceived(response);
+ protected final void onEntityEnclosed(
+ final HttpEntity entity, final ContentType contentType) throws IOException {
+ this.contentType = contentType != null ? contentType : ContentType.DEFAULT_TEXT;
+ try {
+ String cs = this.contentType.getCharset();
+ if (cs == null) {
+ cs = HTTP.DEFAULT_CONTENT_CHARSET;
+ }
+ Charset charset = Charset.forName(cs);
+ this.chardecoder = charset.newDecoder();
+ } catch (UnsupportedCharsetException ex) {
+ throw new UnsupportedEncodingException(this.contentType.getCharset());
+ }
+ this.bbuf = ByteBuffer.allocate(this.bufSize);
+ this.cbuf = CharBuffer.allocate(this.bufSize);
}
@Override
- protected void onContentReceived(
+ protected final void onContentReceived(
final ContentDecoder decoder, final IOControl ioctrl) throws IOException {
- if (this.charset == null) {
- try {
- String cs = this.contentType.getCharset();
- if (cs == null) {
- cs = HTTP.DEFAULT_CONTENT_CHARSET;
- }
- this.charset = Charset.forName(cs);
- } catch (UnsupportedCharsetException ex) {
- throw new UnsupportedEncodingException(this.contentType.getCharset());
- }
- this.chardecoder = this.charset.newDecoder();
- this.bbuf = ByteBuffer.allocate(this.bufSize);
- this.cbuf = CharBuffer.allocate(this.bufSize);
+ if (this.bbuf == null) {
+ throw new IllegalStateException("Byte buffer is null");
}
for (;;) {
int bytesRead = decoder.read(this.bbuf);
@@ -121,7 +117,6 @@ public abstract class AsyncCharConsumer<
@Override
protected void releaseResources() {
- this.charset = null;
this.chardecoder = null;
this.bbuf = null;
this.cbuf = null;
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseZeroCopyRequestProducer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseZeroCopyRequestProducer.java?rev=1240940&r1=1240939&r2=1240940&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseZeroCopyRequestProducer.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseZeroCopyRequestProducer.java Mon Feb 6 09:14:01 2012
@@ -70,6 +70,13 @@ abstract class BaseZeroCopyRequestProduc
this.contentType = contentType;
}
+ private void closeChannel() throws IOException {
+ if (this.fileChannel != null) {
+ this.fileChannel.close();
+ this.fileChannel = null;
+ }
+ }
+
protected abstract HttpEntityEnclosingRequest createRequest(final URI requestURI, final HttpEntity entity);
public HttpRequest generateRequest() throws IOException, HttpException {
@@ -107,30 +114,26 @@ abstract class BaseZeroCopyRequestProduc
if (this.idx >= this.fileChannel.size()) {
encoder.complete();
- this.fileChannel.close();
- this.fileChannel = null;
+ closeChannel();
}
}
public void requestCompleted(final HttpContext context) {
}
- public synchronized boolean isRepeatable() {
+ public void failed(final Exception ex) {
+ }
+
+ public boolean isRepeatable() {
return true;
}
- public synchronized void resetRequest() {
- try {
- close();
- } catch (IOException ignore) {
- }
+ public synchronized void resetRequest() throws IOException {
+ closeChannel();
}
public synchronized void close() throws IOException {
- if (this.fileChannel != null) {
- this.fileChannel.close();
- this.fileChannel = null;
- }
+ closeChannel();
}
}
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncMethods.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncMethods.java?rev=1240940&r1=1240939&r2=1240940&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncMethods.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncMethods.java Mon Feb 6 09:14:01 2012
@@ -43,9 +43,9 @@ import org.apache.http.client.methods.Ht
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.utils.URIUtils;
import org.apache.http.entity.ContentType;
+import org.apache.http.nio.entity.HttpAsyncContentProducer;
import org.apache.http.nio.entity.NByteArrayEntity;
import org.apache.http.nio.entity.NStringEntity;
-import org.apache.http.nio.entity.ProducingNHttpEntity;
import org.apache.http.nio.protocol.BasicAsyncRequestProducer;
import org.apache.http.nio.protocol.BasicAsyncResponseConsumer;
import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
@@ -217,7 +217,10 @@ public final class HttpAsyncMethods {
return new ZeroCopyConsumer<HttpResponse>(file) {
@Override
- protected HttpResponse process(final HttpResponse response, final File file) throws Exception {
+ protected HttpResponse process(
+ final HttpResponse response,
+ final File file,
+ final ContentType contentType) {
return response;
}
@@ -229,7 +232,7 @@ public final class HttpAsyncMethods {
protected RequestProducerImpl(
final HttpHost target,
final HttpEntityEnclosingRequest request,
- final ProducingNHttpEntity producer) {
+ final HttpAsyncContentProducer producer) {
super(target, request, producer);
}
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyConsumer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyConsumer.java?rev=1240940&r1=1240939&r2=1240940&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyConsumer.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyConsumer.java Mon Feb 6 09:14:01 2012
@@ -31,7 +31,9 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
+import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
+import org.apache.http.entity.ContentType;
import org.apache.http.entity.FileEntity;
import org.apache.http.nio.ContentDecoder;
import org.apache.http.nio.ContentDecoderChannel;
@@ -46,6 +48,7 @@ public abstract class ZeroCopyConsumer<T
private final File file;
private HttpResponse response;
+ private ContentType contentType;
private FileChannel fileChannel;
private long idx = -1;
@@ -63,12 +66,18 @@ public abstract class ZeroCopyConsumer<T
}
@Override
+ protected void onEntityEnclosed(
+ final HttpEntity entity, final ContentType contentType) throws IOException {
+ this.contentType = contentType;
+ this.fileChannel = new FileOutputStream(this.file).getChannel();
+ this.idx = 0;
+ }
+
+ @Override
protected void onContentReceived(
final ContentDecoder decoder, final IOControl ioctrl) throws IOException {
if (this.fileChannel == null) {
- FileOutputStream out = new FileOutputStream(this.file);
- this.fileChannel = out.getChannel();
- this.idx = 0;
+ throw new IllegalStateException("File channel is null");
}
long transferred;
if (decoder instanceof FileContentDecoder) {
@@ -87,14 +96,15 @@ public abstract class ZeroCopyConsumer<T
}
}
- protected abstract T process(final HttpResponse response, final File file) throws Exception;
+ protected abstract T process(
+ HttpResponse response, File file, ContentType contentType) throws Exception;
@Override
protected T buildResult(final HttpContext context) throws Exception {
FileEntity entity = new FileEntity(this.file);
entity.setContentType(this.response.getFirstHeader(HTTP.CONTENT_TYPE));
this.response.setEntity(entity);
- return process(this.response, this.file);
+ return process(this.response, this.file, this.contentType);
}
@Override
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/OperatedAsyncClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/OperatedAsyncClientConnection.java?rev=1240940&r1=1240939&r2=1240940&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/OperatedAsyncClientConnection.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/OperatedAsyncClientConnection.java Mon Feb 6 09:14:01 2012
@@ -28,11 +28,9 @@ package org.apache.http.nio.conn;
import org.apache.http.HttpInetConnection;
import org.apache.http.nio.NHttpClientConnection;
-import org.apache.http.nio.NHttpClientIOTarget;
import org.apache.http.nio.reactor.IOSession;
-public interface OperatedAsyncClientConnection
- extends NHttpClientConnection, HttpInetConnection, NHttpClientIOTarget {
+public interface OperatedAsyncClientConnection extends NHttpClientConnection, HttpInetConnection {
void upgrade(IOSession iosession);
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/HttpAsyncTestBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/HttpAsyncTestBase.java?rev=1240940&r1=1240939&r2=1240940&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/HttpAsyncTestBase.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/HttpAsyncTestBase.java Mon Feb 6 09:14:01 2012
@@ -30,12 +30,12 @@ package org.apache.http;
import java.io.IOException;
import org.apache.http.HttpResponseInterceptor;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
import org.apache.http.impl.nio.client.DefaultHttpAsyncClient;
import org.apache.http.impl.nio.conn.PoolingAsyncClientConnectionManager;
import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor;
import org.apache.http.localserver.HttpServerNio;
import org.apache.http.nio.NHttpConnectionFactory;
-import org.apache.http.nio.NHttpServerIOTarget;
import org.apache.http.nio.conn.scheme.AsyncScheme;
import org.apache.http.nio.conn.scheme.AsyncSchemeRegistry;
import org.apache.http.nio.reactor.IOReactorExceptionHandler;
@@ -60,7 +60,7 @@ public abstract class HttpAsyncTestBase
protected PoolingAsyncClientConnectionManager connMgr;
protected DefaultHttpAsyncClient httpclient;
- protected abstract NHttpConnectionFactory<NHttpServerIOTarget> createServerConnectionFactory(
+ protected abstract NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
HttpParams params) throws Exception;
protected abstract String getSchemeName();
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestClientAuthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestClientAuthentication.java?rev=1240940&r1=1240939&r2=1240940&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestClientAuthentication.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestClientAuthentication.java Mon Feb 6 09:14:01 2012
@@ -47,26 +47,26 @@ import org.apache.http.client.Credential
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
-import org.apache.http.concurrent.Cancellable;
import org.apache.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.http.impl.DefaultHttpResponseFactory;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.DefaultTargetAuthenticationHandler;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
import org.apache.http.impl.nio.DefaultNHttpServerConnectionFactory;
import org.apache.http.localserver.BasicAuthTokenExtractor;
import org.apache.http.localserver.RequestBasicAuth;
import org.apache.http.localserver.ResponseBasicUnauthorized;
import org.apache.http.message.BasicHttpResponse;
import org.apache.http.nio.NHttpConnectionFactory;
-import org.apache.http.nio.NHttpServerIOTarget;
import org.apache.http.nio.entity.NByteArrayEntity;
import org.apache.http.nio.entity.NStringEntity;
+import org.apache.http.nio.protocol.BasicAsyncRequestHandler;
import org.apache.http.nio.protocol.BasicAsyncResponseProducer;
-import org.apache.http.nio.protocol.BufferingAsyncRequestHandler;
-import org.apache.http.nio.protocol.HttpAsyncContinueTrigger;
+import org.apache.http.nio.protocol.HttpAsyncExchange;
import org.apache.http.nio.protocol.HttpAsyncExpectationVerifier;
import org.apache.http.nio.protocol.HttpAsyncRequestHandlerRegistry;
import org.apache.http.nio.protocol.HttpAsyncRequestHandlerResolver;
-import org.apache.http.nio.protocol.HttpAsyncServiceHandler;
+import org.apache.http.nio.protocol.HttpAsyncService;
import org.apache.http.nio.reactor.IOReactorStatus;
import org.apache.http.nio.reactor.ListenerEndpoint;
import org.apache.http.params.CoreProtocolPNames;
@@ -117,7 +117,7 @@ public class TestClientAuthentication ex
}
@Override
- protected NHttpConnectionFactory<NHttpServerIOTarget> createServerConnectionFactory(
+ protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
final HttpParams params) throws Exception {
return new DefaultNHttpServerConnectionFactory(params);
}
@@ -130,11 +130,12 @@ public class TestClientAuthentication ex
private HttpHost start(
final HttpAsyncRequestHandlerResolver requestHandlerResolver,
final HttpAsyncExpectationVerifier expectationVerifier) throws Exception {
- HttpAsyncServiceHandler serviceHandler = new HttpAsyncServiceHandler(
- requestHandlerResolver,
- expectationVerifier,
+ HttpAsyncService serviceHandler = new HttpAsyncService(
this.serverHttpProc,
new DefaultConnectionReuseStrategy(),
+ new DefaultHttpResponseFactory(),
+ requestHandlerResolver,
+ expectationVerifier,
this.serverParams);
this.server.start(serviceHandler);
this.httpclient.start();
@@ -218,10 +219,10 @@ public class TestClientAuthentication ex
this.authTokenExtractor = new BasicAuthTokenExtractor();
}
- public Cancellable verify(
- final HttpRequest request,
- final HttpAsyncContinueTrigger trigger,
+ public void verify(
+ final HttpAsyncExchange httpexchange,
final HttpContext context) throws HttpException, IOException {
+ HttpRequest request = httpexchange.getRequest();
ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
if (!ver.lessEquals(HttpVersion.HTTP_1_1)) {
ver = HttpVersion.HTTP_1_1;
@@ -229,11 +230,10 @@ public class TestClientAuthentication ex
String creds = this.authTokenExtractor.extract(request);
if (creds == null || !creds.equals("test:test")) {
HttpResponse response = new BasicHttpResponse(ver, HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED");
- trigger.submitResponse(new BasicAsyncResponseProducer(response));
+ httpexchange.submitResponse(new BasicAsyncResponseProducer(response));
} else {
- trigger.continueRequest();
+ httpexchange.submitResponse();
}
- return null;
}
}
@@ -268,7 +268,7 @@ public class TestClientAuthentication ex
@Test
public void testBasicAuthenticationNoCreds() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(new AuthHandler()));
+ registry.register("*", new BasicAsyncRequestHandler(new AuthHandler()));
HttpHost target = start(registry, null);
TestCredentialsProvider credsProvider = new TestCredentialsProvider(null);
@@ -287,7 +287,7 @@ public class TestClientAuthentication ex
@Test
public void testBasicAuthenticationFailure() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(new AuthHandler()));
+ registry.register("*", new BasicAsyncRequestHandler(new AuthHandler()));
HttpHost target = start(registry, null);
TestCredentialsProvider credsProvider = new TestCredentialsProvider(
@@ -307,7 +307,7 @@ public class TestClientAuthentication ex
@Test
public void testBasicAuthenticationSuccess() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(new AuthHandler()));
+ registry.register("*", new BasicAsyncRequestHandler(new AuthHandler()));
HttpHost target = start(registry, null);
TestCredentialsProvider credsProvider = new TestCredentialsProvider(
@@ -327,7 +327,7 @@ public class TestClientAuthentication ex
@Test
public void testBasicAuthenticationSuccessNonPersistentConnection() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(new AuthHandler(false)));
+ registry.register("*", new BasicAsyncRequestHandler(new AuthHandler(false)));
HttpHost target = start(registry, null);
TestCredentialsProvider credsProvider = new TestCredentialsProvider(
@@ -335,7 +335,6 @@ public class TestClientAuthentication ex
this.httpclient.setCredentialsProvider(credsProvider);
HttpGet httpget = new HttpGet("/");
- httpget.addHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_CLOSE);
Future<HttpResponse> future = this.httpclient.execute(target, httpget, null);
HttpResponse response = future.get();
Assert.assertNotNull(response);
@@ -348,7 +347,7 @@ public class TestClientAuthentication ex
@Test
public void testBasicAuthenticationSuccessWithNonRepeatableExpectContinue() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(new AuthHandler()));
+ registry.register("*", new BasicAsyncRequestHandler(new AuthHandler()));
AuthExpectationVerifier expectationVerifier = new AuthExpectationVerifier();
HttpHost target = start(registry, expectationVerifier);
@@ -380,7 +379,7 @@ public class TestClientAuthentication ex
@Test(expected=ExecutionException.class)
public void testBasicAuthenticationFailureWithNonRepeatableEntityExpectContinueOff() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(new AuthHandler()));
+ registry.register("*", new BasicAsyncRequestHandler(new AuthHandler()));
HttpHost target = start(registry, null);
TestCredentialsProvider credsProvider = new TestCredentialsProvider(
@@ -416,7 +415,7 @@ public class TestClientAuthentication ex
@Test
public void testBasicAuthenticationSuccessOnRepeatablePost() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(new AuthHandler()));
+ registry.register("*", new BasicAsyncRequestHandler(new AuthHandler()));
HttpHost target = start(registry, null);
TestCredentialsProvider credsProvider = new TestCredentialsProvider(
@@ -439,7 +438,7 @@ public class TestClientAuthentication ex
@Test
public void testBasicAuthenticationCredentialsCaching() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(new AuthHandler()));
+ registry.register("*", new BasicAsyncRequestHandler(new AuthHandler()));
HttpHost target = start(registry, null);
BasicCredentialsProvider credsProvider = new BasicCredentialsProvider();
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpAsync.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpAsync.java?rev=1240940&r1=1240939&r2=1240940&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpAsync.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpAsync.java Mon Feb 6 09:14:01 2012
@@ -41,22 +41,23 @@ import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.http.impl.DefaultHttpResponseFactory;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
import org.apache.http.impl.nio.DefaultNHttpServerConnectionFactory;
import org.apache.http.localserver.EchoHandler;
import org.apache.http.localserver.RandomHandler;
import org.apache.http.nio.ContentDecoder;
import org.apache.http.nio.IOControl;
import org.apache.http.nio.NHttpConnectionFactory;
-import org.apache.http.nio.NHttpServerIOTarget;
import org.apache.http.nio.client.methods.HttpAsyncMethods;
import org.apache.http.nio.entity.NByteArrayEntity;
+import org.apache.http.nio.protocol.BasicAsyncRequestHandler;
import org.apache.http.nio.protocol.BasicAsyncResponseConsumer;
-import org.apache.http.nio.protocol.BufferingAsyncRequestHandler;
import org.apache.http.nio.protocol.HttpAsyncExpectationVerifier;
import org.apache.http.nio.protocol.HttpAsyncRequestHandlerRegistry;
import org.apache.http.nio.protocol.HttpAsyncRequestHandlerResolver;
import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
-import org.apache.http.nio.protocol.HttpAsyncServiceHandler;
+import org.apache.http.nio.protocol.HttpAsyncService;
import org.apache.http.nio.reactor.IOReactorStatus;
import org.apache.http.nio.reactor.ListenerEndpoint;
import org.apache.http.params.HttpParams;
@@ -81,7 +82,7 @@ public class TestHttpAsync extends HttpA
}
@Override
- protected NHttpConnectionFactory<NHttpServerIOTarget> createServerConnectionFactory(
+ protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
final HttpParams params) throws Exception {
return new DefaultNHttpServerConnectionFactory(params);
}
@@ -94,11 +95,12 @@ public class TestHttpAsync extends HttpA
private HttpHost start(
final HttpAsyncRequestHandlerResolver requestHandlerResolver,
final HttpAsyncExpectationVerifier expectationVerifier) throws Exception {
- HttpAsyncServiceHandler serviceHandler = new HttpAsyncServiceHandler(
- requestHandlerResolver,
- expectationVerifier,
+ HttpAsyncService serviceHandler = new HttpAsyncService(
this.serverHttpProc,
new DefaultConnectionReuseStrategy(),
+ new DefaultHttpResponseFactory(),
+ requestHandlerResolver,
+ expectationVerifier,
this.serverParams);
this.server.start(serviceHandler);
this.httpclient.start();
@@ -114,8 +116,8 @@ public class TestHttpAsync extends HttpA
private HttpHost start() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("/echo/*", new BufferingAsyncRequestHandler(new EchoHandler()));
- registry.register("/random/*", new BufferingAsyncRequestHandler(new RandomHandler()));
+ registry.register("/echo/*", new BasicAsyncRequestHandler(new EchoHandler()));
+ registry.register("/random/*", new BasicAsyncRequestHandler(new RandomHandler()));
return start(registry, null);
}
@@ -221,7 +223,7 @@ public class TestHttpAsync extends HttpA
BasicAsyncResponseConsumer responseConsumer = new BasicAsyncResponseConsumer() {
@Override
- public void consumeContent(final ContentDecoder decoder, final IOControl ioctrl)
+ public void onContentReceived(final ContentDecoder decoder, final IOControl ioctrl)
throws IOException {
throw new IOException("Kaboom");
}
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpsAsync.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpsAsync.java?rev=1240940&r1=1240939&r2=1240940&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpsAsync.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpsAsync.java Mon Feb 6 09:14:01 2012
@@ -27,9 +27,9 @@
package org.apache.http.impl.nio.client;
import org.apache.http.SSLTestContexts;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
import org.apache.http.impl.nio.SSLNHttpServerConnectionFactory;
import org.apache.http.nio.NHttpConnectionFactory;
-import org.apache.http.nio.NHttpServerIOTarget;
import org.apache.http.nio.conn.scheme.AsyncScheme;
import org.apache.http.nio.conn.ssl.SSLLayeringStrategy;
import org.apache.http.params.HttpParams;
@@ -37,7 +37,7 @@ import org.apache.http.params.HttpParams
public class TestHttpsAsync extends TestHttpAsync {
@Override
- protected NHttpConnectionFactory<NHttpServerIOTarget> createServerConnectionFactory(
+ protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
final HttpParams params) throws Exception {
return new SSLNHttpServerConnectionFactory(SSLTestContexts.createServerSSLContext(), null, params);
}
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpsRedirects.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpsRedirects.java?rev=1240940&r1=1240939&r2=1240940&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpsRedirects.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpsRedirects.java Mon Feb 6 09:14:01 2012
@@ -27,9 +27,9 @@
package org.apache.http.impl.nio.client;
import org.apache.http.SSLTestContexts;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
import org.apache.http.impl.nio.SSLNHttpServerConnectionFactory;
import org.apache.http.nio.NHttpConnectionFactory;
-import org.apache.http.nio.NHttpServerIOTarget;
import org.apache.http.nio.conn.scheme.AsyncScheme;
import org.apache.http.nio.conn.ssl.SSLLayeringStrategy;
import org.apache.http.params.HttpParams;
@@ -37,7 +37,7 @@ import org.apache.http.params.HttpParams
public class TestHttpsRedirects extends TestRedirects {
@Override
- protected NHttpConnectionFactory<NHttpServerIOTarget> createServerConnectionFactory(
+ protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
final HttpParams params) throws Exception {
return new SSLNHttpServerConnectionFactory(SSLTestContexts.createServerSSLContext(), null, params);
}
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestRedirects.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestRedirects.java?rev=1240940&r1=1240939&r2=1240940&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestRedirects.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestRedirects.java Mon Feb 6 09:14:01 2012
@@ -52,18 +52,19 @@ import org.apache.http.client.params.Cli
import org.apache.http.cookie.SM;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.http.impl.DefaultHttpResponseFactory;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.cookie.BasicClientCookie;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
import org.apache.http.impl.nio.DefaultNHttpServerConnectionFactory;
import org.apache.http.message.BasicHeader;
import org.apache.http.nio.NHttpConnectionFactory;
-import org.apache.http.nio.NHttpServerIOTarget;
import org.apache.http.nio.entity.NStringEntity;
-import org.apache.http.nio.protocol.BufferingAsyncRequestHandler;
+import org.apache.http.nio.protocol.BasicAsyncRequestHandler;
import org.apache.http.nio.protocol.HttpAsyncExpectationVerifier;
import org.apache.http.nio.protocol.HttpAsyncRequestHandlerRegistry;
import org.apache.http.nio.protocol.HttpAsyncRequestHandlerResolver;
-import org.apache.http.nio.protocol.HttpAsyncServiceHandler;
+import org.apache.http.nio.protocol.HttpAsyncService;
import org.apache.http.nio.reactor.IOReactorStatus;
import org.apache.http.nio.reactor.ListenerEndpoint;
import org.apache.http.params.HttpParams;
@@ -95,7 +96,7 @@ public class TestRedirects extends HttpA
}
@Override
- protected NHttpConnectionFactory<NHttpServerIOTarget> createServerConnectionFactory(
+ protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
final HttpParams params) throws Exception {
return new DefaultNHttpServerConnectionFactory(params);
}
@@ -108,11 +109,12 @@ public class TestRedirects extends HttpA
private HttpHost start(
final HttpAsyncRequestHandlerResolver requestHandlerResolver,
final HttpAsyncExpectationVerifier expectationVerifier) throws Exception {
- HttpAsyncServiceHandler serviceHandler = new HttpAsyncServiceHandler(
- requestHandlerResolver,
- expectationVerifier,
+ HttpAsyncService serviceHandler = new HttpAsyncService(
this.serverHttpProc,
new DefaultConnectionReuseStrategy(),
+ new DefaultHttpResponseFactory(),
+ requestHandlerResolver,
+ expectationVerifier,
this.serverParams);
this.server.start(serviceHandler);
this.httpclient.start();
@@ -276,7 +278,7 @@ public class TestRedirects extends HttpA
@Test
public void testBasicRedirect300() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(
+ registry.register("*", new BasicAsyncRequestHandler(
new BasicRedirectService(getSchemeName(), HttpStatus.SC_MULTIPLE_CHOICES)));
HttpHost target = start(registry, null);
@@ -298,7 +300,7 @@ public class TestRedirects extends HttpA
@Test
public void testBasicRedirect301() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(
+ registry.register("*", new BasicAsyncRequestHandler(
new BasicRedirectService(getSchemeName(), HttpStatus.SC_MOVED_PERMANENTLY)));
HttpHost target = start(registry, null);
@@ -323,7 +325,7 @@ public class TestRedirects extends HttpA
@Test
public void testBasicRedirect302() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(
+ registry.register("*", new BasicAsyncRequestHandler(
new BasicRedirectService(getSchemeName(), HttpStatus.SC_MOVED_TEMPORARILY)));
HttpHost target = start(registry, null);
@@ -348,7 +350,7 @@ public class TestRedirects extends HttpA
@Test
public void testBasicRedirect302NoLocation() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(new HttpRequestHandler() {
+ registry.register("*", new BasicAsyncRequestHandler(new HttpRequestHandler() {
public void handle(
final HttpRequest request,
@@ -381,7 +383,7 @@ public class TestRedirects extends HttpA
@Test
public void testBasicRedirect303() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(
+ registry.register("*", new BasicAsyncRequestHandler(
new BasicRedirectService(getSchemeName(), HttpStatus.SC_SEE_OTHER)));
HttpHost target = start(registry, null);
@@ -406,7 +408,7 @@ public class TestRedirects extends HttpA
@Test
public void testBasicRedirect304() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(
+ registry.register("*", new BasicAsyncRequestHandler(
new BasicRedirectService(getSchemeName(), HttpStatus.SC_NOT_MODIFIED)));
HttpHost target = start(registry, null);
@@ -428,7 +430,7 @@ public class TestRedirects extends HttpA
@Test
public void testBasicRedirect305() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(
+ registry.register("*", new BasicAsyncRequestHandler(
new BasicRedirectService(getSchemeName(), HttpStatus.SC_USE_PROXY)));
HttpHost target = start(registry, null);
@@ -450,7 +452,7 @@ public class TestRedirects extends HttpA
@Test
public void testBasicRedirect307() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(
+ registry.register("*", new BasicAsyncRequestHandler(
new BasicRedirectService(getSchemeName(), HttpStatus.SC_TEMPORARY_REDIRECT)));
HttpHost target = start(registry, null);
@@ -475,7 +477,7 @@ public class TestRedirects extends HttpA
@Test(expected=ExecutionException.class)
public void testMaxRedirectCheck() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(new CircularRedirectService()));
+ registry.register("*", new BasicAsyncRequestHandler(new CircularRedirectService()));
HttpHost target = start(registry, null);
this.httpclient.getParams().setBooleanParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true);
@@ -494,7 +496,7 @@ public class TestRedirects extends HttpA
@Test(expected=ExecutionException.class)
public void testCircularRedirect() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(new CircularRedirectService()));
+ registry.register("*", new BasicAsyncRequestHandler(new CircularRedirectService()));
HttpHost target = start(registry, null);
this.httpclient.getParams().setBooleanParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, false);
@@ -513,7 +515,7 @@ public class TestRedirects extends HttpA
@Test
public void testPostNoRedirect() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(
+ registry.register("*", new BasicAsyncRequestHandler(
new BasicRedirectService(getSchemeName(), HttpStatus.SC_MOVED_TEMPORARILY)));
HttpHost target = start(registry, null);
@@ -537,7 +539,7 @@ public class TestRedirects extends HttpA
@Test
public void testPostRedirectSeeOther() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(
+ registry.register("*", new BasicAsyncRequestHandler(
new BasicRedirectService(getSchemeName(), HttpStatus.SC_SEE_OTHER)));
HttpHost target = start(registry, null);
@@ -561,7 +563,7 @@ public class TestRedirects extends HttpA
@Test
public void testRelativeRedirect() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(new RelativeRedirectService()));
+ registry.register("*", new BasicAsyncRequestHandler(new RelativeRedirectService()));
HttpHost target = start(registry, null);
HttpContext context = new BasicHttpContext();
@@ -587,7 +589,7 @@ public class TestRedirects extends HttpA
@Test
public void testRelativeRedirect2() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(new RelativeRedirectService2()));
+ registry.register("*", new BasicAsyncRequestHandler(new RelativeRedirectService2()));
HttpHost target = start(registry, null);
HttpContext context = new BasicHttpContext();
@@ -613,7 +615,7 @@ public class TestRedirects extends HttpA
@Test(expected=ExecutionException.class)
public void testRejectRelativeRedirect() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(new RelativeRedirectService()));
+ registry.register("*", new BasicAsyncRequestHandler(new RelativeRedirectService()));
HttpHost target = start(registry, null);
this.httpclient.getParams().setBooleanParameter(
@@ -632,7 +634,7 @@ public class TestRedirects extends HttpA
@Test(expected=ExecutionException.class)
public void testRejectBogusRedirectLocation() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(
+ registry.register("*", new BasicAsyncRequestHandler(
new BogusRedirectService(getSchemeName(), "xxx://bogus", true)));
HttpHost target = start(registry, null);
@@ -650,7 +652,7 @@ public class TestRedirects extends HttpA
@Test(expected=ExecutionException.class)
public void testRejectInvalidRedirectLocation() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(
+ registry.register("*", new BasicAsyncRequestHandler(
new BogusRedirectService(getSchemeName(), "/newlocation/?p=I have spaces", false)));
HttpHost target = start(registry, null);
@@ -667,7 +669,7 @@ public class TestRedirects extends HttpA
@Test
public void testRedirectWithCookie() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(
+ registry.register("*", new BasicAsyncRequestHandler(
new BasicRedirectService(getSchemeName(), HttpStatus.SC_MOVED_TEMPORARILY)));
HttpHost target = start(registry, null);
@@ -700,7 +702,7 @@ public class TestRedirects extends HttpA
@Test
public void testDefaultHeadersRedirect() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(
+ registry.register("*", new BasicAsyncRequestHandler(
new BasicRedirectService(getSchemeName(), HttpStatus.SC_MOVED_TEMPORARILY)));
HttpHost target = start(registry, null);
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestStatefulConnManagement.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestStatefulConnManagement.java?rev=1240940&r1=1240939&r2=1240940&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestStatefulConnManagement.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestStatefulConnManagement.java Mon Feb 6 09:14:01 2012
@@ -31,6 +31,7 @@ import java.nio.ByteBuffer;
import java.util.concurrent.Future;
import org.apache.http.HttpAsyncTestBase;
+import org.apache.http.HttpEntity;
import org.apache.http.HttpException;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
@@ -38,22 +39,24 @@ import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.UserTokenHandler;
import org.apache.http.client.methods.HttpGet;
+import org.apache.http.entity.ContentType;
import org.apache.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.http.impl.DefaultHttpResponseFactory;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
import org.apache.http.impl.nio.DefaultNHttpServerConnectionFactory;
import org.apache.http.nio.ContentDecoder;
import org.apache.http.nio.IOControl;
import org.apache.http.nio.NHttpConnectionFactory;
-import org.apache.http.nio.NHttpServerIOTarget;
import org.apache.http.nio.client.HttpAsyncClient;
import org.apache.http.nio.conn.ManagedAsyncClientConnection;
import org.apache.http.nio.entity.NStringEntity;
import org.apache.http.nio.protocol.AbstractAsyncResponseConsumer;
+import org.apache.http.nio.protocol.BasicAsyncRequestHandler;
import org.apache.http.nio.protocol.BasicAsyncRequestProducer;
-import org.apache.http.nio.protocol.BufferingAsyncRequestHandler;
import org.apache.http.nio.protocol.HttpAsyncExpectationVerifier;
import org.apache.http.nio.protocol.HttpAsyncRequestHandlerRegistry;
import org.apache.http.nio.protocol.HttpAsyncRequestHandlerResolver;
-import org.apache.http.nio.protocol.HttpAsyncServiceHandler;
+import org.apache.http.nio.protocol.HttpAsyncService;
import org.apache.http.nio.reactor.IOReactorStatus;
import org.apache.http.nio.reactor.ListenerEndpoint;
import org.apache.http.params.BasicHttpParams;
@@ -83,7 +86,7 @@ public class TestStatefulConnManagement
}
@Override
- protected NHttpConnectionFactory<NHttpServerIOTarget> createServerConnectionFactory(
+ protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
final HttpParams params) throws Exception {
return new DefaultNHttpServerConnectionFactory(params);
}
@@ -96,11 +99,12 @@ public class TestStatefulConnManagement
private HttpHost start(
final HttpAsyncRequestHandlerResolver requestHandlerResolver,
final HttpAsyncExpectationVerifier expectationVerifier) throws Exception {
- HttpAsyncServiceHandler serviceHandler = new HttpAsyncServiceHandler(
- requestHandlerResolver,
- expectationVerifier,
+ HttpAsyncService serviceHandler = new HttpAsyncService(
this.serverHttpProc,
new DefaultConnectionReuseStrategy(),
+ new DefaultHttpResponseFactory(),
+ requestHandlerResolver,
+ expectationVerifier,
this.serverParams);
this.server.start(serviceHandler);
this.httpclient.start();
@@ -142,7 +146,7 @@ public class TestStatefulConnManagement
});
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(new SimpleService()));
+ registry.register("*", new BasicAsyncRequestHandler(new SimpleService()));
HttpHost target = start(registry, null);
@@ -233,6 +237,12 @@ public class TestStatefulConnManagement
}
@Override
+ protected void onEntityEnclosed(
+ final HttpEntity entity,
+ final ContentType contentType) throws IOException {
+ }
+
+ @Override
protected void onContentReceived(
final ContentDecoder decoder,
final IOControl ioctrl) throws IOException {
@@ -285,7 +295,7 @@ public class TestStatefulConnManagement
this.connMgr.setDefaultMaxPerRoute(maxConn);
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("*", new BufferingAsyncRequestHandler(new SimpleService()));
+ registry.register("*", new BasicAsyncRequestHandler(new SimpleService()));
HttpHost target = start(registry, null);
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/localserver/HttpServerNio.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/localserver/HttpServerNio.java?rev=1240940&r1=1240939&r2=1240940&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/localserver/HttpServerNio.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/localserver/HttpServerNio.java Mon Feb 6 09:14:01 2012
@@ -31,12 +31,12 @@ import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.List;
-import org.apache.http.impl.nio.DefaultServerIODispatch;
+import org.apache.http.impl.nio.DefaultHttpServerIODispatch;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
import org.apache.http.impl.nio.reactor.DefaultListeningIOReactor;
import org.apache.http.impl.nio.reactor.ExceptionEvent;
import org.apache.http.nio.NHttpConnectionFactory;
-import org.apache.http.nio.NHttpServerIOTarget;
-import org.apache.http.nio.NHttpServiceHandler;
+import org.apache.http.nio.NHttpServerEventHandler;
import org.apache.http.nio.reactor.IOEventDispatch;
import org.apache.http.nio.reactor.IOReactorExceptionHandler;
import org.apache.http.nio.reactor.IOReactorStatus;
@@ -46,13 +46,13 @@ import org.apache.http.nio.reactor.Liste
public class HttpServerNio {
private final DefaultListeningIOReactor ioReactor;
- private final NHttpConnectionFactory<NHttpServerIOTarget> connFactory;
+ private final NHttpConnectionFactory<DefaultNHttpServerConnection> connFactory;
private volatile IOReactorThread thread;
private ListenerEndpoint endpoint;
public HttpServerNio(
- final NHttpConnectionFactory<NHttpServerIOTarget> connFactory) throws IOException {
+ final NHttpConnectionFactory<DefaultNHttpServerConnection> connFactory) throws IOException {
super();
this.ioReactor = new DefaultListeningIOReactor();
this.connFactory = connFactory;
@@ -62,8 +62,9 @@ public class HttpServerNio {
this.ioReactor.setExceptionHandler(exceptionHandler);
}
- private void execute(final NHttpServiceHandler serviceHandler) throws IOException {
- IOEventDispatch ioEventDispatch = new DefaultServerIODispatch(serviceHandler, this.connFactory);
+ private void execute(final NHttpServerEventHandler serviceHandler) throws IOException {
+ IOEventDispatch ioEventDispatch = new DefaultHttpServerIODispatch(serviceHandler,
+ this.connFactory);
this.ioReactor.execute(ioEventDispatch);
}
@@ -75,7 +76,7 @@ public class HttpServerNio {
this.endpoint = endpoint;
}
- public void start(final NHttpServiceHandler serviceHandler) {
+ public void start(final NHttpServerEventHandler serviceHandler) {
this.endpoint = this.ioReactor.listen(new InetSocketAddress(0));
this.thread = new IOReactorThread(serviceHandler);
this.thread.start();
@@ -117,11 +118,11 @@ public class HttpServerNio {
private class IOReactorThread extends Thread {
- private final NHttpServiceHandler serviceHandler;
+ private final NHttpServerEventHandler serviceHandler;
private volatile Exception ex;
- public IOReactorThread(final NHttpServiceHandler serviceHandler) {
+ public IOReactorThread(final NHttpServerEventHandler serviceHandler) {
super();
this.serviceHandler = serviceHandler;
}
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java?rev=1240940&r1=1240939&r2=1240940&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java Mon Feb 6 09:14:01 2012
@@ -40,19 +40,19 @@ import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.entity.ContentType;
import org.apache.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.http.impl.DefaultHttpResponseFactory;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
import org.apache.http.impl.nio.DefaultNHttpServerConnectionFactory;
import org.apache.http.localserver.EchoHandler;
import org.apache.http.localserver.RandomHandler;
-import org.apache.http.nio.ContentDecoder;
import org.apache.http.nio.IOControl;
import org.apache.http.nio.NHttpConnectionFactory;
-import org.apache.http.nio.NHttpServerIOTarget;
-import org.apache.http.nio.protocol.BufferingAsyncRequestHandler;
+import org.apache.http.nio.protocol.BasicAsyncRequestHandler;
import org.apache.http.nio.protocol.HttpAsyncExpectationVerifier;
import org.apache.http.nio.protocol.HttpAsyncRequestHandlerRegistry;
import org.apache.http.nio.protocol.HttpAsyncRequestHandlerResolver;
import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
-import org.apache.http.nio.protocol.HttpAsyncServiceHandler;
+import org.apache.http.nio.protocol.HttpAsyncService;
import org.apache.http.nio.reactor.IOReactorStatus;
import org.apache.http.nio.reactor.ListenerEndpoint;
import org.apache.http.params.HttpParams;
@@ -79,7 +79,7 @@ public class TestAsyncConsumers extends
}
@Override
- protected NHttpConnectionFactory<NHttpServerIOTarget> createServerConnectionFactory(
+ protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
final HttpParams params) throws Exception {
return new DefaultNHttpServerConnectionFactory(params);
}
@@ -92,11 +92,12 @@ public class TestAsyncConsumers extends
private HttpHost start(
final HttpAsyncRequestHandlerResolver requestHandlerResolver,
final HttpAsyncExpectationVerifier expectationVerifier) throws Exception {
- HttpAsyncServiceHandler serviceHandler = new HttpAsyncServiceHandler(
- requestHandlerResolver,
- expectationVerifier,
+ HttpAsyncService serviceHandler = new HttpAsyncService(
this.serverHttpProc,
new DefaultConnectionReuseStrategy(),
+ new DefaultHttpResponseFactory(),
+ requestHandlerResolver,
+ expectationVerifier,
this.serverParams);
this.server.start(serviceHandler);
this.httpclient.start();
@@ -112,8 +113,8 @@ public class TestAsyncConsumers extends
private HttpHost start() throws Exception {
HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
- registry.register("/echo/*", new BufferingAsyncRequestHandler(new EchoHandler()));
- registry.register("/random/*", new BufferingAsyncRequestHandler(new RandomHandler()));
+ registry.register("/echo/*", new BasicAsyncRequestHandler(new EchoHandler()));
+ registry.register("/random/*", new BasicAsyncRequestHandler(new RandomHandler()));
return start(registry, null);
}
@@ -134,7 +135,7 @@ public class TestAsyncConsumers extends
}
@Override
- protected void onByteReceived(final ByteBuffer buf, final IOControl ioctrl) throws IOException {
+ protected void onByteReceived(final ByteBuffer buf, final IOControl ioctrl) {
this.count.addAndGet(buf.remaining());
}
@@ -182,7 +183,7 @@ public class TestAsyncConsumers extends
private StringBuilder sb = new StringBuilder();
@Override
- protected void onResponseReceived(final HttpResponse response) {
+ public void onResponseReceived(final HttpResponse response) {
}
@Override
@@ -264,7 +265,6 @@ public class TestAsyncConsumers extends
Future<String> future = this.httpclient.execute(httppost, consumer, null);
String result = future.get();
Assert.assertEquals(s, result);
- Mockito.verify(consumer).responseCompleted(Mockito.any(HttpContext.class));
Mockito.verify(consumer).buildResult(Mockito.any(HttpContext.class));
Mockito.verify(consumer).releaseResources();
}
@@ -276,8 +276,8 @@ public class TestAsyncConsumers extends
target.toURI() + "/echo/stuff", "stuff",
ContentType.create("text/plain", HTTP.ASCII));
AsyncCharConsumer<String> consumer = Mockito.spy(new BufferingCharConsumer());
- Mockito.doThrow(new IOException("Kaboom")).when(consumer).consumeContent(
- Mockito.any(ContentDecoder.class), Mockito.any(IOControl.class));
+ Mockito.doThrow(new IOException("Kaboom")).when(consumer).onCharReceived(
+ Mockito.any(CharBuffer.class), Mockito.any(IOControl.class));
Future<String> future = this.httpclient.execute(httppost, consumer, null);
try {
@@ -289,7 +289,6 @@ public class TestAsyncConsumers extends
Assert.assertTrue(t instanceof IOException);
Assert.assertEquals("Kaboom", t.getMessage());
}
- Mockito.verify(consumer).failed(Mockito.any(IOException.class));
Mockito.verify(consumer).releaseResources();
}
@@ -312,7 +311,6 @@ public class TestAsyncConsumers extends
Assert.assertTrue(t instanceof HttpException);
Assert.assertEquals("Kaboom", t.getMessage());
}
- Mockito.verify(consumer).responseCompleted(Mockito.any(HttpContext.class));
Mockito.verify(consumer).releaseResources();
}