hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: Better header API
Date Mon, 30 Nov 2015 18:53:39 GMT
I mean:

Index: src/main/java/org/apache/hc/core5/http/HttpMessage.java
===================================================================
--- src/main/java/org/apache/hc/core5/http/HttpMessage.java (revision
1717301)
+++ src/main/java/org/apache/hc/core5/http/HttpMessage.java (working copy)
@@ -55,7 +55,7 @@
      * @param name the name of the header.
      * @param value the value of the header.
      */
-    void addHeader(String name, String value);
+    void addHeader(String name, Object value);

     /**
      * Overwrites the first header with the same name. The new header will
be appended to
@@ -72,7 +72,7 @@
      * @param name the name of the header.
      * @param value the value of the header.
      */
-    void setHeader(String name, String value);
+    void setHeader(String name, Object value);

     /**
      * Overwrites all the headers in the message.
Index:
src/main/java/org/apache/hc/core5/http/message/AbstractHttpMessage.java
===================================================================
--- src/main/java/org/apache/hc/core5/http/message/AbstractHttpMessage.java
(revision
1717301)
+++ src/main/java/org/apache/hc/core5/http/message/AbstractHttpMessage.java
(working
copy)
@@ -43,13 +43,13 @@
     private HttpEntity entity;

     @Override
-    public void addHeader(final String name, final String value) {
+    public void addHeader(final String name, final Object value) {
         Args.notNull(name, "Header name");
         addHeader(new BasicHeader(name, value));
     }

     @Override
-    public void setHeader(final String name, final String value) {
+    public void setHeader(final String name, final Object value) {
         Args.notNull(name, "Header name");
         setHeader(new BasicHeader(name, value));
     }
Index: src/main/java/org/apache/hc/core5/http/message/BasicHeader.java
===================================================================
--- src/main/java/org/apache/hc/core5/http/message/BasicHeader.java (revision
1717301)
+++ src/main/java/org/apache/hc/core5/http/message/BasicHeader.java (working
copy)
@@ -28,6 +28,7 @@
 package org.apache.hc.core5.http.message;

 import java.io.Serializable;
+import java.util.Objects;

 import org.apache.hc.core5.annotation.Immutable;
 import org.apache.hc.core5.http.Header;
@@ -55,10 +56,10 @@
      * @param name the header name
      * @param value the header value
      */
-    public BasicHeader(final String name, final String value) {
+    public BasicHeader(final String name, final Object value) {
         super();
         this.name = Args.notNull(name, "Name");
-        this.value = value;
+        this.value = Objects.toString(value, null);
     }

     @Override

Thoughts?

Gary

On Mon, Nov 30, 2015 at 10:53 AM, Gary Gregory <garydgregory@gmail.com>
wrote:

> I'd like to apply this patch:
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message