hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1097205 - in /httpcomponents/httpasyncclient/trunk/httpasyncclient/src: examples/org/apache/http/examples/nio/client/ main/java/org/apache/http/impl/nio/client/ main/java/org/apache/http/nio/client/methods/ test/java/org/apache/http/nio/ t...
Date Wed, 27 Apr 2011 19:01:30 GMT
Author: olegk
Date: Wed Apr 27 19:01:28 2011
New Revision: 1097205

URL: http://svn.apache.org/viewvc?rev=1097205&view=rev
Log:
Added a number of common request producer / response consumer implementations

Added:
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/NHttpEntityWrapper.java   (with props)
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AbstractHttpAsyncResponseConsumer.java   (with props)
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncByteConsumer.java   (with props)
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java   (with props)
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncEntityRequestProducer.java   (with props)
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncRequestProducer.java   (with props)
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncDelete.java   (with props)
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncGet.java   (with props)
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncHead.java   (with props)
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncOptions.java   (with props)
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncPost.java   (with props)
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncPut.java   (with props)
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncTrace.java   (with props)
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java   (with props)
Modified:
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchangeStreaming.java
    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/BasicHttpAsyncRequestProducer.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/BasicHttpAsyncResponseConsumer.java

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchangeStreaming.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchangeStreaming.java?rev=1097205&r1=1097204&r2=1097205&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchangeStreaming.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchangeStreaming.java Wed Apr 27 19:01:28 2011
@@ -27,28 +27,15 @@
 package org.apache.http.examples.nio.client;
 
 import java.io.IOException;
-import java.nio.ByteBuffer;
 import java.nio.CharBuffer;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CoderResult;
 import java.util.concurrent.Future;
 
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.impl.nio.client.DefaultHttpAsyncClient;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.nio.ContentDecoder;
-import org.apache.http.nio.ContentEncoder;
 import org.apache.http.nio.IOControl;
 import org.apache.http.nio.client.HttpAsyncClient;
