You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2020/01/28 19:51:31 UTC

[httpcomponents-core] branch master updated (cedb564 -> 0867704)

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

olegk pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git.


 discard cedb564  GitHub #191: Add org.apache.hc.core5.http.Method.normalizedValueOf(String).
 discard e7f5f33  Add org.apache.hc.core5.http.Method.normalizedValueOf(String) for use by (#191)
     new 0867704  Add org.apache.hc.core5.http.Method.normalizedValueOf(String) for use by (#191)

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (cedb564)
            \
             N -- N -- N   refs/heads/master (0867704)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:


[httpcomponents-core] 01/01: Add org.apache.hc.core5.http.Method.normalizedValueOf(String) for use by (#191)

Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 0867704ec4bce730442ae2c60a868c1d15ef2cde
Author: Gary Gregory <ga...@users.noreply.github.com>
AuthorDate: Tue Jan 28 14:40:28 2020 -0500

    Add org.apache.hc.core5.http.Method.normalizedValueOf(String) for use by (#191)
---
 RELEASE_NOTES.txt                                        |  3 +++
 .../src/main/java/org/apache/hc/core5/http/Method.java   | 16 ++++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 763ed0c..dd35f3a 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -20,6 +20,9 @@ Change Log
 
 * GitHub #188: Add PathEntity, a Path based implementation of HttpEntity. (#188)
   Contributed by Gary Gregory <garydgregory at gmail.com>
+  
+* GitHub #191: Add org.apache.hc.core5.http.Method.normalizedValueOf(String).
+  Contributed by Gary Gregory <garydgregory at gmail.com>
 
 
 Release 5.0-BETA11
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java b/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java
index 81bd758..0b3b627 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java
@@ -29,6 +29,8 @@ package org.apache.hc.core5.http;
 
 import java.util.Locale;
 
+import org.apache.hc.core5.util.Args;
+
 /**
  * Common HTTP methods defined by the HTTP spec.
  *
@@ -67,7 +69,7 @@ public enum Method {
             return false;
         }
         try {
-            return valueOf(value.toUpperCase(Locale.ROOT)).safe;
+            return normalizedValueOf(value).safe;
         } catch (final IllegalArgumentException ex) {
             return false;
         }
@@ -78,12 +80,22 @@ public enum Method {
             return false;
         }
         try {
-            return valueOf(value.toUpperCase(Locale.ROOT)).idempotent;
+            return normalizedValueOf(value).idempotent;
         } catch (final IllegalArgumentException ex) {
             return false;
         }
     }
 
+    /**
+     * Returns the Method for a normalized {@code value} of a method name.
+     *
+     * @param method A method name like {@code "delete"}, {@code "DELETE"}, or any mixed-case variant.
+     * @return the Method for the given method name.
+     */
+    public static Method normalizedValueOf(final String method) {
+        return valueOf(Args.notNull(method, "method").toUpperCase(Locale.ROOT));
+    }
+
     public boolean isSame(final String value) {
         if (value == null) {
             return false;