[prev in list] [next in list] [prev in thread] [next in thread] 

List:       httpcomponents-commits
Subject:    [httpcomponents-client] branch master updated: No need to use the type name of an input arg in the m
From:       ggregory () apache ! org
Date:       2020-01-30 0:20:12
Message-ID: 158034361212.18418.7226939112958570341 () gitbox ! apache ! org
[Download RAW message or body]

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git


The following commit(s) were added to refs/heads/master by this push:
     new d1c4199  No need to use the type name of an input arg in the method name. \
(#208) d1c4199 is described below

commit d1c4199db3996fceddc7eb4262c61daa1331440e
Author: Gary Gregory <garydgregory@users.noreply.github.com>
AuthorDate: Wed Jan 29 19:20:05 2020 -0500

    No need to use the type name of an input arg in the method name. (#208)
    
    * No need to use the type name of an input arg in the method name.
    
    * Do not use input type names in method names.
---
 RELEASE_NOTES.txt                                    |  7 +++++++
 .../http/impl/cache/CachedHttpResponseGenerator.java |  2 +-
 .../async/AbstractSimpleServerExchangeHandler.java   |  2 +-
 .../async/AbstractHttpAsyncClientAuthentication.java |  6 +++---
 .../async/AbstractHttpAsyncRedirectsTest.java        | 12 ++++++------
 .../testing/async/TestHttp1AsyncRedirects.java       |  2 +-
 .../async/TestHttp1AsyncStatefulConnManagement.java  |  4 ++--
 .../http/async/methods/SimpleHttpRequest.java        | 16 ++++++++++++++++
 .../http/async/methods/SimpleHttpResponse.java       | 20 ++++++++++++++++++--
 .../http/async/methods/SimpleResponseConsumer.java   |  2 +-
 10 files changed, 56 insertions(+), 17 deletions(-)

diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index ceecf89..f4c68ad 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -15,6 +15,13 @@
   SimpleHttpRequests.create(String, String)
   Contributed by Gary Gregory <ggregory at apache.org>
 
+* GitHub #208: Do not use input type names in method names: 
+  SimpleHttpRequest: Deprecate setBodyBytes(byte[], ContentType) in favor of \
setBody(byte[], ContentType) +  SimpleHttpRequest: Deprecate setBodyText(String, \
ContentType) in favor of setBody(String, ContentType) +  SimpleHttpResponse: \
Deprecate setBodyBytes(byte[], ContentType) in favor of setBody(byte[], ContentType) \
+  SimpleHttpResponse: Deprecate setBodyText(String, ContentType) in favor of \
setBody(String, ContentType) +  Contributed by Gary Gregory <ggregory at apache.org>
+
 
 Release 5.0-BETA7
 -----------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachedHttpResponseGenerator.java \
b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachedHttpResponseGenerator.java
 index 614ed0e..455c0ef 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachedHttpResponseGenerator.java
                
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachedHttpResponseGenerator.java
 @@ -76,7 +76,7 @@ class CachedHttpResponseGenerator {
             final ContentType contentType = h != null ? \
ContentType.parse(h.getValue()) : null;  final byte[] content = resource.get();
             addMissingContentLengthHeader(response, content);
-            response.setBodyBytes(content, contentType);
+            response.setBody(content, contentType);
         }
 
         final TimeValue age = this.validityStrategy.getCurrentAge(entry, now);
diff --git a/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/async/AbstractSimpleServerExchangeHandler.java \
b/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/async/AbstractSimpleServerExchangeHandler.java
 index 24635ac..e3e2881 100644
--- a/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/async/AbstractSimpleServerExchangeHandler.java
                
+++ b/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/async/AbstractSimpleServerExchangeHandler.java
 @@ -65,7 +65,7 @@ public abstract class AbstractSimpleServerExchangeHandler extends \
AbstractServer  final ContentType contentType) {
                 final SimpleHttpRequest simpleRequest = \
SimpleHttpRequest.copy(request);  if (body != null) {
-                    simpleRequest.setBodyBytes(body, contentType);
+                    simpleRequest.setBody(body, contentType);
                 }
                 return simpleRequest;
             }
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthentication.java \
b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthentication.java
 index 872481b..20f6af2 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthentication.java
                
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthentication.java
 @@ -246,7 +246,7 @@ public abstract class AbstractHttpAsyncClientAuthentication<T \
extends CloseableH  context.setCredentialsProvider(credsProvider);
 
         final SimpleHttpRequest put = SimpleHttpRequests.put(target, "/");
-        put.setBodyText("Some important stuff", ContentType.TEXT_PLAIN);
+        put.setBody("Some important stuff", ContentType.TEXT_PLAIN);
         final Future<SimpleHttpResponse> future = httpclient.execute(put, context, \
null);  final HttpResponse response = future.get();
 
@@ -276,7 +276,7 @@ public abstract class AbstractHttpAsyncClientAuthentication<T \
                extends CloseableH
         context.setRequestConfig(RequestConfig.custom().setExpectContinueEnabled(true).build());
  
         final SimpleHttpRequest put = SimpleHttpRequests.put(target, "/");
-        put.setBodyText("Some important stuff", ContentType.TEXT_PLAIN);
+        put.setBody("Some important stuff", ContentType.TEXT_PLAIN);
         final Future<SimpleHttpResponse> future = httpclient.execute(put, context, \
null);  final HttpResponse response = future.get();
 
@@ -303,7 +303,7 @@ public abstract class AbstractHttpAsyncClientAuthentication<T \
                extends CloseableH
         context.setRequestConfig(RequestConfig.custom().setExpectContinueEnabled(true).build());
  
         final SimpleHttpRequest put = SimpleHttpRequests.put(target, "/");
-        put.setBodyText("Some important stuff", ContentType.TEXT_PLAIN);
+        put.setBody("Some important stuff", ContentType.TEXT_PLAIN);
         final Future<SimpleHttpResponse> future = httpclient.execute(put, context, \
null);  final HttpResponse response = future.get();
 
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncRedirectsTest.java \
b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncRedirectsTest.java
 index 1a11fb4..e92af3a 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncRedirectsTest.java
                
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncRedirectsTest.java
 @@ -110,7 +110,7 @@ public abstract class AbstractHttpAsyncRedirectsTest <T extends \
CloseableHttpAsy  return response;
                 } else if (path.equals("/newlocation/")) {
                     final SimpleHttpResponse response = new \
                SimpleHttpResponse(HttpStatus.SC_OK);
-                    response.setBodyText("Successful redirect", \
ContentType.TEXT_PLAIN); +                    response.setBody("Successful redirect", \
ContentType.TEXT_PLAIN);  return response;
                 } else {
                     return new SimpleHttpResponse(HttpStatus.SC_NOT_FOUND);
@@ -166,7 +166,7 @@ public abstract class AbstractHttpAsyncRedirectsTest <T extends \
CloseableHttpAsy  return response;
                 } else if (path.equals("/relativelocation/")) {
                     final SimpleHttpResponse response = new \
                SimpleHttpResponse(HttpStatus.SC_OK);
-                    response.setBodyText("Successful redirect", \
ContentType.TEXT_PLAIN); +                    response.setBody("Successful redirect", \
ContentType.TEXT_PLAIN);  return response;
                 } else {
                     return new SimpleHttpResponse(HttpStatus.SC_NOT_FOUND);
@@ -191,7 +191,7 @@ public abstract class AbstractHttpAsyncRedirectsTest <T extends \
CloseableHttpAsy  return response;
                 } else if (path.equals("/test/relativelocation")) {
                     final SimpleHttpResponse response = new \
                SimpleHttpResponse(HttpStatus.SC_OK);
-                    response.setBodyText("Successful redirect", \
ContentType.TEXT_PLAIN); +                    response.setBody("Successful redirect", \
ContentType.TEXT_PLAIN);  return response;
                 } else {
                     return new SimpleHttpResponse(HttpStatus.SC_NOT_FOUND);
@@ -468,7 +468,7 @@ public abstract class AbstractHttpAsyncRedirectsTest <T extends \
CloseableHttpAsy  final HttpClientContext context = HttpClientContext.create();
 
         final SimpleHttpRequest post = SimpleHttpRequests.post(target, \
                "/oldlocation/");
-        post.setBodyText("stuff", ContentType.TEXT_PLAIN);
+        post.setBody("stuff", ContentType.TEXT_PLAIN);
         final Future<SimpleHttpResponse> future = httpclient.execute(post, context, \
null);  final HttpResponse response = future.get();
         Assert.assertNotNull(response);
@@ -553,7 +553,7 @@ public abstract class AbstractHttpAsyncRedirectsTest <T extends \
CloseableHttpAsy  return response;
                 } else if (path.equals("/relativelocation/")) {
                     final SimpleHttpResponse response = new \
                SimpleHttpResponse(HttpStatus.SC_OK);
-                    response.setBodyText("Successful redirect", \
ContentType.TEXT_PLAIN); +                    response.setBody("Successful redirect", \
ContentType.TEXT_PLAIN);  return response;
                 } else {
                     return new SimpleHttpResponse(HttpStatus.SC_NOT_FOUND);
@@ -734,7 +734,7 @@ public abstract class AbstractHttpAsyncRedirectsTest <T extends \
CloseableHttpAsy  final String path = requestURI.getPath();
                 if (path.equals("/rome")) {
                     final SimpleHttpResponse response = new \
                SimpleHttpResponse(HttpStatus.SC_OK);
-                    response.setBodyText("Successful redirect", \
ContentType.TEXT_PLAIN); +                    response.setBody("Successful redirect", \
ContentType.TEXT_PLAIN);  return response;
                 } else {
                     final SimpleHttpResponse response = new \
                SimpleHttpResponse(HttpStatus.SC_MOVED_TEMPORARILY);
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncRedirects.java \
b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncRedirects.java
 index 2992c45..0e22390 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncRedirects.java
                
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncRedirects.java
 @@ -152,7 +152,7 @@ public class TestHttp1AsyncRedirects extends \
AbstractHttpAsyncRedirectsTest<Clos  return response;
                 } else if (path.equals("/newlocation/")) {
                     final SimpleHttpResponse response = new \
                SimpleHttpResponse(HttpStatus.SC_OK);
-                    response.setBodyText("Successful redirect", \
ContentType.TEXT_PLAIN); +                    response.setBody("Successful redirect", \
ContentType.TEXT_PLAIN);  return response;
                 } else {
                     return new SimpleHttpResponse(HttpStatus.SC_NOT_FOUND);
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncStatefulConnManagement.java \
b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncStatefulConnManagement.java
 index 83eb582..da771d3 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncStatefulConnManagement.java
                
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncStatefulConnManagement.java
 @@ -121,7 +121,7 @@ public class TestHttp1AsyncStatefulConnManagement extends \
AbstractIntegrationTes  final SimpleHttpRequest request,
                             final HttpCoreContext context) throws HttpException {
                         final SimpleHttpResponse response = new \
                SimpleHttpResponse(HttpStatus.SC_OK);
-                        response.setBodyText("Whatever", ContentType.TEXT_PLAIN);
+                        response.setBody("Whatever", ContentType.TEXT_PLAIN);
                         return response;
                     }
                 };