-import org.apache.http.nio.client.HttpAsyncRequestProducer;
-import org.apache.http.nio.client.HttpAsyncResponseConsumer;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.util.EntityUtils;
+import org.apache.http.nio.client.methods.AsyncCharConsumer;
+import org.apache.http.nio.client.methods.HttpAsyncGet;
 
 public class AsyncClientHttpExchangeStreaming {
 
@@ -57,7 +44,8 @@ public class AsyncClientHttpExchangeStre
         httpclient.start();
         try {
             Future<Boolean> future = httpclient.execute(
-                    new MyRequestProducer(), new MyResponseConsumer(), null);
+                    new HttpAsyncGet("http://localhost:8080/"),
+                    new MyResponseConsumer(), null);
             Boolean result = future.get();
             if (result != null && result.booleanValue()) {
                 System.out.println("Request successfully executed");
@@ -71,90 +59,26 @@ public class AsyncClientHttpExchangeStre
         System.out.println("Done");
     }
 
-    static class MyRequestProducer implements HttpAsyncRequestProducer {
+    static class MyResponseConsumer extends AsyncCharConsumer<Boolean> {
 
-        public HttpRequest generateRequest() throws IOException, HttpException {
-            BasicHttpRequest request = new BasicHttpRequest("GET", "/");
-            return request;
+        @Override
+        protected void onResponseReceived(final HttpResponse response) {
         }
 
-        public HttpHost getTarget() {
-            return new HttpHost("www.apache.org");
-        }
-
-        public boolean isRepeatable() {
-            return true;
-        }
-
-        public void produceContent(
-                final ContentEncoder encoder, final IOControl ioctrl) throws IOException {
-            // Should never be called for non entity enclosing requests
-        }
-
-        public void resetRequest() {
-        }
-
-    }
-
-    static class MyResponseConsumer implements HttpAsyncResponseConsumer<Boolean> {
-
-        private Charset charset;
-        private CharsetDecoder decoder;
-        private ByteBuffer bbuf;
-        private CharBuffer cbuf;
-
-        private volatile Boolean result;
-
-        public synchronized void responseReceived(
-                final HttpResponse response) throws IOException, HttpException {
-            System.out.println("HTTP response: " + response.getStatusLine());
-            HttpEntity entity = response.getEntity();
-            if (entity != null) {
-                String s = EntityUtils.getContentCharSet(entity);
-                if (s == null) {
-                    s = HTTP.DEFAULT_CONTENT_CHARSET;
-                }
-                this.charset = Charset.forName(s);
-                this.decoder = this.charset.newDecoder();
-                this.bbuf = ByteBuffer.allocate(1024);
-                this.cbuf = CharBuffer.allocate(1024);
+        @Override
+        protected void onCharReceived(final CharBuffer buf, final IOControl ioctrl) throws IOException {
+            while (buf.hasRemaining()) {
+                System.out.print(buf.get());
             }
         }
 
-        public synchronized void consumeContent(
-                final ContentDecoder decoder, final IOControl ioctrl) throws IOException {
-            int bytesRead;
-            do {
-                bytesRead = decoder.read(this.bbuf);
-                this.bbuf.flip();
-                CoderResult result = this.decoder.decode(this.bbuf, this.cbuf, decoder.isCompleted());
-                if (result.isError()) {
-                    result.throwException();
-                }
-                this.bbuf.compact();
-                this.cbuf.flip();
-                while (this.cbuf.hasRemaining()) {
-                    System.out.print(this.cbuf.get());
-                }
-                this.cbuf.compact();
-            } while (bytesRead > 0);
-        }
-
-        public void responseCompleted() {
-            this.result = Boolean.TRUE;
-        }
-
-        public void cancel() {
-            this.result = Boolean.FALSE;
-        }
-
-        public void failed(final Exception ex) {
-            this.result = Boolean.FALSE;
-            ex.printStackTrace();
+        @Override
+        protected void onCleanup() {
         }
 
-        public Boolean getResult() {
-            return this.result;
+        @Override
+        protected Boolean buildResult() {
+            return Boolean.TRUE;
         }
 
     }

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=1097205&r1=1097204&r2=1097205&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 Wed Apr 27 19:01:28 2011
@@ -319,7 +319,7 @@ public abstract class AbstractHttpAsyncC
             final HttpContext context,
             final FutureCallback<T> callback) {
         if (this.terminated) {
-            throw new IllegalStateException("Client terminated");
+            throw new IllegalStateException("Client has been shut down");
         }
         BasicFuture<T> future = new BasicFuture<T>(callback);
         ResultCallback<T> resultCallback = new DefaultResultCallback<T>(future, this.queue);
@@ -366,22 +366,6 @@ public abstract class AbstractHttpAsyncC
         return execute(target, request, new BasicHttpContext(), callback);
     }
 
-    private HttpHost determineTarget(final HttpUriRequest request) throws ClientProtocolException {
-        // A null target may be acceptable if there is a default target.
-        // Otherwise, the null target is detected in the director.
-        HttpHost target = null;
-
-        URI requestURI = request.getURI();
-        if (requestURI.isAbsolute()) {
-            target = URIUtils.extractHost(requestURI);
-            if (target == null) {
-                throw new ClientProtocolException(
-                        "URI does not specify a valid host name: " + requestURI);
-            }
-        }
-        return target;
-    }
-
     public Future<HttpResponse> execute(
             final HttpUriRequest request,
             final FutureCallback<HttpResponse> callback) {
@@ -403,4 +387,20 @@ public abstract class AbstractHttpAsyncC
         return execute(target, request, context, callback);
     }
 
+    private HttpHost determineTarget(final HttpUriRequest request) throws ClientProtocolException {
+        // A null target may be acceptable if there is a default target.
+        // Otherwise, the null target is detected in the director.
+        HttpHost target = null;
+
+        URI requestURI = request.getURI();
+        if (requestURI.isAbsolute()) {
+            target = URIUtils.extractHost(requestURI);
+            if (target == null) {
+                throw new ClientProtocolException(
+                        "URI does not specify a valid host name: " + requestURI);
+            }
+        }
+        return target;
+    }
+
 }

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/BasicHttpAsyncRequestProducer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/BasicHttpAsyncRequestProducer.java?rev=1097205&r1=1097204&r2=1097205&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/BasicHttpAsyncRequestProducer.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/BasicHttpAsyncRequestProducer.java Wed Apr 27 19:01:28 2011
@@ -35,15 +35,13 @@ import org.apache.http.HttpRequest;
 import org.apache.http.nio.ContentEncoder;
 import org.apache.http.nio.IOControl;
 import org.apache.http.nio.client.HttpAsyncRequestProducer;
-import org.apache.http.nio.entity.NHttpEntityWrapper;
 import org.apache.http.nio.entity.ProducingNHttpEntity;
 
-public class BasicHttpAsyncRequestProducer implements HttpAsyncRequestProducer {
+class BasicHttpAsyncRequestProducer implements HttpAsyncRequestProducer {
 
     private final HttpHost target;
     private final HttpRequest request;
-
-    private volatile ProducingNHttpEntity contentProducingEntity;
+    private final ProducingNHttpEntity producer;
 
     public BasicHttpAsyncRequestProducer(final HttpHost target, final HttpRequest request) {
         super();
@@ -55,69 +53,54 @@ public class BasicHttpAsyncRequestProduc
         }
         this.target = target;
         this.request = request;
-    }
-
-    public HttpRequest generateRequest() {
-        return this.request;
-    }
-
-    public HttpHost getTarget() {
-        return this.target;
-    }
-
-    protected ProducingNHttpEntity createProducingHttpEntity(
-            final HttpRequest request) throws IOException {
         HttpEntity entity = null;
         if (request instanceof HttpEntityEnclosingRequest) {
             entity = ((HttpEntityEnclosingRequest) request).getEntity();
         }
         if (entity != null) {
             if (entity instanceof ProducingNHttpEntity) {
-                return (ProducingNHttpEntity) entity;
+                this.producer = (ProducingNHttpEntity) entity;
             } else {
-                return new NHttpEntityWrapper(entity);
+                this.producer = new NHttpEntityWrapper(entity);
             }
         } else {
-            return null;
+            this.producer = null;
         }
     }
 
-    private ProducingNHttpEntity getProducingHttpEntity() throws IOException {
-        if (this.contentProducingEntity == null) {
-            this.contentProducingEntity = createProducingHttpEntity(this.request);
-            if (this.contentProducingEntity == null) {
-                throw new IllegalStateException("Content producer is null");
-            }
-        }
-        return this.contentProducingEntity;
+    public HttpRequest generateRequest() {
+        return this.request;
+    }
+
+    public HttpHost getTarget() {
+        return this.target;
     }
 
     public synchronized void produceContent(
             final ContentEncoder encoder, final IOControl ioctrl) throws IOException {
-        ProducingNHttpEntity producer = getProducingHttpEntity();
-        producer.produceContent(encoder, ioctrl);
+        if (this.producer == null) {
+            throw new IllegalStateException("Content producer is null");
+        }
+        this.producer.produceContent(encoder, ioctrl);
+        if (encoder.isCompleted()) {
+            this.producer.finish();
+        }
     }
 
     public synchronized boolean isRepeatable() {
-        if (this.request instanceof HttpEntityEnclosingRequest) {
-            HttpEntity entity = ((HttpEntityEnclosingRequest) this.request).getEntity();
-            if (entity != null) {
-                return entity.isRepeatable();
-            } else {
-                return true;
-            }
+        if (this.producer != null) {
+            return this.producer.isRepeatable();
         } else {
             return true;
         }
     }
 
     public synchronized void resetRequest() {
-        if (this.contentProducingEntity != null) {
-            try {
-                this.contentProducingEntity.finish();
-                this.contentProducingEntity = null;
-            } catch (IOException ex) {
+        try {
+            if (this.producer != null) {
+                this.producer.finish();
             }
+        } catch (IOException ignore) {
         }
     }
 

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/BasicHttpAsyncResponseConsumer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/BasicHttpAsyncResponseConsumer.java?rev=1097205&r1=1097204&r2=1097205&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/BasicHttpAsyncResponseConsumer.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/BasicHttpAsyncResponseConsumer.java Wed Apr 27 19:01:28 2011
@@ -31,109 +31,45 @@ import java.io.IOException;
 import org.apache.http.HttpResponse;
 import org.apache.http.nio.ContentDecoder;
 import org.apache.http.nio.IOControl;
-import org.apache.http.nio.client.HttpAsyncResponseConsumer;
+import org.apache.http.nio.client.methods.AbstractHttpAsyncResponseConsumer;
 import org.apache.http.nio.entity.BufferingNHttpEntity;
 import org.apache.http.nio.entity.ConsumingNHttpEntity;
 import org.apache.http.nio.util.HeapByteBufferAllocator;
 
-public class BasicHttpAsyncResponseConsumer implements HttpAsyncResponseConsumer<HttpResponse> {
+class BasicHttpAsyncResponseConsumer extends AbstractHttpAsyncResponseConsumer<HttpResponse> {
 
     private volatile HttpResponse response;
-    private volatile ConsumingNHttpEntity contentConsumingEntity;
-    private volatile HttpResponse result;
-    private volatile Exception ex;
-    private volatile boolean completed;
+    private volatile ConsumingNHttpEntity consumer;
 
     public BasicHttpAsyncResponseConsumer() {
         super();
     }
 
-    protected ConsumingNHttpEntity createConsumingHttpEntity(
-            final HttpResponse response) throws IOException {
+    @Override
+    protected void onResponseReceived(final HttpResponse response) {
+        this.response = response;
         if (response.getEntity() != null) {
-            return new BufferingNHttpEntity(response.getEntity(), new HeapByteBufferAllocator());
+            this.consumer = new BufferingNHttpEntity(
+                    response.getEntity(), new HeapByteBufferAllocator());
         } else {
-            return null;
-        }
-    }
-
-    private ConsumingNHttpEntity getConsumingHttpEntity() throws IOException {
-        if (this.contentConsumingEntity == null) {
-            this.contentConsumingEntity = createConsumingHttpEntity(this.response);
-            if (this.contentConsumingEntity == null) {
-                throw new IllegalStateException("Content consumer is null");
-            }
-        }
-        return this.contentConsumingEntity;
-    }
-
-    private void releaseResources() {
-        if (this.contentConsumingEntity != null) {
-            try {
-                this.contentConsumingEntity.finish();
-                this.contentConsumingEntity = null;
-            } catch (IOException ex) {
-            }
-        }
-    }
-
-    public synchronized void responseReceived(final HttpResponse response) {
-        if (this.response != null) {
-            throw new IllegalStateException("HTTP response already set");
+            this.consumer = null;
         }
-        this.response = response;
+        this.response.setEntity(this.consumer);
     }
 
-    public synchronized void consumeContent(
+    @Override
+    protected void onContentReceived(
             final ContentDecoder decoder, final IOControl ioctrl) throws IOException {
-        ConsumingNHttpEntity consumer = getConsumingHttpEntity();
-        consumer.consumeContent(decoder, ioctrl);
-        if (decoder.isCompleted()) {
-            this.response.setEntity(consumer);
-            releaseResources();
-        }
-    }
-
-    public synchronized void responseCompleted() {
-        if (this.completed) {
-            return;
-        }
-        this.completed = true;
-        if (this.response != null) {
-            this.result = this.response;
-        }
-        releaseResources();
-    }
-
-    public synchronized void cancel() {
-        if (this.completed) {
-            return;
-        }
-        this.completed = true;
-        this.response = null;
-        releaseResources();
-    }
-
-    public synchronized void failed(final Exception ex) {
-        if (this.completed) {
-            return;
-        }
-        this.completed = true;
-        this.ex = ex;
-        this.response = null;
-        releaseResources();
-    }
-
-    public Exception getException() {
-        return this.ex;
+        this.consumer.consumeContent(decoder, ioctrl);
     }
 
-    public void setEx(Exception ex) {
-        this.ex = ex;
+    @Override
+    protected void onCleanup() {
     }
 
-    public HttpResponse getResult() {
-        return this.result;
+    @Override
+    protected HttpResponse buildResult() {
+        return this.response;
     }
 
 }

Added: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/NHttpEntityWrapper.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/NHttpEntityWrapper.java?rev=1097205&view=auto
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/NHttpEntityWrapper.java (added)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/NHttpEntityWrapper.java Wed Apr 27 19:01:28 2011
@@ -0,0 +1,99 @@
+/*
+ * ====================================================================
+ * 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.nio.client;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.entity.HttpEntityWrapper;
+import org.apache.http.nio.ContentEncoder;
+import org.apache.http.nio.IOControl;
+import org.apache.http.nio.entity.ProducingNHttpEntity;
+
+class NHttpEntityWrapper extends HttpEntityWrapper implements ProducingNHttpEntity {
+
+    private final ByteBuffer buffer;
+    private ReadableByteChannel channel;
+
+    public NHttpEntityWrapper(final HttpEntity httpEntity) {
+        super(httpEntity);
+        this.buffer = ByteBuffer.allocate(4096);
+    }
+
+    @Override
+    public InputStream getContent() throws IOException, UnsupportedOperationException {
+        throw new UnsupportedOperationException("Does not support blocking methods");
+    }
+
+    @Override
+    public boolean isStreaming() {
+        return true;
+    }
+
+    @Override
+    public void writeTo(final OutputStream out) throws IOException, UnsupportedOperationException {
+        throw new UnsupportedOperationException("Does not support blocking methods");
+    }
+
+    @Override
+    @Deprecated
+    public void consumeContent() throws IOException {
+        finish();
+    }
+
+    public void produceContent(
+            final ContentEncoder encoder,
+            final IOControl ioctrl) throws IOException {
+        if (this.channel == null) {
+            this.channel = Channels.newChannel(this.wrappedEntity.getContent());
+        }
+        int i = this.channel.read(this.buffer);
+        this.buffer.flip();
+        encoder.write(this.buffer);
+        boolean buffering = this.buffer.hasRemaining();
+        this.buffer.compact();
+        if (i == -1 && !buffering) {
+            encoder.complete();
+            this.channel.close();
+        }
+    }
+
+    public void finish() throws IOException {
+        if (this.channel != null) {
+            this.channel.close();
+            this.channel = null;
+        }
+    }
+
+}
+

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/NHttpEntityWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/NHttpEntityWrapper.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/NHttpEntityWrapper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AbstractHttpAsyncResponseConsumer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AbstractHttpAsyncResponseConsumer.java?rev=1097205&view=auto
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AbstractHttpAsyncResponseConsumer.java (added)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AbstractHttpAsyncResponseConsumer.java Wed Apr 27 19:01:28 2011
@@ -0,0 +1,115 @@
+/*
+ * ====================================================================
+ * 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.nio.client.methods;
+
+import java.io.IOException;
+
+import org.apache.http.HttpException;
+import org.apache.http.HttpResponse;
+import org.apache.http.nio.ContentDecoder;
+import org.apache.http.nio.IOControl;
+import org.apache.http.nio.client.HttpAsyncResponseConsumer;
+
+public abstract class AbstractHttpAsyncResponseConsumer<T> implements HttpAsyncResponseConsumer<T> {
+
+    private volatile HttpResponse response;
+    private volatile Exception ex;
+    private volatile boolean completed;
+    private volatile T result;
+
+    public AbstractHttpAsyncResponseConsumer() {
+        super();
+    }
+
+    protected abstract void onResponseReceived(final HttpResponse response);
+
+    protected abstract void onContentReceived(
+            final ContentDecoder decoder, final IOControl ioctrl) throws IOException;
+
+    protected abstract void onCleanup();
+
+    protected abstract T buildResult() throws Exception;
+
+    void releaseResources() {
+        onCleanup();
+    }
+
+    public synchronized void responseReceived(final HttpResponse response) throws IOException, HttpException {
+        if (this.response != null) {
+            throw new IllegalStateException("HTTP response already set");
+        }
+        this.response = response;
+        onResponseReceived(this.response);
+    }
+
+    public synchronized void consumeContent(
+            final ContentDecoder decoder, final IOControl ioctrl) throws IOException {
+        onContentReceived(decoder, ioctrl);
+    }
+
+    public synchronized void responseCompleted() {
+        if (this.completed) {
+            return;
+        }
+        this.completed = true;
+        try {
+            this.result = buildResult();
+        } catch (Exception ex) {
+            failed(ex);
+        } finally {
+            releaseResources();
+        }
+    }
+
+    public synchronized void cancel() {
+        if (this.completed) {
+            return;
+        }
+        this.completed = true;
+        this.response = null;
+        releaseResources();
+    }
+
+    public synchronized void failed(final Exception ex) {
+        if (this.completed) {
+            return;
+        }
+        this.completed = true;
+        this.ex = ex;
+        this.response = null;
+        releaseResources();
+    }
+
+    public Exception getException() {
+        return this.ex;
+    }
+
+    public T getResult() {
+        return this.result;
+    }
+
+}

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AbstractHttpAsyncResponseConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AbstractHttpAsyncResponseConsumer.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AbstractHttpAsyncResponseConsumer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=1097205&view=auto
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncByteConsumer.java (added)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncByteConsumer.java Wed Apr 27 19:01:28 2011
@@ -0,0 +1,75 @@
+/*
+ * ====================================================================
+ * 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.nio.client.methods;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import org.apache.http.nio.ContentDecoder;
+import org.apache.http.nio.IOControl;
+
+public abstract class AsyncByteConsumer<T> extends AbstractHttpAsyncResponseConsumer<T> {
+
+    private final int bufSize;
+    private ByteBuffer bbuf;
+
+    public AsyncByteConsumer(int bufSize) {
+        super();
+        this.bufSize = bufSize;
+    }
+
+    public AsyncByteConsumer() {
+        this(8 * 1024);
+    }
+
+    protected abstract void onByteReceived(
+            final ByteBuffer buf, final IOControl ioctrl) throws IOException;
+
+    @Override
+    protected void onContentReceived(
+            final ContentDecoder decoder, final IOControl ioctrl) throws IOException {
+        if (this.bbuf == null) {
+            this.bbuf = ByteBuffer.allocate(this.bufSize);
+        }
+        for (;;) {
+            int bytesRead = decoder.read(this.bbuf);
+            if (bytesRead <= 0) {
+                break;
+            }
+            this.bbuf.flip();
+            onByteReceived(this.bbuf, ioctrl);
+            this.bbuf.clear();
+        }
+    }
+
+    @Override
+    void releaseResources() {
+        this.bbuf = null;
+        super.releaseResources();
+    }
+
+}

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncByteConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncByteConsumer.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncByteConsumer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=1097205&view=auto
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java (added)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java Wed Apr 27 19:01:28 2011
@@ -0,0 +1,119 @@
+/*
+ * ====================================================================
+ * 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.nio.client.methods;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+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.nio.ContentDecoder;
+import org.apache.http.nio.IOControl;
+import org.apache.http.protocol.HTTP;
+import org.apache.http.util.EntityUtils;
+
+public abstract class AsyncCharConsumer<T> extends AbstractHttpAsyncResponseConsumer<T> {
+
+    private final int bufSize;
+    private String charsetName;
+    private Charset charset;
+    private CharsetDecoder decoder;
+    private ByteBuffer bbuf;
+    private CharBuffer cbuf;
+
+    public AsyncCharConsumer(int bufSize) {
+        super();
+        this.bufSize = bufSize;
+    }
+
+    public AsyncCharConsumer() {
+        this(8 * 1024);
+    }
+
+    protected abstract void onCharReceived(
+            final CharBuffer buf, final IOControl ioctrl) throws IOException;
+
+    @Override
+    public synchronized void responseReceived(
+            final HttpResponse response) throws IOException, HttpException {
+        HttpEntity entity = response.getEntity();
+        if (entity != null) {
+            this.charsetName = EntityUtils.getContentCharSet(entity);
+        }
+        if (this.charsetName == null) {
+            this.charsetName = HTTP.DEFAULT_CONTENT_CHARSET;
+        }
+        super.responseReceived(response);
+    }
+
+    @Override
+    protected void onContentReceived(
+            final ContentDecoder decoder, final IOControl ioctrl) throws IOException {
+        if (this.charset == null) {
+            try {
+                this.charset = Charset.forName(this.charsetName);
+            } catch (UnsupportedCharsetException ex) {
+                throw new UnsupportedEncodingException(this.charsetName);
+            }
+            this.decoder = this.charset.newDecoder();
+            this.bbuf = ByteBuffer.allocate(this.bufSize);
+            this.cbuf = CharBuffer.allocate(this.bufSize);
+        }
+        for (;;) {
+            int bytesRead = decoder.read(this.bbuf);
+            if (bytesRead <= 0) {
+                break;
+            }
+            this.bbuf.flip();
+            CoderResult result = this.decoder.decode(this.bbuf, this.cbuf, decoder.isCompleted());
+            if (result.isError()) {
+                result.throwException();
+            }
+            this.cbuf.flip();
+            onCharReceived(this.cbuf, ioctrl);
+            this.cbuf.clear();
+            this.bbuf.clear();
+        }
+    }
+
+    @Override
+    void releaseResources() {
+        this.charset = null;
+        this.decoder = null;
+        this.bbuf = null;
+        this.cbuf = null;
+        super.releaseResources();
+    }
+
+}

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncEntityRequestProducer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncEntityRequestProducer.java?rev=1097205&view=auto
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncEntityRequestProducer.java (added)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncEntityRequestProducer.java Wed Apr 27 19:01:28 2011
@@ -0,0 +1,132 @@
+/*
+ * ====================================================================
+ * 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.nio.client.methods;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpEntityEnclosingRequest;
+import org.apache.http.HttpException;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpRequest;
+import org.apache.http.client.utils.URIUtils;
+import org.apache.http.nio.ContentEncoder;
+import org.apache.http.nio.IOControl;
+import org.apache.http.nio.client.HttpAsyncRequestProducer;
+import org.apache.http.nio.entity.NByteArrayEntity;
+import org.apache.http.nio.entity.NFileEntity;
+import org.apache.http.nio.entity.NStringEntity;
+import org.apache.http.nio.entity.ProducingNHttpEntity;
+import org.apache.http.protocol.HTTP;
+
+abstract class BaseHttpAsyncEntityRequestProducer implements HttpAsyncRequestProducer, Closeable {
+
+    private final URI requestURI;
+    private final ProducingNHttpEntity producer;
+
+    protected BaseHttpAsyncEntityRequestProducer(
+            final URI requestURI, final String content, String mimeType, String charset) {
+        super();
+        if (requestURI == null) {
+            throw new IllegalArgumentException("Request URI may not be null");
+        }
+        if (mimeType == null) {
+            mimeType = HTTP.PLAIN_TEXT_TYPE;
+        }
+        if (charset == null) {
+            charset = HTTP.DEFAULT_CONTENT_CHARSET;
+        }
+        this.requestURI = requestURI;
+        try {
+            NStringEntity entity = new NStringEntity(content, charset);
+            entity.setContentType(mimeType + HTTP.CHARSET_PARAM + charset);
+            this.producer = entity;
+        } catch (UnsupportedEncodingException ex) {
+            throw new IllegalArgumentException("Unsupported charset: " + charset);
+        }
+    }
+
+    protected BaseHttpAsyncEntityRequestProducer(
+            final URI requestURI, final byte[] content, final String contentType) {
+        super();
+        if (requestURI == null) {
+            throw new IllegalArgumentException("Request URI may not be null");
+        }
+        this.requestURI = requestURI;
+        NByteArrayEntity entity = new NByteArrayEntity(content);
+        entity.setContentType(contentType);
+        this.producer = entity;
+    }
+
+    protected BaseHttpAsyncEntityRequestProducer(
+            final URI requestURI, final File content, final String contentType) {
+        super();
+        if (requestURI == null) {
+            throw new IllegalArgumentException("Request URI may not be null");
+        }
+        this.requestURI = requestURI;
+        this.producer = new NFileEntity(content, contentType);
+    }
+
+    protected abstract HttpEntityEnclosingRequest createRequest(final URI requestURI, final HttpEntity entity);
+
+    public HttpRequest generateRequest() throws IOException, HttpException {
+        return createRequest(this.requestURI, this.producer);
+    }
+
+    public synchronized HttpHost getTarget() {
+        return URIUtils.extractHost(this.requestURI);
+    }
+
+    public synchronized void produceContent(
+            final ContentEncoder encoder, final IOControl ioctrl) throws IOException {
+        this.producer.produceContent(encoder, ioctrl);
+        if (encoder.isCompleted()) {
+            this.producer.finish();
+        }
+    }
+
+    public synchronized boolean isRepeatable() {
+        return this.producer.isRepeatable();
+    }
+
+    public synchronized void resetRequest() {
+        try {
+            this.producer.finish();
+        } catch (IOException ignore) {
+        }
+    }
+
+    public synchronized void close() throws IOException {
+        this.producer.finish();
+    }
+
+}

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncEntityRequestProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncEntityRequestProducer.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncEntityRequestProducer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncRequestProducer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncRequestProducer.java?rev=1097205&view=auto
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncRequestProducer.java (added)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncRequestProducer.java Wed Apr 27 19:01:28 2011
@@ -0,0 +1,73 @@
+/*
+ * ====================================================================
+ * 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.nio.client.methods;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.apache.http.HttpException;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpRequest;
+import org.apache.http.client.utils.URIUtils;
+import org.apache.http.nio.ContentEncoder;
+import org.apache.http.nio.IOControl;
+import org.apache.http.nio.client.HttpAsyncRequestProducer;
+
+abstract class BaseHttpAsyncRequestProducer implements HttpAsyncRequestProducer {
+
+    private final URI requestURI;
+
+    public BaseHttpAsyncRequestProducer(final URI requestURI) {
+        super();
+        if (requestURI == null) {
+            throw new IllegalArgumentException("Request URI may not be null");
+        }
+        this.requestURI = requestURI;
+    }
+
+    protected abstract HttpRequest createRequest(final URI requestURI);
+
+    public HttpRequest generateRequest() throws IOException, HttpException {
+        return createRequest(this.requestURI);
+    }
+
+    public HttpHost getTarget() {
+        return URIUtils.extractHost(this.requestURI);
+    }
+
+    public void produceContent(
+            final ContentEncoder encoder, final IOControl ioctrl) throws IOException {
+    }
+
+    public boolean isRepeatable() {
+        return true;
+    }
+
+    public void resetRequest() {
+    }
+
+}

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncRequestProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncRequestProducer.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncRequestProducer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncDelete.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncDelete.java?rev=1097205&view=auto
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncDelete.java (added)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncDelete.java Wed Apr 27 19:01:28 2011
@@ -0,0 +1,49 @@
+/*
+ * ====================================================================
+ * 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.nio.client.methods;
+
+import java.net.URI;
+
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpUriRequest;
+
+public class HttpAsyncDelete extends BaseHttpAsyncRequestProducer {
+
+    public HttpAsyncDelete(final URI requestURI) {
+        super(requestURI);
+    }
+
+    public HttpAsyncDelete(final String requestURI) {
+        super(URI.create(requestURI));
+    }
+
+    @Override
+    protected HttpUriRequest createRequest(final URI requestURI) {
+        return new HttpDelete(requestURI);
+    }
+
+}

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncDelete.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncDelete.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncDelete.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncGet.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncGet.java?rev=1097205&view=auto
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncGet.java (added)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncGet.java Wed Apr 27 19:01:28 2011
@@ -0,0 +1,49 @@
+/*
+ * ====================================================================
+ * 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.nio.client.methods;
+
+import java.net.URI;
+
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpUriRequest;
+
+public class HttpAsyncGet extends BaseHttpAsyncRequestProducer {
+
+    public HttpAsyncGet(final URI requestURI) {
+        super(requestURI);
+    }
+
+    public HttpAsyncGet(final String requestURI) {
+        super(URI.create(requestURI));
+    }
+
+    @Override
+    protected HttpUriRequest createRequest(final URI requestURI) {
+        return new HttpGet(requestURI);
+    }
+
+}

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncGet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncGet.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncGet.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncHead.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncHead.java?rev=1097205&view=auto
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncHead.java (added)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncHead.java Wed Apr 27 19:01:28 2011
@@ -0,0 +1,49 @@
+/*
+ * ====================================================================
+ * 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.nio.client.methods;
+
+import java.net.URI;
+
+import org.apache.http.client.methods.HttpHead;
+import org.apache.http.client.methods.HttpUriRequest;
+
+public class HttpAsyncHead extends BaseHttpAsyncRequestProducer {
+
+    public HttpAsyncHead(final URI requestURI) {
+        super(requestURI);
+    }
+
+    public HttpAsyncHead(final String requestURI) {
+        super(URI.create(requestURI));
+    }
+
+   @Override
+    protected HttpUriRequest createRequest(final URI requestURI) {
+        return new HttpHead(requestURI);
+    }
+
+}

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncHead.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncHead.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncHead.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncOptions.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncOptions.java?rev=1097205&view=auto
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncOptions.java (added)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncOptions.java Wed Apr 27 19:01:28 2011
@@ -0,0 +1,49 @@
+/*
+ * ====================================================================
+ * 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.nio.client.methods;
+
+import java.net.URI;
+
+import org.apache.http.client.methods.HttpOptions;
+import org.apache.http.client.methods.HttpUriRequest;
+
+public class HttpAsyncOptions extends BaseHttpAsyncRequestProducer {
+
+    public HttpAsyncOptions(final URI requestURI) {
+        super(requestURI);
+    }
+
+    public HttpAsyncOptions(final String requestURI) {
+        super(URI.create(requestURI));
+    }
+
+    @Override
+    protected HttpUriRequest createRequest(final URI requestURI) {
+        return new HttpOptions(requestURI);
+    }
+
+}

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncOptions.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncOptions.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncOptions.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncPost.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncPost.java?rev=1097205&view=auto
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncPost.java (added)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncPost.java Wed Apr 27 19:01:28 2011
@@ -0,0 +1,77 @@
+/*
+ * ====================================================================
+ * 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.nio.client.methods;
+
+import java.io.File;
+import java.net.URI;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpEntityEnclosingRequest;
+import org.apache.http.client.methods.HttpPost;
+
+public class HttpAsyncPost extends BaseHttpAsyncEntityRequestProducer {
+
+    public HttpAsyncPost(final URI requestURI, final byte[] content, final String contentType) {
+        super(requestURI, content, contentType);
+    }
+
+    public HttpAsyncPost(final URI requestURI, final File content, final String contentType) {
+        super(requestURI, content, contentType);
+    }
+
+    public HttpAsyncPost(final URI requestURI, final String content, String mimeType, String charset) {
+        super(requestURI, content, mimeType, charset);
+    }
+
+    public HttpAsyncPost(final URI requestURI, final String content) {
+        super(requestURI, content, null, null);
+    }
+
+    public HttpAsyncPost(final String requestURI, final byte[] content, final String contentType) {
+        super(URI.create(requestURI), content, contentType);
+    }
+
+    public HttpAsyncPost(final String requestURI, final File content, final String contentType) {
+        super(URI.create(requestURI), content, contentType);
+    }
+
+    public HttpAsyncPost(final String requestURI, final String content, String mimeType, String charset) {
+        super(URI.create(requestURI), content, mimeType, charset);
+    }
+
+    public HttpAsyncPost(final String requestURI, final String content) {
+        super(URI.create(requestURI), content, null, null);
+    }
+
+    @Override
+    protected HttpEntityEnclosingRequest createRequest(final URI requestURI, final HttpEntity entity) {
+        HttpPost httppost = new HttpPost(requestURI);
+        httppost.setEntity(entity);
+        return httppost;
+    }
+
+}

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncPost.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncPost.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncPost.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncPut.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncPut.java?rev=1097205&view=auto
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncPut.java (added)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncPut.java Wed Apr 27 19:01:28 2011
@@ -0,0 +1,77 @@
+/*
+ * ====================================================================
+ * 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.nio.client.methods;
+
+import java.io.File;
+import java.net.URI;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpEntityEnclosingRequest;
+import org.apache.http.client.methods.HttpPut;
+
+public class HttpAsyncPut extends BaseHttpAsyncEntityRequestProducer {
+
+    public HttpAsyncPut(final URI requestURI, final byte[] content, final String contentType) {
+        super(requestURI, content, contentType);
+    }
+
+    public HttpAsyncPut(final URI requestURI, final File content, final String contentType) {
+        super(requestURI, content, contentType);
+    }
+
+    public HttpAsyncPut(final URI requestURI, final String content, String mimeType, String charset) {
+        super(requestURI, content, mimeType, charset);
+    }
+
+    public HttpAsyncPut(final URI requestURI, final String content) {
+        super(requestURI, content, null, null);
+    }
+
+    public HttpAsyncPut(final String requestURI, final byte[] content, final String contentType) {
+        super(URI.create(requestURI), content, contentType);
+    }
+
+    public HttpAsyncPut(final String requestURI, final File content, final String contentType) {
+        super(URI.create(requestURI), content, contentType);
+    }
+
+    public HttpAsyncPut(final String requestURI, final String content, String mimeType, String charset) {
+        super(URI.create(requestURI), content, mimeType, charset);
+    }
+
+    public HttpAsyncPut(final String requestURI, final String content) {
+        super(URI.create(requestURI), content, null, null);
+    }
+
+    @Override
+    protected HttpEntityEnclosingRequest createRequest(final URI requestURI, final HttpEntity entity) {
+        HttpPut httpput = new HttpPut(requestURI);
+        httpput.setEntity(entity);
+        return httpput;
+    }
+
+}

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncPut.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncPut.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncPut.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncTrace.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncTrace.java?rev=1097205&view=auto
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncTrace.java (added)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncTrace.java Wed Apr 27 19:01:28 2011
@@ -0,0 +1,49 @@
+/*
+ * ====================================================================
+ * 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.nio.client.methods;
+
+import java.net.URI;
+
+import org.apache.http.client.methods.HttpTrace;
+import org.apache.http.client.methods.HttpUriRequest;
+
+public class HttpAsyncTrace extends BaseHttpAsyncRequestProducer {
+
+    public HttpAsyncTrace(final URI requestURI) {
+        super(requestURI);
+    }
+
+    public HttpAsyncTrace(final String requestURI) {
+        super(URI.create(requestURI));
+    }
+
+    @Override
+    protected HttpUriRequest createRequest(final URI requestURI) {
+        return new HttpTrace(requestURI);
+    }
+
+}

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncTrace.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncTrace.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncTrace.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=1097205&view=auto
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java (added)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java Wed Apr 27 19:01:28 2011
@@ -0,0 +1,207 @@
+/*
+ * ====================================================================
+ * 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.nio.client.methods;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.http.HttpHost;
+import org.apache.http.HttpResponse;
+import org.apache.http.impl.nio.client.DefaultHttpAsyncClient;
+import org.apache.http.impl.nio.conn.PoolingClientConnectionManager;
+import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor;
+import org.apache.http.localserver.ServerTestBase;
+import org.apache.http.nio.IOControl;
+import org.apache.http.nio.client.HttpAsyncClient;
+import org.apache.http.nio.conn.scheme.Scheme;
+import org.apache.http.nio.conn.scheme.SchemeRegistry;
+import org.apache.http.nio.reactor.ConnectingIOReactor;
+import org.apache.http.params.BasicHttpParams;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestAsyncConsumers extends ServerTestBase {
+
+    private HttpHost target;
+    private PoolingClientConnectionManager sessionManager;
+    private HttpAsyncClient httpclient;
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        this.localServer.registerDefaultHandlers();
+        int port = this.localServer.getServiceAddress().getPort();
+        this.target = new HttpHost("localhost", port);
+
+        ConnectingIOReactor ioReactor = new DefaultConnectingIOReactor(2, new BasicHttpParams());
+        SchemeRegistry schemeRegistry = new SchemeRegistry();
+        schemeRegistry.register(new Scheme("http", 80, null));
+        this.sessionManager = new PoolingClientConnectionManager(ioReactor, schemeRegistry);
+        this.httpclient = new DefaultHttpAsyncClient(this.sessionManager);
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        this.httpclient.shutdown();
+        super.tearDown();
+    }
+
+    static class ByteCountingConsumer extends AsyncByteConsumer<Long> {
+
+        public ByteCountingConsumer() {
+            super();
+        }
+
+        public ByteCountingConsumer(int bufSize) {
+            super(bufSize);
+        }
+
+        private AtomicLong count = new AtomicLong(0);
+
+        @Override
+        protected void onResponseReceived(final HttpResponse response) {
+        }
+
+        @Override
+        protected void onByteReceived(final ByteBuffer buf, final IOControl ioctrl) throws IOException {
+            this.count.addAndGet(buf.remaining());
+        }
+
+        @Override
+        protected void onCleanup() {
+        }
+
+        @Override
+        protected Long buildResult() throws Exception {
+            return count.get();
+        }
+
+    }
+
+    @Test
+    public void testByteConsumer() throws Exception {
+        this.httpclient.start();
+        for (int i = 0; i < 5; i++) {
+            HttpAsyncGet httpget = new HttpAsyncGet(this.target.toURI() + "/random/20480");
+            AsyncByteConsumer<Long> consumer = new ByteCountingConsumer();
+            Future<Long> future = this.httpclient.execute(httpget, consumer, null);
+            Long count = future.get();
+            Assert.assertEquals(20480, count.longValue());
+        }
+    }
+
+    @Test
+    public void testByteConsumerSmallBufffer() throws Exception {
+        this.httpclient.start();
+        for (int i = 0; i < 5; i++) {
+            HttpAsyncGet httpget = new HttpAsyncGet(this.target.toURI() + "/random/20480");
+            AsyncByteConsumer<Long> consumer = new ByteCountingConsumer(512);
+            Future<Long> future = this.httpclient.execute(httpget, consumer, null);
+            Long count = future.get();
+            Assert.assertEquals(20480, count.longValue());
+        }
+    }
+
+    static class BufferingCharConsumer extends AsyncCharConsumer<String> {
+
+        public BufferingCharConsumer() {
+            super();
+        }
+
+        public BufferingCharConsumer(int bufSize) {
+            super(bufSize);
+        }
+
+        private StringBuilder sb = new StringBuilder();
+
+        @Override
+        protected void onResponseReceived(final HttpResponse response) {
+        }
+
+        @Override
+        protected void onCharReceived(final CharBuffer buf, final IOControl ioctrl) throws IOException {
+            while (buf.hasRemaining()) {
+                this.sb.append(buf.get());
+            }
+        }
+
+        @Override
+        protected void onCleanup() {
+            this.sb.setLength(0);
+        }
+
+        @Override
+        protected String buildResult() throws Exception {
+            return this.sb.toString();
+        }
+
+    }
+
+    @Test
+    public void testCharConsumer() throws Exception {
+        StringBuilder sb = new StringBuilder();
+        for (int i= 0; i < 25; i++) {
+            sb.append("blah blah blah blah\r\n");
+            sb.append("yada yada yada yada\r\n");
+        }
+        String s = sb.toString();
+
+        this.httpclient.start();
+        for (int i = 0; i < 5; i++) {
+            HttpAsyncPost httppost = new HttpAsyncPost(this.target.toURI() + "/echo/stuff", s);
+            AsyncCharConsumer<String> consumer = new BufferingCharConsumer();
+            Future<String> future = this.httpclient.execute(httppost, consumer, null);
+            String result = future.get();
+            Assert.assertEquals(s, result);
+        }
+    }
+
+    @Test
+    public void testCharConsumerSmallBufffer() throws Exception {
+        StringBuilder sb = new StringBuilder();
+        for (int i= 0; i < 25; i++) {
+            sb.append("blah blah blah blah\r\n");
+            sb.append("yada yada yada yada\r\n");
+        }
+        String s = sb.toString();
+
+        this.httpclient.start();
+        for (int i = 0; i < 5; i++) {
+            HttpAsyncPost httppost = new HttpAsyncPost(this.target.toURI() + "/echo/stuff", s);
+            AsyncCharConsumer<String> consumer = new BufferingCharConsumer(512);
+            Future<String> future = this.httpclient.execute(httppost, consumer, null);
+            String result = future.get();
+            Assert.assertEquals(s, result);
+        }
+    }
+
+}

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message