hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1714136 - in /httpcomponents/httpclient/trunk: RELEASE_NOTES.txt fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java fluent-hc/src/test/java/org/apache/http/client/fluent/TestFluent.java
Date Thu, 12 Nov 2015 23:10:58 GMT
Author: ggregory
Date: Thu Nov 12 23:10:58 2015
New Revision: 1714136

URL: http://svn.apache.org/viewvc?rev=1714136&view=rev
Log:
[HTTPCLIENT-1696]: Add convenience methods to fluent API class Request.
Contributed by Gary Gregory <ggregory @ apache.org>

Modified:
    httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
    httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java
    httpcomponents/httpclient/trunk/fluent-hc/src/test/java/org/apache/http/client/fluent/TestFluent.java

Modified: httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/RELEASE_NOTES.txt?rev=1714136&r1=1714135&r2=1714136&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpclient/trunk/RELEASE_NOTES.txt Thu Nov 12 23:10:58 2015
@@ -1,3 +1,10 @@
+Release 5.0
+-------------------
+
+* [HTTPCLIENT-1696]: Add convenience methods to fluent API class Request.
+  Contributed by Gary Gregory <ggregory @ apache.org>
+
+
 Release 4.5
 -------------------
 
@@ -32,7 +39,6 @@ Changelog:
   Contributed by Michael Osipov <michaelo at apache.org>
 
 
-
 Release 4.4.1
 -------------------
 

Modified: httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java?rev=1714136&r1=1714135&r2=1714136&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java
(original)
+++ httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java
Thu Nov 12 23:10:58 2015
@@ -78,6 +78,14 @@ public class Request {
 
     private SimpleDateFormat dateFormatter;
 
+    public static Request create(final String methodName, final String uri) {
+        return new Request(new InternalHttpRequest(methodName, URI.create(uri)));
+    }
+
+    public static Request create(final String methodName, final URI uri) {
+        return new Request(new InternalHttpRequest(methodName, uri));
+    }
+
     public static Request Get(final URI uri) {
         return new Request(new InternalHttpRequest(HttpGet.METHOD_NAME, uri));
     }

Modified: httpcomponents/httpclient/trunk/fluent-hc/src/test/java/org/apache/http/client/fluent/TestFluent.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/fluent-hc/src/test/java/org/apache/http/client/fluent/TestFluent.java?rev=1714136&r1=1714135&r2=1714136&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/fluent-hc/src/test/java/org/apache/http/client/fluent/TestFluent.java
(original)
+++ httpcomponents/httpclient/trunk/fluent-hc/src/test/java/org/apache/http/client/fluent/TestFluent.java
Thu Nov 12 23:10:58 2015
@@ -28,6 +28,7 @@ package org.apache.http.client.fluent;
 
 import java.io.File;
 import java.io.IOException;
+import java.net.URI;
 import java.nio.charset.Charset;
 
 import org.apache.http.HttpEntity;
@@ -106,6 +107,22 @@ public class TestFluent extends LocalSer
         Assert.assertEquals("All is well", message);
     }
 
+    @Test
+    public void testGetRequestByName() throws Exception {
+        final HttpHost target = start();
+        final String baseURL = "http://localhost:" + target.getPort();
+        final String message = Request.create("GET", baseURL + "/").execute().returnContent().asString();
+        Assert.assertEquals("All is well", message);
+    }
+
+    @Test
+    public void testGetRequestByNameWithURI() throws Exception {
+        final HttpHost target = start();
+        final String baseURL = "http://localhost:" + target.getPort();
+        final String message = Request.create("GET", new URI(baseURL + "/")).execute().returnContent().asString();
+        Assert.assertEquals("All is well", message);
+    }
+
     @Test(expected = ClientProtocolException.class)
     public void testGetRequestFailure() throws Exception {
         final HttpHost target = start();



Mime
View raw message