hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1758104 - in /httpcomponents/httpasyncclient/trunk/httpasyncclient/src: main/java/org/apache/http/nio/client/methods/HttpAsyncMethods.java test/java/org/apache/http/nio/client/integration/TestHttpAsync.java
Date Sun, 28 Aug 2016 12:38:50 GMT
Author: olegk
Date: Sun Aug 28 12:38:50 2016
New Revision: 1758104

URL: http://svn.apache.org/viewvc?rev=1758104&view=rev
Log:
fix HttpAsyncMethods.createPost/createPut(URI,byte[],ContentType): set entity to request
Contributed by Dmitry Potapov <dpotapov at yandex-team.ru>

Modified:
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncMethods.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsync.java

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=1758104&r1=1758103&r2=1758104&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
Sun Aug 28 12:38:50 2016
@@ -233,6 +233,7 @@ public final class HttpAsyncMethods {
             final ContentType contentType) {
         final HttpPost httppost = new HttpPost(requestURI);
         final NByteArrayEntity entity = new NByteArrayEntity(content, contentType);
+        httppost.setEntity(entity);
         final HttpHost target = URIUtils.extractHost(requestURI);
         return new RequestProducerImpl(target, httppost, entity);
     }
@@ -300,6 +301,7 @@ public final class HttpAsyncMethods {
             final ContentType contentType) {
         final HttpPut httpput = new HttpPut(requestURI);
         final NByteArrayEntity entity = new NByteArrayEntity(content, contentType);
+        httpput.setEntity(entity);
         final HttpHost target = URIUtils.extractHost(requestURI);
         return new RequestProducerImpl(target, httpput, entity);
     }

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsync.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsync.java?rev=1758104&r1=1758103&r2=1758104&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsync.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsync.java
Sun Aug 28 12:38:50 2016
@@ -113,6 +113,26 @@ public class TestHttpAsync extends HttpA
     }
 
     @Test
+    public void testHttpAsyncMethods() throws Exception {
+        final HttpHost target = start();
+        final byte[] b1 = new byte[1024];
+        final Random rnd = new Random(System.currentTimeMillis());
+        rnd.nextBytes(b1);
+
+        final Future<HttpResponse> future = this.httpclient.execute(
+            HttpAsyncMethods.createPost(target + "/echo/post", b1, null),
+            new BasicAsyncResponseConsumer(),
+            null);
+        final HttpResponse response = future.get();
+        Assert.assertNotNull(response);
+        Assert.assertEquals(200, response.getStatusLine().getStatusCode());
+        final HttpEntity entity = response.getEntity();
+        Assert.assertNotNull(entity);
+        final byte[] b2 = EntityUtils.toByteArray(entity);
+        Assert.assertArrayEquals(b1, b2);
+    }
+
+    @Test
     public void testMultiplePostsOverMultipleConnections() throws Exception {
         final HttpHost target = start();
         final byte[] b1 = new byte[1024];



Mime
View raw message