@@ -246,7 +246,7 @@ public class TestHttp1AsyncStatefulConnManagement extends \
AbstractIntegrationTes  final SimpleHttpRequest request,
                             final HttpCoreContext context) throws HttpException {
                         final SimpleHttpResponse response = new \
                SimpleHttpResponse(HttpStatus.SC_OK);
-                        response.setBodyText("Whatever", ContentType.TEXT_PLAIN);
+                        response.setBody("Whatever", ContentType.TEXT_PLAIN);
                         return response;
                     }
                 };
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequest.java \
b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequest.java
 index aad4a85..d675169 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequest.java
                
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequest.java
 @@ -85,10 +85,26 @@ public final class SimpleHttpRequest extends \
ConfigurableHttpRequest {  this.body = body;
     }
 
+    public void setBody(final byte[] bodyBytes, final ContentType contentType) {
+        this.body = SimpleBody.create(bodyBytes, contentType);
+    }
+
+    public void setBody(final String bodyText, final ContentType contentType) {
+        this.body = SimpleBody.create(bodyText, contentType);
+    }
+
+    /**
+     * @deprecated Use {@link #setBody(byte[], ContentType)}.
+     */
+    @Deprecated
     public void setBodyBytes(final byte[] bodyBytes, final ContentType contentType) \
{  this.body = SimpleBody.create(bodyBytes, contentType);
     }
 
