hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Better header API
Date Mon, 30 Nov 2015 20:28:26 GMT
On Mon, 2015-11-30 at 10:53 -0800, Gary Gregory wrote:
> 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?
> 

Works for me.

+1

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message