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

jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git


The following commit(s) were added to refs/heads/master by this push:
     new 09d8ab4  REST refactoring.
09d8ab4 is described below

commit 09d8ab4bef2307e8108ee42498024381dd18333c
Author: JamesBognar <[email protected]>
AuthorDate: Fri Mar 12 12:53:17 2021 -0500

    REST refactoring.
---
 .../org/apache/juneau/rest/client/RestClient.java  |  4 +-
 .../org/apache/juneau/rest/client/RestRequest.java | 88 ++++++++++++++++++++--
 .../org/apache/juneau/rest/RequestHeaders.java     | 27 ++++---
 .../client/RestClient_Config_RestClient_Test.java  | 17 +++--
 .../rest/client/RestClient_Headers_Test.java       | 54 ++++++-------
 .../apache/juneau/rest/client/RestClient_Test.java |  3 +-
 6 files changed, 135 insertions(+), 58 deletions(-)

diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
index 868664e..0c9a1df 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
@@ -2900,7 +2900,7 @@ public class RestClient extends BeanContext implements 
HttpClient, Closeable, Re
                RestRequest req = createRequest(toURI(op.getUri(), rootUri), 
op.getMethod(), op.hasBody());
 
                for (Object o : headers)
-                       req.header(BasicHeader.cast(o));
+                       req.header(APPEND, BasicHeader.cast(o));
 
                for (Object o : query)
                        req.query(BasicPart.cast(o));
@@ -3084,7 +3084,7 @@ public class RestClient extends BeanContext implements 
HttpClient, Closeable, Re
                                        rc.parser(parser);
 
                                        for (Header h : rm.getHeaders())
-                                               rc.header(h);
+                                               rc.header(APPEND, h);
 
                                        for (RemoteOperationArg a : 
rom.getPathArgs())
                                                rc.pathArg(a.getName(), 
args[a.getIndex()], a.getSchema(), a.getSerializer(s));
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java
index 9442560..3ee14fd 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java
@@ -2032,7 +2032,10 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
        }
 
        /**
-        * Appends a header on the request.
+        * Adds or replaces a header on the request.
+        * 
+        * <p>
+        * Replaces the header if it already exists, or appends it to the end 
of the headers if it doesn't.
         *
         * <h5 class='section'>Example:</h5>
         * <p class='bcode w800'>
@@ -2057,9 +2060,12 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
        }
 
        /**
-        * Appends a header on the request.
+        * Adds or replaces a header on the request.
         *
         * <p>
+        * Replaces the header if it already exists, or appends it to the end 
of the headers if it doesn't.
+        * 
+        * <p>
         * The optional schema allows for specifying how part should be 
serialized (as a pipe-delimited list for example).
         *
         * <h5 class='section'>Example:</h5>
@@ -2089,7 +2095,7 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
        }
 
        /**
-        * Adds a header to the request.
+        * Adds or replaces a header to the request.
         *
         * <h5 class='section'>Example:</h5>
         * <p class='bcode w800'>
@@ -2123,8 +2129,11 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
        }
 
        /**
-        * Appends a header on the request.
+        * Adds or replaces a header on the request.
         *
+        * <p>
+        * Replaces the header if it already exists, or appends it to the end 
of the headers if it doesn't.
+        * 
         * <h5 class='section'>Example:</h5>
         * <p class='bcode w800'>
         *      <jc>// Adds header "Foo: bar".</jc>
@@ -2143,8 +2152,37 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
        }
 
        /**
-        * Appends multiple headers to the request.
+        * Adds or replaces a header on the request.
+        *
+        * <h5 class='section'>Example:</h5>
+        * <p class='bcode w800'>
+        *      <jc>// Adds header "Foo: bar".</jc>
+        *      <jv>client</jv>
+        *              .get(<jsf>URI</jsf>)
+        *              .header(<jsf>APPEND</jsf>, 
BasicHeader.<jsm>of</jsm>(<js>"Foo"</js>, <js>"bar"</js>))
+        *              .run();
+        * </p>
+        *
+        * @param flag How to add this parameter.
+        *      <ul>
+        *              <li>{@link AddFlag#APPEND APPEND} (default) - Append to 
end.
+        *              <li>{@link AddFlag#PREPEND PREPEND} - Prepend to 
beginning.
+        *              <li>{@link AddFlag#REPLACE REPLACE} - Delete any 
existing with same name and append to end.
+        *      </ul>
+        * @param header The header to set.
+        * @return This object (for method chaining).
+        * @throws RestCallException Invalid input.
+        */
+       public RestRequest header(AddFlag flag, Header header) throws 
RestCallException {
+               return headers(flag, header);
+       }
+
+       /**
+        * Adds or replaces multiple headers to the request.
         *
+        * <p>
+        * Replaces the header if it already exists, or appends it to the end 
of the headers if it doesn't.
+        * 
         * <h5 class='section'>Example:</h5>
         * <p class='bcode w800'>
         *      <jc>// Adds headers "Foo: bar" and "Baz: qux".</jc>
@@ -2176,7 +2214,7 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
         * @throws RestCallException Invalid input.
         */
        public RestRequest headers(Object...headers) throws RestCallException {
-               return headers(APPEND, headers);
+               return headers(REPLACE, headers);
        }
 
        /**
@@ -2247,8 +2285,11 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
        }
 
        /**
-        * Appends multiple headers on the request using freeform key/value 
pairs.
+        * Adds or replaces multiple headers on the request using freeform 
key/value pairs.
         *
+        * <p>
+        * Replaces the header if it already exists, or appends it to the end 
of the headers if it doesn't.
+        * 
         * <h5 class='section'>Example:</h5>
         * <p class='bcode w800'>
         *      <jc>// Adds headers "Foo: bar" and "Baz: qux".</jc>
@@ -2267,12 +2308,43 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
         * @throws RestCallException Invalid input.
         */
        public RestRequest headerPairs(Object...pairs) throws RestCallException 
{
+               return headerPairs(REPLACE, pairs);
+       }
+
+       /**
+        * Adds or replaces multiple headers on the request using freeform 
key/value pairs.
+        *
+        * <h5 class='section'>Example:</h5>
+        * <p class='bcode w800'>
+        *      <jc>// Adds headers "Foo: bar" and "Baz: qux".</jc>
+        *      <jv>client</jv>
+        *              .get(<jsf>URI</jsf>)
+        *              
.headers(<jsf>APPEND</jsf>,<js>"Foo"</js>,<js>"bar"</js>,<js>"Baz"</js>,<js>"qux"</js>)
+        *              .run();
+        * </p>
+        *
+        * @param flag How to add this parameter.
+        *      <ul>
+        *              <li>{@link AddFlag#APPEND APPEND} (default) - Append to 
end.
+        *              <li>{@link AddFlag#PREPEND PREPEND} - Prepend to 
beginning.
+        *              <li>{@link AddFlag#REPLACE REPLACE} - Delete any 
existing with same name and append to end.
+        *      </ul>
+        * @param pairs The form-data key/value pairs.
+        *      <ul>
+        *              <li>Values can be any POJO.
+        *              <li>Values converted to a string using the configured 
part serializer.
+        *      </ul>
+        * @return This object (for method chaining).
+        * @throws RestCallException Invalid input.
+        */
+
+       public RestRequest headerPairs(AddFlag flag, Object...pairs) throws 
RestCallException {
                List<Header> l = new ArrayList<>();
                if (pairs.length % 2 != 0)
                        throw new RestCallException(null, null, "Odd number of 
parameters passed into headerPairs()");
                for (int i = 0; i < pairs.length; i+=2)
                        l.add(serializedHeader(pairs[i], pairs[i+1], 
partSerializer, null, null));
-               return innerHeaders(EnumSet.of(APPEND), l);
+               return innerHeaders(EnumSet.of(flag), l);
        }
 
        RestRequest headerArg(EnumSet<AddFlag> flags, String name, Object 
value, HttpPartSchema schema, HttpPartSerializerSession serializer) throws 
RestCallException {
diff --git 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestHeaders.java
 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestHeaders.java
index a2899ce..c25b3ea 100644
--- 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestHeaders.java
+++ 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestHeaders.java
@@ -65,18 +65,13 @@ public class RequestHeaders {
                        map.put(key, l);
                }
 
+               // Parameters defined on the request URL overwrite existing 
headers.
                Set<String> allowedHeaderParams = 
req.getContext().getAllowedHeaderParams();
                for (RequestQueryParam p : query.getAll()) {
                        String name = p.getName();
                        String key = key(name);
                        if (allowedHeaderParams.contains(key) || 
allowedHeaderParams.contains("*")) {
-                               List<RequestHeader> l = map.get(key);
-                               if (l == null)
-                                       l = new ArrayList<>();
-                               RequestHeader h = new RequestHeader(req, name, 
p.getValue());
-                               list.add(h);
-                               l.add(h);
-                               map.put(key, l);
+                               set(name, p.getValue());
                        }
                }
        }
@@ -382,16 +377,24 @@ public class RequestHeaders {
        }
 
        /**
-        * Returns the last header with the specified name.
-        *
-        * <p>
-        * This is equivalent to {@link #getLast(String)}.
+        * Returns the condensed header with the specified name.
         *
         * @param name The header name.
         * @return The header, never <jk>null</jk>.
         */
        public RequestHeader get(String name) {
-               return getLast(name);
+               List<RequestHeader> l = getAll(name);
+               if (l.isEmpty())
+                       return new RequestHeader(req, name, 
null).parser(parser);
+               if (l.size() == 1)
+                       return l.get(0);
+               StringBuilder sb = new StringBuilder(128);
+               for (int i = 0, j = l.size(); i < j; i++) {
+                       if (i > 0)
+                               sb.append(", ");
+                       sb.append(l.get(i).getValue());
+               }
+               return new RequestHeader(req, name, 
sb.toString()).parser(parser);
        }
 
        /**
diff --git 
a/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Config_RestClient_Test.java
 
b/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Config_RestClient_Test.java
index c2b9f35..a1bf0d5 100644
--- 
a/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Config_RestClient_Test.java
+++ 
b/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Config_RestClient_Test.java
@@ -17,6 +17,7 @@ import static org.apache.juneau.http.HttpResponses.*;
 import static org.apache.juneau.rest.client.RestClient.*;
 import static org.junit.Assert.*;
 import static org.junit.runners.MethodSorters.*;
+import static org.apache.juneau.AddFlag.*;
 
 import java.io.*;
 import java.util.concurrent.*;
@@ -112,7 +113,7 @@ public class RestClient_Config_RestClient_Test {
                                return new BasicHttpResponse(new 
BasicStatusLine(new ProtocolVersion("http",1,1),201,null));
                        }
                };
-               
client().callHandler(A1.class).header("Foo","f1").build().get("/checkHeader").header("Foo","f2").run().assertBody().is("['f1','f2','baz']");
+               
client().callHandler(A1.class).header("Foo","f1").build().get("/checkHeader").header(APPEND,"Foo","f2").run().assertBody().is("['f1','f2','baz']");
                
client().callHandler(x).header("Foo","f1").build().get("/checkHeader").header("Foo","f2").run().assertCode().is(201);
        }
 
@@ -157,7 +158,7 @@ public class RestClient_Config_RestClient_Test {
                @Override
                public void onInit(RestRequest req) throws Exception {
                        x = 1;
-                       req.header("Foo","f2");
+                       req.header(APPEND,"Foo","f2");
                }
                @Override
                public void onConnect(RestRequest req, RestResponse res) throws 
Exception {
@@ -271,13 +272,13 @@ public class RestClient_Config_RestClient_Test {
 
        @Test
        public void a05_interceptors() throws Exception {
-               
client().header("Foo","f1").interceptors(A5.class).build().get("/checkHeader").header("Check","foo").header("Foo","f3").run().assertBody().is("['f1','f2','f3']").assertHeader("Bar").is("b1");
+               
client().header("Foo","f1").interceptors(A5.class).build().get("/checkHeader").header("Check","foo").header(APPEND,"Foo","f3").run().assertBody().is("['f1','f2','f3']").assertHeader("Bar").is("b1");
                assertEquals(111,A5.x);
 
-               client().header("Foo","f1").interceptors(new 
A5()).build().get("/checkHeader").header("Check","foo").header("Foo","f3").run().assertBody().is("['f1','f2','f3']").assertHeader("Bar").is("b1");
+               client().header("Foo","f1").interceptors(new 
A5()).build().get("/checkHeader").header("Check","foo").header(APPEND,"Foo","f3").run().assertBody().is("['f1','f2','f3']").assertHeader("Bar").is("b1");
                assertEquals(111,A5.x);
 
-               
client().header("Foo","f1").build().get("/checkHeader").interceptors(new 
A5()).header("Check","foo").header("Foo","f3").run().assertBody().is("['f1','f2','f3']").assertHeader("Bar").is("b1");
+               
client().header("Foo","f1").build().get("/checkHeader").interceptors(new 
A5()).header("Check","foo").header(APPEND,"Foo","f3").run().assertBody().is("['f1','f2','f3']").assertHeader("Bar").is("b1");
                assertEquals(111,A5.x);
 
                
assertThrown(()->client().header("Foo","f1").interceptors(A5a.class).build().get("/checkHeader")).isType(RuntimeException.class).is("foo");
@@ -485,13 +486,13 @@ public class RestClient_Config_RestClient_Test {
        @Test
        public void a12_partSerializer_partParser() throws Exception {
                RestClient x = 
client(A12.class).header("Foo",bean).partSerializer(A12a.class).partParser(A12b.class).build();
-               ABean b = 
x.get("/").header("Foo",bean).run().assertHeader("Foo").is("x{f:1}").getHeader("Foo").asType(ABean.class).get();
+               ABean b = 
x.get("/").header(APPEND,"Foo",bean).run().assertHeader("Foo").is("x{f:1}").getHeader("Foo").asType(ABean.class).get();
                assertEquals("{f:1}",b.toString());
-               b = 
x.get().header("Foo",bean).run().assertHeader("Foo").is("x{f:1}").getHeader("Foo").asType(ABean.class).get();
+               b = 
x.get().header(APPEND,"Foo",bean).run().assertHeader("Foo").is("x{f:1}").getHeader("Foo").asType(ABean.class).get();
                assertEquals("{f:1}",b.toString());
 
                x = client(A12.class).header("Foo",bean).partSerializer(new 
A12a()).partParser(new A12b()).build();
-               b = 
x.get("/").header("Foo",bean).run().assertHeader("Foo").is("x{f:1}").getHeader("Foo").asType(ABean.class).get();
+               b = 
x.get("/").header(APPEND,"Foo",bean).run().assertHeader("Foo").is("x{f:1}").getHeader("Foo").asType(ABean.class).get();
                assertEquals("{f:1}",b.toString());
        }
 
diff --git 
a/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Headers_Test.java
 
b/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Headers_Test.java
index b72c768..fe18a9f 100644
--- 
a/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Headers_Test.java
+++ 
b/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Headers_Test.java
@@ -75,30 +75,30 @@ public class RestClient_Headers_Test {
        public void a01_header_String_Object() throws Exception {
                
checkFooClient().header("Foo","bar").build().get("/headers").run().assertBody().is("['bar']");
                
checkFooClient().build().get("/headers").header("Foo","baz").run().assertBody().is("['baz']");
-               
checkFooClient().header("Foo","bar").build().get("/headers").header("Foo","baz").run().assertBody().is("['bar','baz']");
-               
checkFooClient().header("Foo",bean).build().get("/headers").header("Foo",bean).run().assertBody().is("['f=1','f=1']");
-               
checkFooClient().header("Foo",null).build().get("/headers").header("Foo",null).run().assertBody().is("[]");
+               
checkFooClient().header("Foo","bar").build().get("/headers").header(APPEND,"Foo","baz").run().assertBody().is("['bar','baz']");
+               
checkFooClient().header("Foo",bean).build().get("/headers").header(APPEND,"Foo",bean).run().assertBody().is("['f=1','f=1']");
+               
checkFooClient().header("Foo",null).build().get("/headers").header(APPEND,"Foo",null).run().assertBody().is("[]");
 
                
checkClient("null").header(null,"bar").build().get("/headers").header(null,"Foo").run().assertBody().is("[]");
-               
checkClient("null").header(null,null).build().get("/headers").header(null,null).run().assertBody().is("[]");
+               
checkClient("null").header(null,null).build().get("/headers").header((String)null,null).run().assertBody().is("[]");
        }
 
        @Test
        public void a02_header_String_Object_Schema() throws Exception {
                List<String> l1 = AList.of("bar","baz"), l2 = 
AList.of("qux","quux");
-               
checkFooClient().header("Foo",l1,T_ARRAY_PIPES).build().get("/headers").header("Foo",l2,T_ARRAY_PIPES).run().assertBody().is("['bar|baz','qux|quux']");
+               
checkFooClient().header("Foo",l1,T_ARRAY_PIPES).build().get("/headers").header(APPEND,"Foo",l2,T_ARRAY_PIPES).run().assertBody().is("['bar|baz','qux|quux']");
        }
 
        @Test
        public void a03_header_Header() throws Exception {
-               
checkFooClient().header(header("Foo","bar")).build().get("/headers").header(header("Foo","baz")).run().assertBody().is("['bar','baz']");
-               
checkFooClient().header(stringHeader("Foo","bar")).build().get("/headers").header(stringHeader("Foo","baz")).run().assertBody().is("['bar','baz']");
+               
checkFooClient().header(header("Foo","bar")).build().get("/headers").header(APPEND,header("Foo","baz")).run().assertBody().is("['bar','baz']");
+               
checkFooClient().header(stringHeader("Foo","bar")).build().get("/headers").header(APPEND,stringHeader("Foo","baz")).run().assertBody().is("['bar','baz']");
        }
 
        @Test
        public void a05_headerPairs_Objects() throws Exception {
-               
checkFooClient().headerPairs("Foo","bar").build().get("/headers").headerPairs("Foo","baz").run().assertBody().is("['bar','baz']");
-               
checkFooClient().headerPairs("Foo","bar","Foo","baz").header("Foo","qux").build().get("/headers").headerPairs("Foo","q1x","Foo","q2x").run().assertBody().is("['bar','baz','qux','q1x','q2x']");
+               
checkFooClient().headerPairs("Foo","bar").build().get("/headers").headerPairs(APPEND,"Foo","baz").run().assertBody().is("['bar','baz']");
+               
checkFooClient().headerPairs("Foo","bar","Foo","baz").header("Foo","qux").build().get("/headers").headerPairs(APPEND,"Foo","q1x","Foo","q2x").run().assertBody().is("['bar','baz','qux','q1x','q2x']");
                assertThrown(()->client().headerPairs("Foo")).contains("Odd 
number of parameters");
                
assertThrown(()->client().build().get("").headerPairs("Foo")).contains("Odd 
number of parameters");
        }
@@ -106,16 +106,16 @@ public class RestClient_Headers_Test {
        @Test
        public void a06_headers_Objects() throws Exception {
                
checkFooClient().headers((Header)null).build().get("/headers").headers((Header)null).run().assertBody().is("[]");
-               
checkFooClient().headers(header("Foo","bar"),header("Baz","baz")).build().get("/headers").headers(header("Foo","baz"),header("Baz","quux")).run().assertBody().is("['bar','baz']");
-               
checkFooClient().headers(OMap.of("Foo","bar")).build().get("/headers").headers(OMap.of("Foo","baz")).run().assertBody().is("['bar','baz']");
-               
checkFooClient().headers(AMap.of("Foo","bar")).build().get("/headers").headers(AMap.of("Foo","baz")).run().assertBody().is("['bar','baz']");
-               
checkFooClient().headers(part("Foo","bar")).build().get("/headers").headers(part("Foo","baz")).run().assertBody().is("['bar','baz']");
-               
checkFooClient().headers(serializedPart("Foo","Bar").serializer(OpenApiSerializer.DEFAULT)).build().get("/headers").headers(serializedPart("Foo","Baz").serializer(OpenApiSerializer.DEFAULT)).run().assertBody().is("['Bar','Baz']");
-               
checkFooClient().headers(serializedHeader("Foo","Bar").serializer(OpenApiSerializer.DEFAULT)).build().get("/headers").headers(serializedHeader("Foo","Baz").serializer(OpenApiSerializer.DEFAULT)).run().assertBody().is("['Bar','Baz']");
-               
checkFooClient().headers(serializedHeader("Foo",()->"Bar").serializer(OpenApiSerializer.DEFAULT)).build().get("/headers").headers(serializedHeader("Foo",()->"Baz").serializer(OpenApiSerializer.DEFAULT)).run().assertBody().is("['Bar','Baz']");
-               checkFooClient().headers((Object)new 
Header[]{header("Foo","bar")}).build().get("/headers").headers((Object)new 
Header[]{header("Foo","baz")}).run().assertBody().is("['bar','baz']");
-               
checkFooClient().headers(HeaderList.of(header("Foo","bar"))).build().get("/headers").headers(HeaderList.of(header("Foo","baz"))).run().assertBody().is("['bar','baz']");
-               
checkFooClient().headers(AList.of(header("Foo","bar"))).build().get("/headers").headers(AList.of(header("Foo","baz"))).run().assertBody().is("['bar','baz']");
+               
checkFooClient().headers(header("Foo","bar"),header("Baz","baz")).build().get("/headers").headers(APPEND,header("Foo","baz"),header("Baz","quux")).run().assertBody().is("['bar','baz']");
+               
checkFooClient().headers(OMap.of("Foo","bar")).build().get("/headers").headers(APPEND,OMap.of("Foo","baz")).run().assertBody().is("['bar','baz']");
+               
checkFooClient().headers(AMap.of("Foo","bar")).build().get("/headers").headers(APPEND,AMap.of("Foo","baz")).run().assertBody().is("['bar','baz']");
+               
checkFooClient().headers(part("Foo","bar")).build().get("/headers").headers(APPEND,part("Foo","baz")).run().assertBody().is("['bar','baz']");
+               
checkFooClient().headers(serializedPart("Foo","Bar").serializer(OpenApiSerializer.DEFAULT)).build().get("/headers").headers(APPEND,serializedPart("Foo","Baz").serializer(OpenApiSerializer.DEFAULT)).run().assertBody().is("['Bar','Baz']");
+               
checkFooClient().headers(serializedHeader("Foo","Bar").serializer(OpenApiSerializer.DEFAULT)).build().get("/headers").headers(APPEND,serializedHeader("Foo","Baz").serializer(OpenApiSerializer.DEFAULT)).run().assertBody().is("['Bar','Baz']");
+               
checkFooClient().headers(serializedHeader("Foo",()->"Bar").serializer(OpenApiSerializer.DEFAULT)).build().get("/headers").headers(APPEND,serializedHeader("Foo",()->"Baz").serializer(OpenApiSerializer.DEFAULT)).run().assertBody().is("['Bar','Baz']");
+               checkFooClient().headers((Object)new 
Header[]{header("Foo","bar")}).build().get("/headers").headers(APPEND,(Object)new
 Header[]{header("Foo","baz")}).run().assertBody().is("['bar','baz']");
+               
checkFooClient().headers(HeaderList.of(header("Foo","bar"))).build().get("/headers").headers(APPEND,HeaderList.of(header("Foo","baz"))).run().assertBody().is("['bar','baz']");
+               
checkFooClient().headers(AList.of(header("Foo","bar"))).build().get("/headers").headers(APPEND,AList.of(header("Foo","baz"))).run().assertBody().is("['bar','baz']");
                
checkClient("f").build().get("/headers").headers(bean).run().assertBody().is("['1']");
                
checkClient("f").build().get("/headers").headers((Object)null).run().assertBody().is("[]");
                assertThrown(()->client().headers("Foo")).contains("Invalid 
type");
@@ -150,9 +150,9 @@ public class RestClient_Headers_Test {
        public void a08_header_String_Supplier() throws Exception {
                TestSupplier s = TestSupplier.of("foo");
                RestClient x = checkFooClient().header("Foo",s).build();
-               
x.get("/headers").header("Foo",s).run().assertBody().is("['foo','foo']");
+               
x.get("/headers").header(APPEND,"Foo",s).run().assertBody().is("['foo','foo']");
                s.set("bar");
-               
x.get("/headers").header("Foo",s).run().assertBody().is("['bar','bar']");
+               
x.get("/headers").header(APPEND,"Foo",s).run().assertBody().is("['bar','bar']");
        }
 
        public static class A8 extends SimplePartSerializer {
@@ -176,9 +176,9 @@ public class RestClient_Headers_Test {
        public void a10_headers_String_Supplier_Schema() throws Exception {
                TestSupplier s = TestSupplier.of(new String[]{"foo","bar"});
                RestClient x = 
checkFooClient().header("Foo",s,T_ARRAY_PIPES).build();
-               
x.get("/headers").header("Foo",s,T_ARRAY_PIPES).run().assertBody().is("['foo|bar','foo|bar']");
+               
x.get("/headers").header(APPEND,"Foo",s,T_ARRAY_PIPES).run().assertBody().is("['foo|bar','foo|bar']");
                s.set(new String[]{"bar","baz"});
-               
x.get("/headers").header("Foo",s,T_ARRAY_PIPES).run().assertBody().is("['bar|baz','bar|baz']");
+               
x.get("/headers").header(APPEND,"Foo",s,T_ARRAY_PIPES).run().assertBody().is("['bar|baz','bar|baz']");
        }
 
        @Test
@@ -210,7 +210,7 @@ public class RestClient_Headers_Test {
 
        @Test
        public void b01_standardHeaders() throws Exception {
-               
checkClient("Accept").accept("text/foo").build().get("/headers").accept("text/plain").run().assertBody().is("['text/foo','text/plain']");
+               
checkClient("Accept").accept("text/foo").build().get("/headers").accept("text/plain").run().assertBody().is("['text/plain']");
                
checkClient("Accept-Charset").acceptCharset("UTF-8").build().get("/headers").run().assertBody().is("['UTF-8']");
                
checkClient("Accept-Encoding").acceptEncoding("identity").build().get("/headers").run().assertBody().is("['identity']");
                
checkClient("Accept-Language").acceptLanguage("en").build().get("/headers").run().assertBody().is("['en']");
@@ -281,7 +281,7 @@ public class RestClient_Headers_Test {
 
        @Test
        public void b02_headerBeans() throws Exception {
-               checkClient("Accept").header(new 
Accept("text/foo")).build().get("/headers").header(new 
Accept("text/plain")).run().assertBody().is("['text/foo','text/plain']");
+               checkClient("Accept").header(new 
Accept("text/foo")).build().get("/headers").header(new 
Accept("text/plain")).run().assertBody().is("['text/plain']");
                checkClient("Accept-Charset").header(new 
AcceptCharset("UTF-8")).build().get("/headers").run().assertBody().is("['UTF-8']");
                checkClient("Accept-Encoding").header(new 
AcceptEncoding("identity")).build().get("/headers").run().assertBody().is("['identity']");
                checkClient("Accept-Language").header(new 
AcceptLanguage("en")).build().get("/headers").run().assertBody().is("['en']");
@@ -326,7 +326,7 @@ public class RestClient_Headers_Test {
        @Test
        public void b04_dontOverrideAccept() throws Exception {
                
checkClient("Accept").header("Accept","text/plain").build().get("/headers").run().assertBody().is("['text/plain']");
-               
checkClient("Accept").header("Accept","text/foo").build().get("/headers").header("Accept","text/plain").run().assertBody().is("['text/foo','text/plain']");
+               
checkClient("Accept").header("Accept","text/foo").build().get("/headers").header("Accept","text/plain").run().assertBody().is("['text/plain']");
                RestClient rc = 
checkClient("Accept").header("Accept","text/foo").build();
                RestRequest req = rc.get("/headers");
                req.setHeader("Accept","text/plain");
@@ -336,7 +336,7 @@ public class RestClient_Headers_Test {
        @Test
        public void b05_dontOverrideContentType() throws Exception {
                
checkClient("Content-Type").header("Content-Type","text/plain").build().get("/headers").run().assertBody().is("['text/plain']");
-               
checkClient("Content-Type").header("Content-Type","text/foo").build().get("/headers").header("Content-Type","text/plain").run().assertBody().is("['text/foo','text/plain']");
+               
checkClient("Content-Type").header("Content-Type","text/foo").build().get("/headers").header("Content-Type","text/plain").run().assertBody().is("['text/plain']");
        }
 
        
//------------------------------------------------------------------------------------------------------------------
diff --git 
a/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Test.java 
b/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Test.java
index c271dcd..1318742 100644
--- 
a/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Test.java
+++ 
b/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Test.java
@@ -18,6 +18,7 @@ import static org.apache.juneau.assertions.Assertions.*;
 import static org.apache.juneau.http.HttpHeaders.*;
 import static org.apache.juneau.http.HttpResponses.*;
 import static org.apache.juneau.rest.client.RestClient.*;
+import static org.apache.juneau.AddFlag.*;
 
 import java.io.*;
 import java.util.concurrent.*;
@@ -402,7 +403,7 @@ public class RestClient_Test {
 
        @Test
        public void e08_httpMessage_getFirstHeader_getLastHeader() throws 
Exception {
-               RestRequest x = 
client().build().get("/bean").header("Foo","bar").header("Foo","baz");
+               RestRequest x = 
client().build().get("/bean").header("Foo","bar").header(APPEND,"Foo","baz");
                assertEquals("bar",x.getFirstHeader("Foo").getValue());
                assertEquals("baz",x.getLastHeader("Foo").getValue());
        }

Reply via email to