+    /**
+     * @deprecated Use {@link #setBody(String, ContentType)}.
+     */
+    @Deprecated
     public void setBodyText(final String bodyText, final ContentType contentType) {
         this.body = SimpleBody.create(bodyText, contentType);
     }
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpResponse.java \
b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpResponse.java
 index e323a2a..793507f 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpResponse.java
                
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpResponse.java
 @@ -72,7 +72,7 @@ public final class SimpleHttpResponse extends BasicHttpResponse {
     public static SimpleHttpResponse create(final int code, final String content, \
final ContentType contentType) {  final SimpleHttpResponse response = new \
SimpleHttpResponse(code);  if (content != null) {
-            response.setBodyText(content, contentType);
+            response.setBody(content, contentType);
         }
         return response;
     }
@@ -84,7 +84,7 @@ public final class SimpleHttpResponse extends BasicHttpResponse {
     public static SimpleHttpResponse create(final int code, final byte[] content, \
final ContentType contentType) {  final SimpleHttpResponse response = new \
SimpleHttpResponse(code);  if (content != null) {
-            response.setBodyBytes(content, contentType);
+            response.setBody(content, contentType);
         }
         return response;
     }
@@ -97,10 +97,26 @@ public final class SimpleHttpResponse extends BasicHttpResponse {
         this.body = body;
     }
 
+    public void setBody(final byte[] bodyBytes, final ContentType contentType) {
+        this.body = SimpleBody.create(bodyBytes, contentType);
+    }
+
+    public void setBody(final String bodyText, final ContentType contentType) {
+        this.body = SimpleBody.create(bodyText, contentType);
+    }
+
+    /**
+     * @deprecated Use {@link #setBody(byte[], ContentType)}.
+     */
+    @Deprecated
     public void setBodyBytes(final byte[] bodyBytes, final ContentType contentType) \
{  this.body = SimpleBody.create(bodyBytes, contentType);
     }
 
+    /**
+     * @deprecated Use {@link #setBody(String, ContentType)}.
+     */
+    @Deprecated
     public void setBodyText(final String bodyText, final ContentType contentType) {
         this.body = SimpleBody.create(bodyText, contentType);
     }
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleResponseConsumer.java \
b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleResponseConsumer.java
 index 6b51fdc..75b73fb 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleResponseConsumer.java
                
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleResponseConsumer.java
 @@ -61,7 +61,7 @@ public final class SimpleResponseConsumer extends \
                AbstractAsyncResponseConsumer<
     protected SimpleHttpResponse buildResult(final HttpResponse response, final \
                byte[] entity, final ContentType contentType) {
         final SimpleHttpResponse simpleResponse = SimpleHttpResponse.copy(response);
         if (entity != null) {
-            simpleResponse.setBodyBytes(entity, contentType);
+            simpleResponse.setBody(entity, contentType);
         }
         return simpleResponse;
     }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic