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 776e751  RestClient tests.
776e751 is described below

commit 776e751d607c6249922ab49d98bdf8d768858d24
Author: JamesBognar <[email protected]>
AuthorDate: Fri Jun 5 09:10:49 2020 -0400

    RestClient tests.
---
 .../org/apache/juneau/http/BasicObjectHeader.java  |  13 +
 .../juneau/http/SerializedNameValuePair.java       |  22 +-
 .../org/apache/juneau/internal/StringUtils.java    |   3 +
 .../apache/juneau/rest/client2/RestClientTest.java |   5 +-
 .../org/apache/juneau/rest/client2/RestClient.java |  34 +-
 .../juneau/rest/client2/RestClientBuilder.java     | 319 ++++++-
 .../apache/juneau/rest/client2/RestRequest.java    | 963 +++++++++++++++++----
 .../juneau/rest/mock2/MockRestClientBuilder.java   |  12 +-
 8 files changed, 1151 insertions(+), 220 deletions(-)

diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/BasicObjectHeader.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/BasicObjectHeader.java
index 25edaf3..f0814e3 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/BasicObjectHeader.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/BasicObjectHeader.java
@@ -12,6 +12,8 @@
 // 
***************************************************************************************************************************
 package org.apache.juneau.http;
 
+import java.util.function.*;
+
 import org.apache.http.message.BasicHeader;
 import org.apache.juneau.internal.*;
 
@@ -36,6 +38,17 @@ public class BasicObjectHeader extends BasicHeader {
        }
 
        /**
+        * Convenience creator.
+        *
+        * @param name The parameter name.
+        * @param value The parameter value.
+        * @return A new {@link BasicObjectHeader} object.
+        */
+       public static BasicObjectHeader of(String name, Supplier<?> value) {
+               return new BasicObjectHeader(name, value);
+       }
+
+       /**
         * Constructor.
         *
         * @param name The HTTP header name.
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/SerializedNameValuePair.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/SerializedNameValuePair.java
index f054feb..90d73e9 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/SerializedNameValuePair.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/SerializedNameValuePair.java
@@ -14,6 +14,8 @@ package org.apache.juneau.http;
 
 import static org.apache.juneau.internal.StringUtils.*;
 
+import java.util.function.*;
+
 import org.apache.http.*;
 import org.apache.juneau.*;
 import org.apache.juneau.httppart.*;
@@ -115,6 +117,17 @@ public class SerializedNameValuePair implements 
NameValuePair {
                }
 
                /**
+                * Sets the POJO to serialize to the parameter value.
+                *
+                * @param value The new value for this property.
+                * @return This object (for method chaining).
+                */
+               public Builder value(Supplier<Object> value) {
+                       this.value = value;
+                       return this;
+               }
+
+               /**
                 * Sets the HTTP part type.
                 *
                 * @param value The new value for this property.
@@ -189,15 +202,18 @@ public class SerializedNameValuePair implements 
NameValuePair {
        @Override /* NameValuePair */
        public String getValue() {
                try {
-                       if (value == null) {
+                       Object v = value;
+                       if (v instanceof Supplier)
+                               v = ((Supplier<?>)v).get();
+                       if (v == null) {
                                if (schema == null)
                                        return null;
                                if (schema.getDefault() == null && ! 
schema.isRequired())
                                        return null;
                        }
-                       if (isEmpty(value) && skipIfEmpty && 
schema.getDefault() == null)
+                       if (isEmpty(v) && skipIfEmpty && schema.getDefault() == 
null)
                                return null;
-                       return serializer.serialize(type, schema, value);
+                       return serializer.serialize(type, schema, v);
                } catch (SchemaValidationException e) {
                        throw new BasicRuntimeException(e, "Validation error on 
request {0} parameter ''{1}''=''{2}''", type, name, value);
                } catch (SerializeException e) {
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java
index b8f8816..ea49687 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java
@@ -24,6 +24,7 @@ import java.text.*;
 import java.util.*;
 import java.util.concurrent.*;
 import java.util.concurrent.atomic.*;
+import java.util.function.*;
 import java.util.regex.*;
 
 import javax.xml.bind.*;
@@ -2815,6 +2816,8 @@ public final class StringUtils {
         * @return The value converted to a string or <jk>null</jk> if the 
value was <jk>null</jk>.
         */
        public static String asString(Object value) {
+               if (value instanceof Supplier)
+                       value = ((Supplier<?>)value).get();
                return value == null ? null : value.toString();
        }
 
diff --git 
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClientTest.java
 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClientTest.java
index d94c0e3..bc3cdc3 100644
--- 
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClientTest.java
+++ 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClientTest.java
@@ -1576,12 +1576,11 @@ public class RestClientTest {
                        .create(A.class)
                        .simpleJson()
                        .header("Check", "Foo")
-                       .header("Foo", bean, new XPartSerializer(), null)
+                       .header("Foo", bean, null, new XPartSerializer())
                        .build()
                        .get("/checkHeader")
-                       .header(AddFlag.DEFAULT_FLAGS,"Foo",bean,new 
XPartSerializer().createPartSession(null),null)
                        .run()
-                       .assertBody().is("['x{f:1}','x{f:1}']");
+                       .assertBody().is("['x{f:1}']");
        }
 
        @Test
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestClient.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestClient.java
index d21afb2..dd71afc 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestClient.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestClient.java
@@ -281,7 +281,7 @@ import org.apache.http.client.CookieStore;
  *     <li class='jc'>{@link RestClientBuilder}
  *     <ul>
  *             <li class='jm'>{@link RestClientBuilder#header(String,Object) 
header(String,Object)}
- *             <li class='jm'>{@link 
RestClientBuilder#header(String,Object,HttpPartSerializer,HttpPartSchema) 
header(String,Object,HttpPartSerializer,HttpPartSchema)}
+ *             <li class='jm'>{@link 
RestClientBuilder#header(String,Object,HttpPartSchema,HttpPartSerializer) 
header(String,Object,HttpPartSerializer,HttpPartSchema)}
  *             <li class='jm'>{@link RestClientBuilder#header(Object) 
header(Object)}
  *             <li class='jm'>{@link RestClientBuilder#headers(Object...) 
headers(Object...)}
  *             <li class='jm'>{@link RestClientBuilder#headerPairs(Object...) 
headerPairs(Object...)}
@@ -321,7 +321,6 @@ import org.apache.http.client.CookieStore;
  *     <ul>
  *             <li class='jm'>{@link RestRequest#header(String,Object) 
header(String,Object)}
  *             <li class='jm'>{@link RestRequest#header(EnumSet,String,Object) 
header(EnumSet&gt;AddFlag&gt;,String,Object)}
- *             <li class='jm'>{@link 
RestRequest#header(EnumSet,String,Object,HttpPartSerializerSession,HttpPartSchema)
 header(EnumSet&gt;AddFlag&gt;,String,Object,HttpPartSerializer,HttpPartSchema)}
  *             <li class='jm'>{@link RestRequest#header(Object) header(Object)}
  *             <li class='jm'>{@link RestRequest#header(EnumSet,Object) 
header(EnumSet&gt;AddFlag&gt;,Object)}
  *             <li class='jm'>{@link RestRequest#headers(Object...) 
headers(Object...)}
@@ -404,7 +403,7 @@ import org.apache.http.client.CookieStore;
  *     <li class='jc'>{@link RestClientBuilder}
  *     <ul>
  *             <li class='jm'>{@link RestClientBuilder#query(String,Object) 
query(String,Object)}
- *             <li class='jm'>{@link 
RestClientBuilder#query(String,Object,HttpPartSerializer,HttpPartSchema) 
query(String,Object,HttpPartSerializer,HttpPartSchema)}
+ *             <li class='jm'>{@link 
RestClientBuilder#query(String,Object,HttpPartSchema,HttpPartSerializer) 
query(String,Object,HttpPartSerializer,HttpPartSchema)}
  *             <li class='jm'>{@link RestClientBuilder#query(Object...) 
query(Object...)}
  *             <li class='jm'>{@link RestClientBuilder#queryPairs(Object...) 
queryPairs(Object...)}
  *     </ul>
@@ -412,7 +411,6 @@ import org.apache.http.client.CookieStore;
  *     <ul>
  *             <li class='jm'>{@link RestRequest#query(String,Object) 
query(String,Object)}
  *             <li class='jm'>{@link RestRequest#query(EnumSet,String,Object) 
query(EnumSet&lt;AddFlag&gt;,String,Object)}
- *             <li class='jm'>{@link 
RestRequest#query(EnumSet,String,Object,HttpPartSerializerSession,HttpPartSchema)
 
query(EnumSet&lt;AddFlag&gt;,String,Object,HttpPartSerializerSession,HttpPartSchema)}
  *             <li class='jm'>{@link RestRequest#query(Object...) 
query(Object...)}
  *             <li class='jm'>{@link RestRequest#query(EnumSet,Object...) 
query(EnumSet&lt;AddFlag&gt;,Object...)}
  *             <li class='jm'>{@link RestRequest#queryPairs(Object...) 
queryPairs(Object...)}
@@ -444,7 +442,7 @@ import org.apache.http.client.CookieStore;
  *     <li class='jc'>{@link RestClientBuilder}
  *     <ul>
  *             <li class='jm'>{@link RestClientBuilder#formData(String,Object) 
formData(String,Object)}
- *             <li class='jm'>{@link 
RestClientBuilder#formData(String,Object,HttpPartSerializer,HttpPartSchema) 
formData(String,Object,HttpPartSerializer,HttpPartSchema)}
+ *             <li class='jm'>{@link 
RestClientBuilder#formData(String,Object,HttpPartSchema,HttpPartSerializer) 
formData(String,Object,HttpPartSerializer,HttpPartSchema)}
  *             <li class='jm'>{@link RestClientBuilder#formData(Object...) 
formData(Object...)}
  *             <li class='jm'>{@link 
RestClientBuilder#formDataPairs(Object...) formDataPairs(Object...)}
  *     </ul>
@@ -452,7 +450,6 @@ import org.apache.http.client.CookieStore;
  *     <ul>
  *             <li class='jm'>{@link RestRequest#formData(String,Object) 
formData(String,Object)}
  *             <li class='jm'>{@link 
RestRequest#formData(EnumSet,String,Object) 
formData(EnumSet&lt;AddFlag&gt;,String,Object)}
- *             <li class='jm'>{@link 
RestRequest#formData(EnumSet,String,Object,HttpPartSerializerSession,HttpPartSchema)
 
formData(EnumSet&lt;AddFlag&gt;,String,Object,HttpPartSerializerSession,HttpPartSchema)}
  *             <li class='jm'>{@link RestRequest#formData(Object...) 
formData(Object...)}
  *             <li class='jm'>{@link RestRequest#formData(EnumSet,Object...) 
formData(EnumSet&lt;AddFlag&gt;,Object...)}
  *             <li class='jm'>{@link RestRequest#formDataPairs(Object...) 
formDataPairs(Object...)}
@@ -1135,7 +1132,7 @@ public class RestClient extends BeanContext implements 
HttpClient, Closeable {
         *                      <li class='jc'>{@link 
org.apache.juneau.rest.client2.RestClientBuilder}
         *                      <ul>
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestClientBuilder#formData(String,Object) 
formData(String,Object)}
-        *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestClientBuilder#formData(String,Object,HttpPartSerializer,HttpPartSchema)
 formData(String,Object,HttpPartSerializer,HttpPartSchema)}
+        *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestClientBuilder#formData(String,Object,HttpPartSchema,HttpPartSerializer)
 formData(String,Object,HttpPartSerializer,HttpPartSchema)}
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestClientBuilder#formData(Object...) 
formData(Map<String, Object>)}
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestClientBuilder#formDataPairs(Object...) 
formData(Map<String, Object>)}
         *                      </ul>
@@ -1143,7 +1140,6 @@ public class RestClient extends BeanContext implements 
HttpClient, Closeable {
         *                      <ul>
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestRequest#formData(String,Object) 
formData(String,Object)}
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestRequest#formData(EnumSet,String,Object) 
formData(EnumSet&lt;AddFlag&gt;,String,Object)}
-        *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestRequest#formData(EnumSet,String,Object,HttpPartSerializerSession,HttpPartSchema)
 
formData(EnumSet&lt;AddFlag&gt;,String,Object,HttpPartSerializerSession,HttpPartSchema)}
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestRequest#formData(Object...) 
formData(Object...)}
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestRequest#formData(EnumSet,Object...) 
formData(EnumSet&lt;AddFlag&gt;Object...)}
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestRequest#formDataPairs(Object...) 
formDataPairs(Object...)}
@@ -1172,7 +1168,7 @@ public class RestClient extends BeanContext implements 
HttpClient, Closeable {
         *                      <li class='jc'>{@link 
org.apache.juneau.rest.client2.RestClientBuilder}
         *                      <ul>
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestClientBuilder#header(String,Object) 
header(String,Object)}
-        *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestClientBuilder#header(String,Object,HttpPartSerializer,HttpPartSchema)
 header(String,Object,HttpPartSerializer,HttpPartSchema)}
+        *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestClientBuilder#header(String,Object,HttpPartSchema,HttpPartSerializer)
 header(String,Object,HttpPartSerializer,HttpPartSchema)}
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestClientBuilder#header(Object) header(Object)}
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestClientBuilder#headers(Object...) 
headers(Object...)}
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestClientBuilder#headerPairs(Object...) 
headerPairs(Object...)}
@@ -1212,7 +1208,6 @@ public class RestClient extends BeanContext implements 
HttpClient, Closeable {
         *                      <ul>
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestRequest#header(String,Object) 
header(String,Object)}
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestRequest#header(EnumSet,String,Object) 
header(EnumSet&gt;AddFlag&gt;,String,Object)}
-        *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestRequest#header(EnumSet,String,Object,HttpPartSerializerSession,HttpPartSchema)
 
header(EnumSet&gt;AddFlag&gt;,String,Object,HttpPartSerializerSession,HttpPartSchema)}
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestRequest#header(Object) header(Object)}
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestRequest#header(EnumSet,Object) 
header(EnumSet&gt;AddFlag&gt;,Object)}
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestRequest#headers(Object...) 
headers(Object...)}
@@ -1741,13 +1736,12 @@ public class RestClient extends BeanContext implements 
HttpClient, Closeable {
         *                      <ul>
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestClientBuilder#query(Object...) 
query(Object...)}
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestClientBuilder#query(String,Object) 
query(String,Object)}
-        *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestClientBuilder#query(String,Object,HttpPartSerializer,HttpPartSchema)
 query(String,Object,HttpPartSerializer,HttpPartSchema)}
+        *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestClientBuilder#query(String,Object,HttpPartSchema,HttpPartSerializer)
 query(String,Object,HttpPartSerializer,HttpPartSchema)}
         *                      </ul>
         *                      <li class='jc'>{@link 
org.apache.juneau.rest.client2.RestRequest}
         *                      <ul>
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestRequest#query(String,Object) 
query(String,Object)}
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestRequest#query(EnumSet,String,Object) 
query(EnumSet&lt;AddFlag&gt;,String,Object)}
-        *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestRequest#query(EnumSet,String,Object,HttpPartSerializerSession,HttpPartSchema)
 
query(EnumSet&lt;AddFlag&gt;,String,Object,HttpPartSerializerSession,HttpPartSchema)}
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestRequest#query(Object...) query(Object...)}
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestRequest#query(EnumSet,Object...) 
query(EnumSet&lt;AddFlag&gt;,Object...)}
         *                              <li class='jm'>{@link 
org.apache.juneau.rest.client2.RestRequest#queryPairs(Object...) 
queryPairs(Object...)}
@@ -2947,16 +2941,16 @@ public class RestClient extends BeanContext implements 
HttpClient, Closeable {
                                                        rc.parser(parser);
 
                                                        for (RemoteMethodArg a 
: rmm.getPathArgs())
-                                                               
rc.path(a.getName(), args[a.getIndex()], a.getSerializer(s), a.getSchema());
+                                                               
rc.path(a.getName(), args[a.getIndex()], a.getSchema(), a.getSerializer(s));
 
                                                        for (RemoteMethodArg a 
: rmm.getQueryArgs())
-                                                               
rc.query(a.isSkipIfEmpty() ? SKIP_IF_EMPTY_FLAGS : DEFAULT_FLAGS, a.getName(), 
args[a.getIndex()], a.getSerializer(s), a.getSchema());
+                                                               
rc.query(a.isSkipIfEmpty() ? SKIP_IF_EMPTY_FLAGS : DEFAULT_FLAGS, a.getName(), 
args[a.getIndex()], a.getSchema(), a.getSerializer(s));
 
                                                        for (RemoteMethodArg a 
: rmm.getFormDataArgs())
-                                                               
rc.formData(a.isSkipIfEmpty() ? SKIP_IF_EMPTY_FLAGS : DEFAULT_FLAGS, 
a.getName(), args[a.getIndex()], a.getSerializer(s), a.getSchema());
+                                                               
rc.formData(a.isSkipIfEmpty() ? SKIP_IF_EMPTY_FLAGS : DEFAULT_FLAGS, 
a.getName(), args[a.getIndex()], a.getSchema(), a.getSerializer(s));
 
                                                        for (RemoteMethodArg a 
: rmm.getHeaderArgs())
-                                                               
rc.header(a.isSkipIfEmpty() ? SKIP_IF_EMPTY_FLAGS : DEFAULT_FLAGS, a.getName(), 
args[a.getIndex()], a.getSerializer(s), a.getSchema());
+                                                               
rc.header(a.isSkipIfEmpty() ? SKIP_IF_EMPTY_FLAGS : DEFAULT_FLAGS, a.getName(), 
args[a.getIndex()], a.getSchema(), a.getSerializer(s));
 
                                                        RemoteMethodArg ba = 
rmm.getBodyArg();
                                                        if (ba != null)
@@ -2975,14 +2969,14 @@ public class RestClient extends BeanContext implements 
HttpClient, Closeable {
                                                                                
        HttpPartSchema schema = p.getSchema();
                                                                                
        boolean sie = schema.isSkipIfEmpty();
                                                                                
        if (pt == PATH)
-                                                                               
                rc.path(pn, val, p.getSerializer(s), schema);
+                                                                               
                rc.path(pn, val, schema, p.getSerializer(s));
                                                                                
        else if (val != null) {
                                                                                
                if (pt == QUERY)
-                                                                               
                        rc.query(sie ? SKIP_IF_EMPTY_FLAGS : DEFAULT_FLAGS, pn, 
val, ps, schema);
+                                                                               
                        rc.query(sie ? SKIP_IF_EMPTY_FLAGS : DEFAULT_FLAGS, pn, 
val, schema, ps);
                                                                                
                else if (pt == FORMDATA)
-                                                                               
                        rc.formData(sie ? SKIP_IF_EMPTY_FLAGS : DEFAULT_FLAGS, 
pn, val, ps, schema);
+                                                                               
                        rc.formData(sie ? SKIP_IF_EMPTY_FLAGS : DEFAULT_FLAGS, 
pn, val, schema, ps);
                                                                                
                else if (pt == HEADER)
-                                                                               
                        rc.header(sie ? SKIP_IF_EMPTY_FLAGS : DEFAULT_FLAGS, 
pn, val, ps, schema);
+                                                                               
                        rc.header(sie ? SKIP_IF_EMPTY_FLAGS : DEFAULT_FLAGS, 
pn, val, schema, ps);
                                                                                
                else if (pt == HttpPartType.BODY)
                                                                                
                        rc.body(val, schema);
                                                                                
        }
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestClientBuilder.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestClientBuilder.java
index 9b3e551..b9a70dd 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestClientBuilder.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestClientBuilder.java
@@ -1056,14 +1056,11 @@ public class RestClientBuilder extends 
BeanContextBuilder {
         *
         * <h5 class='section'>Example:</h5>
         * <p class='bcode w800'>
-        *      <jk>import static</jk> 
org.apache.juneau.httppart.HttpPartSchema.*;
-        *
-        *      HttpPartSchema schema = <jsm>tArrayPipes</jsm>().build();  
<jc>// Pipe-delimited array.</jc>
         *      String[] value = {<js>"foo"</js>,<js>"bar"</js>};
         *
         *      RestClient c = RestClient
         *              .<jsm>create</jsm>()
-        *              .header(<js>"Foo"</js>, value, myPartSerializer, 
schema);  <jc>// Gets set as "foo|bar"</jc>
+        *              .header(<js>"Foo"</js>, value, 
HttpPartSchema.<jsf>T_ARRAY_PIPES</jsf>, myPartSerializer);  <jc>// Gets set as 
"foo|bar"</jc>
         *              .build();
         * </p>
         *
@@ -1074,19 +1071,55 @@ public class RestClientBuilder extends 
BeanContextBuilder {
         *              <li>Converted to a string using the specified part 
serializer.
         *              <li>Values are converted to strings at runtime to allow 
them to be modified externally.
         *      </ul>
+        * @param schema The schema object that defines the format of the 
output.
+        *      <ul>
+        *              <li>If <jk>null</jk>, defaults to {@link 
HttpPartSchema#DEFAULT}.
+        *              <li>Only used if serializer is schema-aware (e.g. 
{@link OpenApiSerializer}).
+        *      </ul>
         * @param serializer The serializer to use for serializing the value to 
a string.
         *      <ul>
         *              <li>If <jk>null</jk>, then the {@link 
HttpPartSerializer} defined on the client is used ({@link OpenApiSerializer} by 
default).
         *      </ul>
+        * @return This object (for method chaining).
+        */
+       @FluentSetter
+       public RestClientBuilder header(String name, Object value, 
HttpPartSchema schema, HttpPartSerializer serializer) {
+               return appendTo(RESTCLIENT_headers, 
SerializedNameValuePair.create().name(name).value(value).type(HEADER).serializer(serializer).schema(schema));
+       }
+
+       /**
+        * Sets a header on all requests.
+        *
+        * <h5 class='section'>Example:</h5>
+        * <p class='bcode w800'>
+        *      String[] value = {<js>"foo"</js>,<js>"bar"</js>};
+        *
+        *      RestClient c = RestClient
+        *              .<jsm>create</jsm>()
+        *              .header(<js>"Foo"</js>, ()-&gt;value, 
HttpPartSchema.<jsf>T_ARRAY_PIPES</jsf>, myPartSerializer);  <jc>// Gets set as 
"foo|bar"</jc>
+        *              .build();
+        * </p>
+        *
+        * @param name The header name.
+        * @param value The header value supplier.
+        *      <ul>
+        *              <li>Can be any POJO.
+        *              <li>Converted to a string using the specified part 
serializer.
+        *              <li>Values are converted to strings at runtime to allow 
them to be modified externally.
+        *      </ul>
         * @param schema The schema object that defines the format of the 
output.
         *      <ul>
         *              <li>If <jk>null</jk>, defaults to {@link 
HttpPartSchema#DEFAULT}.
         *              <li>Only used if serializer is schema-aware (e.g. 
{@link OpenApiSerializer}).
         *      </ul>
+        * @param serializer The serializer to use for serializing the value to 
a string.
+        *      <ul>
+        *              <li>If <jk>null</jk>, then the {@link 
HttpPartSerializer} defined on the client is used ({@link OpenApiSerializer} by 
default).
+        *      </ul>
         * @return This object (for method chaining).
         */
        @FluentSetter
-       public RestClientBuilder header(String name, Object value, 
HttpPartSerializer serializer, HttpPartSchema schema) {
+       public RestClientBuilder header(String name, Supplier<?> value, 
HttpPartSchema schema, HttpPartSerializer serializer) {
                return appendTo(RESTCLIENT_headers, 
SerializedNameValuePair.create().name(name).value(value).type(HEADER).serializer(serializer).schema(schema));
        }
 
@@ -1095,14 +1128,11 @@ public class RestClientBuilder extends 
BeanContextBuilder {
         *
         * <h5 class='section'>Example:</h5>
         * <p class='bcode w800'>
-        *      <jk>import static</jk> 
org.apache.juneau.httppart.HttpPartSchema.*;
-        *
-        *      HttpPartSchema schema = <jsm>tArrayPipes</jsm>().build();  
<jc>// Pipe-delimited array.</jc>
         *      String[] value = {<js>"foo"</js>,<js>"bar"</js>};
         *
         *      RestClient c = RestClient
         *              .<jsm>create</jsm>()
-        *              .header(<js>"Foo"</js>, value, schema);  <jc>// Gets 
set as "foo|bar"</jc>
+        *              .header(<js>"Foo"</js>, value, 
HttpPartSchema.<jsf>T_ARRAY_PIPES</jsf>);  <jc>// Gets set as "foo|bar"</jc>
         *              .build();
         * </p>
         *
@@ -1130,6 +1160,38 @@ public class RestClientBuilder extends 
BeanContextBuilder {
         *
         * <h5 class='section'>Example:</h5>
         * <p class='bcode w800'>
+        *      String[] value = {<js>"foo"</js>,<js>"bar"</js>};
+        *
+        *      RestClient c = RestClient
+        *              .<jsm>create</jsm>()
+        *              .header(<js>"Foo"</js>, ()-&gt;value, 
HttpPartSchema.<jsf>T_ARRAY_PIPES</jsf>);  <jc>// Gets set as "foo|bar"</jc>
+        *              .build();
+        * </p>
+        *
+        * @param name The header name.
+        * @param value The header value supplier.
+        *      <ul>
+        *              <li>Can be any POJO.
+        *              <li>Converted to a string using the specified part 
serializer.
+        *              <li>Values are converted to strings at runtime to allow 
them to be modified externally.
+        *      </ul>
+        * @param schema The schema object that defines the format of the 
output.
+        *      <ul>
+        *              <li>If <jk>null</jk>, defaults to {@link 
HttpPartSchema#DEFAULT}.
+        *              <li>Only used if serializer is schema-aware (e.g. 
{@link OpenApiSerializer}).
+        *      </ul>
+        * @return This object (for method chaining).
+        */
+       @FluentSetter
+       public RestClientBuilder header(String name, Supplier<?> value, 
HttpPartSchema schema) {
+               return appendTo(RESTCLIENT_headers, 
SerializedNameValuePair.create().name(name).value(value).type(HEADER).schema(schema));
+       }
+
+       /**
+        * Sets a header on all requests.
+        *
+        * <h5 class='section'>Example:</h5>
+        * <p class='bcode w800'>
         *      RestClient c = RestClient
         *              .<jsm>create</jsm>()
         *              .header(<js>"Foo"</js>, <js>"bar"</js>);
@@ -1161,6 +1223,35 @@ public class RestClientBuilder extends 
BeanContextBuilder {
         * <p class='bcode w800'>
         *      RestClient c = RestClient
         *              .<jsm>create</jsm>()
+        *              .header(<js>"Foo"</js>, ()-&gt;<js>"bar"</js>);
+        *              .build();
+        * </p>
+        *
+        * <ul class='seealso'>
+        *      <li class='jf'>{@link RestClient#RESTCLIENT_headers}
+        * </ul>
+        *
+        * @param name The header name.
+        * @param value The header value supplier.
+        *      <ul>
+        *              <li>Can be any POJO.
+        *              <li>Converted to a string using the specified part 
serializer.
+        *              <li>Values are converted to strings at runtime to allow 
them to be modified externally.
+        *      </ul>
+        * @return This object (for method chaining).
+        */
+       @FluentSetter
+       public RestClientBuilder header(String name, Supplier<?> value) {
+               return header(name, value, (HttpPartSchema)null, null);
+       }
+
+       /**
+        * Sets a header on all requests.
+        *
+        * <h5 class='section'>Example:</h5>
+        * <p class='bcode w800'>
+        *      RestClient c = RestClient
+        *              .<jsm>create</jsm>()
         *              .header(<jk>new</jk> BasicHeader(<js>"Foo"</js>, 
<js>"bar"</js>))
         *              .build();
         * </p>
@@ -1732,14 +1823,11 @@ public class RestClientBuilder extends 
BeanContextBuilder {
         *
         * <h5 class='section'>Example:</h5>
         * <p class='bcode w800'>
-        *      <jk>import static</jk> 
org.apache.juneau.httppart.HttpPartSchema.*;
-        *
-        *      HttpPartSchema schema = <jsm>tArrayPipes</jsm>().build();  
<jc>// Pipe-delimited array.</jc>
         *      String[] value = {<js>"foo"</js>,<js>"bar"</js>};
         *
         *      RestClient c = RestClient
         *              .<jsm>create</jsm>()
-        *              .query(<js>"foo"</js>, myPartSerializer, value, 
schema);  <jc>// Gets set as "foo|bar"</jc>
+        *              .query(<js>"foo"</js>, value, 
HttpPartSchema.<jsf>T_ARRAY_PIPES</jsf>, myPartSerializer);  <jc>// Gets set as 
"foo|bar"</jc>
         *              .build();
         * </p>
         *
@@ -1750,19 +1838,55 @@ public class RestClientBuilder extends 
BeanContextBuilder {
         *              <li>Converted to a string using the specified part 
serializer.
         *              <li>Values are converted to strings at runtime to allow 
them to be modified externally.
         *      </ul>
+        * @param schema The schema object that defines the format of the 
output.
+        *      <ul>
+        *              <li>If <jk>null</jk>, defaults to {@link 
HttpPartSchema#DEFAULT}.
+        *              <li>Only used if serializer is schema-aware (e.g. 
{@link OpenApiSerializer}).
+        *      </ul>
         * @param serializer The serializer to use for serializing the value to 
a string.
         *      <ul>
         *              <li>If <jk>null</jk>, then the {@link 
HttpPartSerializer} defined on the client is used ({@link OpenApiSerializer} by 
default).
         *      </ul>
+        * @return This object (for method chaining).
+        */
+       @FluentSetter
+       public RestClientBuilder query(String name, Object value, 
HttpPartSchema schema, HttpPartSerializer serializer) {
+               return appendTo(RESTCLIENT_query, 
SerializedNameValuePair.create().name(name).value(value).type(QUERY).serializer(serializer).schema(schema));
+       }
+
+       /**
+        * Adds a query parameter to the URI.
+        *
+        * <h5 class='section'>Example:</h5>
+        * <p class='bcode w800'>
+        *      String[] value = {<js>"foo"</js>,<js>"bar"</js>};
+        *
+        *      RestClient c = RestClient
+        *              .<jsm>create</jsm>()
+        *              .query(<js>"foo"</js>, ()-&gt;value, 
HttpPartSchema.<jsf>T_ARRAY_PIPES</jsf>, myPartSerializer);  <jc>// Gets set as 
"foo|bar"</jc>
+        *              .build();
+        * </p>
+        *
+        * @param name The parameter name.
+        * @param value The parameter value supplier.
+        *      <ul>
+        *              <li>Can be any POJO.
+        *              <li>Converted to a string using the specified part 
serializer.
+        *              <li>Values are converted to strings at runtime to allow 
them to be modified externally.
+        *      </ul>
         * @param schema The schema object that defines the format of the 
output.
         *      <ul>
         *              <li>If <jk>null</jk>, defaults to {@link 
HttpPartSchema#DEFAULT}.
         *              <li>Only used if serializer is schema-aware (e.g. 
{@link OpenApiSerializer}).
         *      </ul>
+        * @param serializer The serializer to use for serializing the value to 
a string.
+        *      <ul>
+        *              <li>If <jk>null</jk>, then the {@link 
HttpPartSerializer} defined on the client is used ({@link OpenApiSerializer} by 
default).
+        *      </ul>
         * @return This object (for method chaining).
         */
        @FluentSetter
-       public RestClientBuilder query(String name, Object value, 
HttpPartSerializer serializer, HttpPartSchema schema) {
+       public RestClientBuilder query(String name, Supplier<?> value, 
HttpPartSchema schema, HttpPartSerializer serializer) {
                return appendTo(RESTCLIENT_query, 
SerializedNameValuePair.create().name(name).value(value).type(QUERY).serializer(serializer).schema(schema));
        }
 
@@ -1771,14 +1895,11 @@ public class RestClientBuilder extends 
BeanContextBuilder {
         *
         * <h5 class='section'>Example:</h5>
         * <p class='bcode w800'>
-        *      <jk>import static</jk> 
org.apache.juneau.httppart.HttpPartSchema.*;
-        *
-        *      HttpPartSchema schema = <jsm>tArrayPipes</jsm>().build();  
<jc>// Pipe-delimited array.</jc>
         *      String[] value = {<js>"foo"</js>,<js>"bar"</js>};
         *
         *      RestClient c = RestClient
         *              .<jsm>create</jsm>()
-        *              .query(<js>"foo"</js>, value, schema);  <jc>// Gets set 
as "foo|bar"</jc>
+        *              .query(<js>"foo"</js>, value, 
HttpPartSchema.<jsf>T_ARRAY_PIPES</jsf>);  <jc>// Gets set as "foo|bar"</jc>
         *              .build();
         * </p>
         *
@@ -1806,6 +1927,38 @@ public class RestClientBuilder extends 
BeanContextBuilder {
         *
         * <h5 class='section'>Example:</h5>
         * <p class='bcode w800'>
+        *      String[] value = {<js>"foo"</js>,<js>"bar"</js>};
+        *
+        *      RestClient c = RestClient
+        *              .<jsm>create</jsm>()
+        *              .query(<js>"foo"</js>, ()-&gt;value, 
HttpPartSchema.<jsf>T_ARRAY_PIPES</jsf>);  <jc>// Gets set as "foo|bar"</jc>
+        *              .build();
+        * </p>
+        *
+        * @param name The parameter name.
+        * @param value The parameter value supplier.
+        *      <ul>
+        *              <li>Can be any POJO.
+        *              <li>Converted to a string using the specified part 
serializer.
+        *              <li>Values are converted to strings at runtime to allow 
them to be modified externally.
+        *      </ul>
+        * @param schema The schema object that defines the format of the 
output.
+        *      <ul>
+        *              <li>If <jk>null</jk>, defaults to {@link 
HttpPartSchema#DEFAULT}.
+        *              <li>Only used if serializer is schema-aware (e.g. 
{@link OpenApiSerializer}).
+        *      </ul>
+        * @return This object (for method chaining).
+        */
+       @FluentSetter
+       public RestClientBuilder query(String name, Supplier<?> value, 
HttpPartSchema schema) {
+               return appendTo(RESTCLIENT_query, 
SerializedNameValuePair.create().name(name).value(value).type(QUERY).schema(schema));
+       }
+
+       /**
+        * Adds a query parameter to the URI.
+        *
+        * <h5 class='section'>Example:</h5>
+        * <p class='bcode w800'>
         *      RestClient c = RestClient
         *              .<jsm>create</jsm>()
         *              .query(<js>"foo"</js>, <js>"bar"</js>)
@@ -1833,6 +1986,31 @@ public class RestClientBuilder extends 
BeanContextBuilder {
         * <p class='bcode w800'>
         *      RestClient c = RestClient
         *              .<jsm>create</jsm>()
+        *              .query(<js>"foo"</js>, ()-&gt;<js>"bar"</js>)
+        *              .build();
+        * </p>
+        *
+        * @param name The parameter name.
+        * @param value The parameter value supplier.
+        *      <ul>
+        *              <li>Can be any POJO.
+        *              <li>Converted to a string using the specified part 
serializer.
+        *              <li>Values are converted to strings at runtime to allow 
them to be modified externally.
+        *      </ul>
+        * @return This object (for method chaining).
+        */
+       @FluentSetter
+       public RestClientBuilder query(String name, Supplier<?> value) {
+               return query(name, value, (HttpPartSchema)null, null);
+       }
+
+       /**
+        * Adds a query parameter to the URI.
+        *
+        * <h5 class='section'>Example:</h5>
+        * <p class='bcode w800'>
+        *      RestClient c = RestClient
+        *              .<jsm>create</jsm>()
         *              .query(<jk>new</jk> BasicNameValuePair(<js>"foo"</js>, 
<js>"bar"</js>))
         *              .build();
         * </p>
@@ -1915,14 +2093,11 @@ public class RestClientBuilder extends 
BeanContextBuilder {
         *
         * <h5 class='section'>Example:</h5>
         * <p class='bcode w800'>
-        *      <jk>import static</jk> 
org.apache.juneau.httppart.HttpPartSchema.*;
-        *
-        *      HttpPartSchema schema = <jsm>tArrayPipes</jsm>().build();  
<jc>// Pipe-delimited array.</jc>
         *      String[] value = {<js>"foo"</js>,<js>"bar"</js>};
         *
         *      RestClient c = RestClient
         *              .<jsm>create</jsm>()
-        *              .formData(<js>"foo"</js>, myPartSerializer, value, 
schema);  <jc>// Gets set as "foo|bar"</jc>
+        *              .formData(<js>"foo"</js>, value, 
HttpPartSchema.<jsf>T_ARRAY_PIPES</jsf>, myPartSerializer);  <jc>// Gets set as 
"foo|bar"</jc>
         *              .build();
         * </p>
         *
@@ -1933,19 +2108,55 @@ public class RestClientBuilder extends 
BeanContextBuilder {
         *              <li>Converted to a string using the specified part 
serializer.
         *              <li>Values are converted to strings at runtime to allow 
them to be modified externally.
         *      </ul>
+        * @param schema The schema object that defines the format of the 
output.
+        *      <ul>
+        *              <li>If <jk>null</jk>, defaults to {@link 
HttpPartSchema#DEFAULT}.
+        *              <li>Only used if serializer is schema-aware (e.g. 
{@link OpenApiSerializer}).
+        *      </ul>
         * @param serializer The serializer to use for serializing the value to 
a string.
         *      <ul>
         *              <li>If <jk>null</jk>, then the {@link 
HttpPartSerializer} defined on the client is used ({@link OpenApiSerializer} by 
default).
         *      </ul>
+        * @return This object (for method chaining).
+        */
+       @FluentSetter
+       public RestClientBuilder formData(String name, Object value, 
HttpPartSchema schema, HttpPartSerializer serializer) {
+               return appendTo(RESTCLIENT_formData, 
SerializedNameValuePair.create().name(name).value(value).type(FORMDATA).serializer(serializer).schema(schema));
+       }
+
+       /**
+        * Adds a form-data parameter to all request bodies.
+        *
+        * <h5 class='section'>Example:</h5>
+        * <p class='bcode w800'>
+        *      String[] value = {<js>"foo"</js>,<js>"bar"</js>};
+        *
+        *      RestClient c = RestClient
+        *              .<jsm>create</jsm>()
+        *              .formData(<js>"foo"</js>, ()-&gt;value, 
HttpPartSchema.<jsf>T_ARRAY_PIPES</jsf>, myPartSerializer);  <jc>// Gets set as 
"foo|bar"</jc>
+        *              .build();
+        * </p>
+        *
+        * @param name The parameter name.
+        * @param value The parameter value supplier.
+        *      <ul>
+        *              <li>Can be any POJO.
+        *              <li>Converted to a string using the specified part 
serializer.
+        *              <li>Values are converted to strings at runtime to allow 
them to be modified externally.
+        *      </ul>
         * @param schema The schema object that defines the format of the 
output.
         *      <ul>
         *              <li>If <jk>null</jk>, defaults to {@link 
HttpPartSchema#DEFAULT}.
         *              <li>Only used if serializer is schema-aware (e.g. 
{@link OpenApiSerializer}).
         *      </ul>
+        * @param serializer The serializer to use for serializing the value to 
a string.
+        *      <ul>
+        *              <li>If <jk>null</jk>, then the {@link 
HttpPartSerializer} defined on the client is used ({@link OpenApiSerializer} by 
default).
+        *      </ul>
         * @return This object (for method chaining).
         */
        @FluentSetter
-       public RestClientBuilder formData(String name, Object value, 
HttpPartSerializer serializer, HttpPartSchema schema) {
+       public RestClientBuilder formData(String name, Supplier<?> value, 
HttpPartSchema schema, HttpPartSerializer serializer) {
                return appendTo(RESTCLIENT_formData, 
SerializedNameValuePair.create().name(name).value(value).type(FORMDATA).serializer(serializer).schema(schema));
        }
 
@@ -1954,14 +2165,11 @@ public class RestClientBuilder extends 
BeanContextBuilder {
         *
         * <h5 class='section'>Example:</h5>
         * <p class='bcode w800'>
-        *      <jk>import static</jk> 
org.apache.juneau.httppart.HttpPartSchema.*;
-        *
-        *      HttpPartSchema schema = <jsm>tArrayPipes</jsm>().build();  
<jc>// Pipe-delimited array.</jc>
         *      String[] value = {<js>"foo"</js>,<js>"bar"</js>};
         *
         *      RestClient c = RestClient
         *              .<jsm>create</jsm>()
-        *              .formData(<js>"foo"</js>, value, schema);  <jc>// Gets 
set as "foo|bar"</jc>
+        *              .formData(<js>"foo"</js>, value, 
HttpPartSchema.<jsf>T_ARRAY_PIPES</jsf>);  <jc>// Gets set as "foo|bar"</jc>
         *              .build();
         * </p>
         *
@@ -1989,6 +2197,38 @@ public class RestClientBuilder extends 
BeanContextBuilder {
         *
         * <h5 class='section'>Example:</h5>
         * <p class='bcode w800'>
+        *      String[] value = {<js>"foo"</js>,<js>"bar"</js>};
+        *
+        *      RestClient c = RestClient
+        *              .<jsm>create</jsm>()
+        *              .formData(<js>"foo"</js>, ()-&gt;value, 
HttpPartSchema.<jsf>T_ARRAY_PIPES</jsf>);  <jc>// Gets set as "foo|bar"</jc>
+        *              .build();
+        * </p>
+        *
+        * @param name The parameter name.
+        * @param value The parameter value supplier.
+        *      <ul>
+        *              <li>Can be any POJO.
+        *              <li>Converted to a string using the specified part 
serializer.
+        *              <li>Values are converted to strings at runtime to allow 
them to be modified externally.
+        *      </ul>
+        * @param schema The schema object that defines the format of the 
output.
+        *      <ul>
+        *              <li>If <jk>null</jk>, defaults to {@link 
HttpPartSchema#DEFAULT}.
+        *              <li>Only used if serializer is schema-aware (e.g. 
{@link OpenApiSerializer}).
+        *      </ul>
+        * @return This object (for method chaining).
+        */
+       @FluentSetter
+       public RestClientBuilder formData(String name, Supplier<?> value, 
HttpPartSchema schema) {
+               return appendTo(RESTCLIENT_formData, 
SerializedNameValuePair.create().name(name).value(value).type(FORMDATA).schema(schema));
+       }
+
+       /**
+        * Adds a form-data parameter to all request bodies.
+        *
+        * <h5 class='section'>Example:</h5>
+        * <p class='bcode w800'>
         *      RestClient c = RestClient
         *              .<jsm>create</jsm>()
         *              .formData(<js>"foo"</js>, <js>"bar"</js>)
@@ -2016,6 +2256,31 @@ public class RestClientBuilder extends 
BeanContextBuilder {
         * <p class='bcode w800'>
         *      RestClient c = RestClient
         *              .<jsm>create</jsm>()
+        *              .formData(<js>"foo"</js>, ()-&gt;<js>"bar"</js>)
+        *              .build();
+        * </p>
+        *
+        * @param name The parameter name.
+        * @param value The parameter value supplier.
+        *      <ul>
+        *              <li>Can be any POJO.
+        *              <li>Converted to a string using the specified part 
serializer.
+        *              <li>Values are converted to strings at runtime to allow 
them to be modified externally.
+        *      </ul>
+        * @return This object (for method chaining).
+        */
+       @FluentSetter
+       public RestClientBuilder formData(String name, Supplier<?> value) {
+               return formData(name, value, (HttpPartSchema)null, null);
+       }
+
+       /**
+        * Adds a form-data parameter to all request bodies.
+        *
+        * <h5 class='section'>Example:</h5>
+        * <p class='bcode w800'>
+        *      RestClient c = RestClient
+        *              .<jsm>create</jsm>()
         *              .formData(<jk>new</jk> 
BasicNameValuePair(<js>"foo"</js>, <js>"bar"</js>))
         *              .build();
         * </p>
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestRequest.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestRequest.java
index d6647ef..cf815fc 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestRequest.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestRequest.java
@@ -872,6 +872,14 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
        /**
         * Replaces a path parameter of the form <js>"{name}"</js> in the URL.
         *
+        * <h5 class='section'>Example:</h5>
+        * <p class='bcode w800'>
+        *      client
+        *              .get(<js>"/{foo}"</js>)
+        *              .path(<js>"foo"</js>, <js>"bar"</js>)
+        *              .run();
+        * </p>
+        *
         * @param name The parameter name.
         * @param value The parameter value.
         *      <ul>
@@ -879,40 +887,11 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
         *              <li>Converted to a string using the specified part 
serializer.
         *              <li>Values are converted to strings at runtime to allow 
them to be modified externally.
         *      </ul>
-        * @param serializer The serializer to use for serializing the value to 
a string.
-        *      <ul>
-        *              <li>If <jk>null</jk>, then the {@link 
HttpPartSerializer} defined on the client is used ({@link OpenApiSerializer} by 
default).
-        *      </ul>
-        * @param schema The schema object that defines the format of the 
output.
-        *      <ul>
-        *              <li>If <jk>null</jk>, defaults to {@link 
HttpPartSchema#DEFAULT}.
-        *              <li>Only used if serializer is schema-aware (e.g. 
{@link OpenApiSerializer}).
-        *      </ul>
         * @return This object (for method chaining).
-        * @throws RestCallException Error occurred.
+        * @throws RestCallException Invalid input.
         */
-       @SuppressWarnings("unchecked")
-       public RestRequest path(String name, Object value, 
HttpPartSerializerSession serializer, HttpPartSchema schema) throws 
RestCallException {
-               serializer = (serializer == null ? partSerializer : serializer);
-               boolean isMulti = isEmpty(name) || "*".equals(name) || value 
instanceof NameValuePairs;
-               if (! isMulti) {
-                       path(new SerializedNameValuePair(name, value, PATH, 
serializer, schema, false));
-               } else if (value instanceof NameValuePairs) {
-                       for (NameValuePair p : (NameValuePairs)value)
-                               path(p);
-               } else if (value instanceof Map) {
-                       for (Map.Entry<String,Object> p : ((Map<String,Object>) 
value).entrySet()) {
-                               String n = p.getKey();
-                               Object v = p.getValue();
-                               HttpPartSchema s = schema == null ? null : 
schema.getProperty(n);
-                               path(new SerializedNameValuePair(n, v, PATH, 
serializer, s, false));
-                       }
-               } else if (isBean(value)) {
-                       return path(name, toBeanMap(value), serializer, schema);
-               } else if (value != null) {
-                       throw new RestCallException("Invalid name ''{0}'' 
passed to path(name,value) for data type ''{1}''", name, className(value));
-               }
-               return this;
+       public RestRequest path(String name, Object value) throws 
RestCallException {
+               return path(name, value, null, null);
        }
 
        /**
@@ -922,12 +901,12 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
         * <p class='bcode w800'>
         *      client
         *              .get(<js>"/{foo}"</js>)
-        *              .path(<js>"foo"</js>, <js>"bar"</js>)
+        *              .path(<js>"foo"</js>, ()-&gt;<js>"bar"</js>)
         *              .run();
         * </p>
         *
         * @param name The parameter name.
-        * @param value The parameter value.
+        * @param value The parameter value supplier.
         *      <ul>
         *              <li>Can be any POJO.
         *              <li>Converted to a string using the specified part 
serializer.
@@ -936,7 +915,7 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
         * @return This object (for method chaining).
         * @throws RestCallException Invalid input.
         */
-       public RestRequest path(String name, Object value) throws 
RestCallException {
+       public RestRequest path(String name, Supplier<?> value) throws 
RestCallException {
                return path(name, value, null, null);
        }
 
@@ -967,7 +946,37 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
         * @throws RestCallException Invalid input.
         */
        public RestRequest path(String name, Object value, HttpPartSchema 
schema) throws RestCallException {
-               return path(name, value, null, schema);
+               return path(name, value, schema, null);
+       }
+
+       /**
+        * Replaces a path parameter of the form <js>"{name}"</js> in the URL.
+        *
+        * <p>
+        * The optional schema allows for specifying how part should be 
serialized (as a pipe-delimited list for example).
+        *
+        * <h5 class='section'>Example:</h5>
+        * <p class='bcode w800'>
+        * <jc>// Creates path "/bar|baz"</jc>
+        *      client
+        *              .get(<js>"/{foo}"</js>)
+        *              .path(<js>"foo"</js>, 
()-&gt;AList.<jsm>of</jsm>(<js>"bar"</js>,<js>"baz"</js>), 
HttpPartSchema.<jsf>T_ARRAY_PIPES</jsf>)
+        *              .run();
+        * </p>
+        *
+        * @param name The parameter name.
+        * @param value The parameter value supplier.
+        *      <ul>
+        *              <li>Can be any POJO.
+        *              <li>Converted to a string using the specified part 
serializer.
+        *              <li>Values are converted to strings at runtime to allow 
them to be modified externally.
+        *      </ul>
+        * @param schema The part schema.  Can be <jk>null</jk>.
+        * @return This object (for method chaining).
+        * @throws RestCallException Invalid input.
+        */
+       public RestRequest path(String name, Supplier<?> value, HttpPartSchema 
schema) throws RestCallException {
+               return path(name, value, schema, null);
        }
 
        /**
@@ -1144,6 +1153,30 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
                return this;
        }
 
+       @SuppressWarnings("unchecked")
+       RestRequest path(String name, Object value, HttpPartSchema schema, 
HttpPartSerializerSession serializer) throws RestCallException {
+               serializer = (serializer == null ? partSerializer : serializer);
+               boolean isMulti = isEmpty(name) || "*".equals(name) || value 
instanceof NameValuePairs;
+               if (! isMulti) {
+                       path(new SerializedNameValuePair(name, value, PATH, 
serializer, schema, false));
+               } else if (value instanceof NameValuePairs) {
+                       for (NameValuePair p : (NameValuePairs)value)
+                               path(p);
+               } else if (value instanceof Map) {
+                       for (Map.Entry<String,Object> p : ((Map<String,Object>) 
value).entrySet()) {
+                               String n = p.getKey();
+                               Object v = p.getValue();
+                               HttpPartSchema s = schema == null ? null : 
schema.getProperty(n);
+                               path(new SerializedNameValuePair(n, v, PATH, 
serializer, s, false));
+                       }
+               } else if (isBean(value)) {
+                       return path(name, toBeanMap(value), schema, serializer);
+               } else if (value != null) {
+                       throw new RestCallException("Invalid name ''{0}'' 
passed to path(name,value) for data type ''{1}''", name, className(value));
+               }
+               return this;
+       }
+
        
//------------------------------------------------------------------------------------------------------------------
        // Query
        
//------------------------------------------------------------------------------------------------------------------
@@ -1188,9 +1221,57 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
         *                      </ul>
         *              </ul>
         *      </ul>
-        * @param serializer The serializer to use for serializing the value to 
a string.
+        * @param schema The schema object that defines the format of the 
output.
+        *      <ul>
+        *              <li>If <jk>null</jk>, defaults to {@link 
HttpPartSchema#DEFAULT}.
+        *              <li>Only used if serializer is schema-aware (e.g. 
{@link OpenApiSerializer}).
+        *      </ul>
+        * @return This object (for method chaining).
+        * @throws RestCallException Invalid input.
+        */
+       public RestRequest query(EnumSet<AddFlag> flags, String name, Object 
value, HttpPartSchema schema) throws RestCallException {
+               return query(flags, name, value, schema, partSerializer);
+       }
+
+       /**
+        * Sets a query parameter on the URI.
+        *
+        * @param flags Instructions on 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.
+        *              <li>{@link AddFlag#SKIP_IF_EMPTY} - Don't add if value 
is an empty string.
+        *      </ul>
+        * @param name The parameter name.
+        *      <ul>
+        *              <li>If the name is <js>"*"</js>, the value is assumed 
to be a collection of parameters.
+        *      </ul>
+        * @param value The parameter value supplier.
         *      <ul>
-        *              <li>If <jk>null</jk>, then the {@link 
HttpPartSerializer} defined on the client is used ({@link OpenApiSerializer} by 
default).
+        *              <li>For single value parameters:
+        *              <ul>
+        *                      <li>Can be any POJO.
+        *                      <li>Converted to a string using the specified 
part serializer.
+        *                      <li>Values are converted to strings at runtime 
to allow them to be modified externally.
+        *              </ul>
+        *              <li>For multi-value parameters:
+        *              <ul>
+        *                      <li>{@link Map} / {@link OMap} / bean
+        *                      <ul>
+        *                              <li>Values can be any POJO.
+        *                              <li>Values converted to a string using 
the configured part serializer.
+        *                              <li>Values are converted to strings at 
runtime to allow them to be modified externally.
+        *                      </ul>
+        *                      <li>{@link NameValuePairs}
+        *                      <ul>
+        *                              <li>Values converted directly to 
strings.
+        *                      </ul>
+        *                      <li>{@link Reader} / {@link InputStream} / 
{@link CharSequence}
+        *                      <ul>
+        *                              <li>Sets the entire query string to the 
contents of the input.
+        *                      </ul>
+        *              </ul>
         *      </ul>
         * @param schema The schema object that defines the format of the 
output.
         *      <ul>
@@ -1200,25 +1281,8 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
         * @return This object (for method chaining).
         * @throws RestCallException Invalid input.
         */
-       @SuppressWarnings("unchecked")
-       public RestRequest query(EnumSet<AddFlag> flags, String name, Object 
value, HttpPartSerializerSession serializer, HttpPartSchema schema) throws 
RestCallException {
-               serializer = (serializer == null ? partSerializer : serializer);
-               flags = AddFlag.orDefault(flags);
-               boolean isMulti = isEmpty(name) || "*".equals(name) || value 
instanceof NameValuePairs;
-               if (! isMulti) {
-                       innerQuery(flags, toQuery(flags, name, value, 
serializer, schema));
-               } else if (value instanceof NameValuePairs) {
-                       innerQuery(flags, AList.of((NameValuePairs)value));
-               } else if (value instanceof Map) {
-                       innerQuery(flags, toQuery(flags, 
(Map<String,Object>)value, serializer, schema));
-               } else if (isBean(value)) {
-                       query(flags, name, toBeanMap(value), serializer, 
schema);
-               } else if (value instanceof Reader || value instanceof 
InputStream || value instanceof CharSequence) {
-                       queryCustom(value);
-               } else {
-                       throw new RestCallException("Invalid name ''{0}'' 
passed to query() for data type ''{1}''", name, className(value));
-               }
-               return this;
+       public RestRequest query(EnumSet<AddFlag> flags, String name, 
Supplier<?> value, HttpPartSchema schema) throws RestCallException {
+               return query(flags, name, value, schema, partSerializer);
        }
 
        /**
@@ -1266,21 +1330,17 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
         * @throws RestCallException Invalid input.
         */
        public RestRequest query(String name, Object value) throws 
RestCallException {
-               return query(DEFAULT_FLAGS, name, value, partSerializer, null);
+               return query(DEFAULT_FLAGS, name, value, null, partSerializer);
        }
 
        /**
         * Adds a query parameter to the URI.
         *
-        * <p>
-        * The optional schema allows for specifying how part should be 
serialized (as a pipe-delimited list for example).
-        *
         * <h5 class='section'>Example:</h5>
         * <p class='bcode w800'>
-        *      <jc>// Creates query parameter "foo=bar|baz"</jc>
         *      client
         *              .get(<jsf>URL</jsf>)
-        *              .query(<js>"foo"</js>, 
AList.<jsm>of</jsm>(<js>"bar"</js>,<js>"baz"</js>), 
HttpPartSchema.<jsf>T_ARRAY_PIPES</jsf>)
+        *              .query(<js>"foo"</js>, ()-&gt;<js>"bar"</js>)
         *              .run();
         * </p>
         *
@@ -1314,32 +1374,28 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
         *                      </ul>
         *              </ul>
         *      </ul>
-        * @param schema The HTTP part schema.  Can be <jk>null</jk>.
         * @return This object (for method chaining).
         * @throws RestCallException Invalid input.
         */
-       public RestRequest query(String name, Object value, HttpPartSchema 
schema) throws RestCallException {
-               return query(DEFAULT_FLAGS, name, value, partSerializer, 
schema);
+       public RestRequest query(String name, Supplier<?> value) throws 
RestCallException {
+               return query(DEFAULT_FLAGS, name, value, null, partSerializer);
        }
 
        /**
         * Adds a query parameter to the URI.
         *
+        * <p>
+        * The optional schema allows for specifying how part should be 
serialized (as a pipe-delimited list for example).
+        *
         * <h5 class='section'>Example:</h5>
         * <p class='bcode w800'>
+        *      <jc>// Creates query parameter "foo=bar|baz"</jc>
         *      client
         *              .get(<jsf>URL</jsf>)
-        *              .query(<js>"foo"</js>, <js>"bar"</js>)
+        *              .query(<js>"foo"</js>, 
AList.<jsm>of</jsm>(<js>"bar"</js>,<js>"baz"</js>), 
HttpPartSchema.<jsf>T_ARRAY_PIPES</jsf>)
         *              .run();
         * </p>
         *
-        * @param flags Instructions on 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.
-        *              <li>{@link AddFlag#SKIP_IF_EMPTY} - Don't add if value 
is an empty string.
-        *      </ul>
         * @param name The parameter name.
         *      <ul>
         *              <li>If the name is <js>"*"</js>, the value is assumed 
to be a collection of parameters.
@@ -1370,55 +1426,75 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
         *                      </ul>
         *              </ul>
         *      </ul>
+        * @param schema The HTTP part schema.  Can be <jk>null</jk>.
         * @return This object (for method chaining).
         * @throws RestCallException Invalid input.
         */
-       public RestRequest query(EnumSet<AddFlag> flags, String name, Object 
value) throws RestCallException {
-               return query(flags, name, value, partSerializer, null);
+       public RestRequest query(String name, Object value, HttpPartSchema 
schema) throws RestCallException {
+               return query(DEFAULT_FLAGS, name, value, schema, 
partSerializer);
        }
 
        /**
-        * Sets multiple parameters on the query string.
+        * Adds a query parameter to the URI.
+        *
+        * <p>
+        * The optional schema allows for specifying how part should be 
serialized (as a pipe-delimited list for example).
         *
         * <h5 class='section'>Example:</h5>
         * <p class='bcode w800'>
+        *      <jc>// Creates query parameter "foo=bar|baz"</jc>
         *      client
         *              .get(<jsf>URL</jsf>)
-        *              .query(<jk>new</jk> BasicNameValuePair(<js>"foo"</js>, 
<js>"bar"</js>))
+        *              .query(<js>"foo"</js>, 
()-&gt;AList.<jsm>of</jsm>(<js>"bar"</js>,<js>"baz"</js>), 
HttpPartSchema.<jsf>T_ARRAY_PIPES</jsf>)
         *              .run();
         * </p>
         *
-        * @param params The parameters to set.
-        *      <br>Can be any of the following types:
+        * @param name The parameter name.
         *      <ul>
-        *              <li>{@link NameValuePair}
-        *              <li>{@link Map} / {@link OMap} / bean
+        *              <li>If the name is <js>"*"</js>, the value is assumed 
to be a collection of parameters.
+        *      </ul>
+        * @param value The parameter value.
+        *      <ul>
+        *              <li>For single value parameters:
         *              <ul>
-        *                      <li>Values can be any POJO.
-        *                      <li>Values converted to a string using the 
configured part serializer.
+        *                      <li>Can be any POJO.
+        *                      <li>Converted to a string using the specified 
part serializer.
         *                      <li>Values are converted to strings at runtime 
to allow them to be modified externally.
         *              </ul>
-        *              <li>{@link NameValuePairs}
+        *              <li>For multi-value parameters:
         *              <ul>
-        *                      <li>Values converted directly to strings.
+        *                      <li>{@link Map} / {@link OMap} / bean
+        *                      <ul>
+        *                              <li>Values can be any POJO.
+        *                              <li>Values converted to a string using 
the configured part serializer.
+        *                              <li>Values are converted to strings at 
runtime to allow them to be modified externally.
+        *                      </ul>
+        *                      <li>{@link NameValuePairs}
+        *                      <ul>
+        *                              <li>Values converted directly to 
strings.
+        *                      </ul>
+        *                      <li>{@link Reader} / {@link InputStream} / 
{@link CharSequence}
+        *                      <ul>
+        *                              <li>Sets the entire query string to the 
contents of the input.
+        *                      </ul>
         *              </ul>
-        *              <li><jk>null</jk> - Will be a no-op.
         *      </ul>
+        * @param schema The HTTP part schema.  Can be <jk>null</jk>.
         * @return This object (for method chaining).
         * @throws RestCallException Invalid input.
         */
-       public RestRequest query(Object...params) throws RestCallException {
-               return query(DEFAULT_FLAGS, params);
+       public RestRequest query(String name, Supplier<?> value, HttpPartSchema 
schema) throws RestCallException {
+               return query(DEFAULT_FLAGS, name, value, schema, 
partSerializer);
        }
 
        /**
-        * Sets multiple parameters on the query string.
+        * Adds a query parameter to the URI.
         *
         * <h5 class='section'>Example:</h5>
         * <p class='bcode w800'>
         *      client
         *              .get(<jsf>URL</jsf>)
-        *              
.query(EnumSet.<jsm>of</jsm>(<jsf>REPLACE</jsf>,<jsf>SKIP_IF_EMPTY</jsf>),<jk>new</jk>
 BasicNameValuePair(<js>"Foo"</js>, <js>"bar"</js>))
+        *              .query(<js>"foo"</js>, <js>"bar"</js>)
         *              .run();
         * </p>
         *
@@ -1429,27 +1505,171 @@ public class RestRequest extends BeanSession 
implements HttpUriRequest, Configur
         *              <li>{@link AddFlag#REPLACE REPLACE} - Delete any 
existing with same name and append to end.
         *              <li>{@link AddFlag#SKIP_IF_EMPTY} - Don't add if value 
is an empty string.
         *      </ul>
-        * @param params The parameters to set.
-        *      <br>Can be any of the following types:
+        * @param name The parameter name.
         *      <ul>
-        *              <li>{@link NameValuePair}
-        *              <li>{@link Map} / {@link OMap} / bean
+        *              <li>If the name is <js>"*"</js>, the value is assumed 
to be a collection of parameters.
+        *      </ul>
+        * @param value The parameter value.
+        *      <ul>
+        *              <li>For single value parameters:
         *              <ul>
-        *                      <li>Values can be any POJO.
-        *                      <li>Values converted to a string using the 
configured part serializer.
+        *                      <li>Can be any POJO.
+        *                      <li>Converted to a string using the specified 
part serializer.
         *                      <li>Values are converted to strings at runtime 
to allow them to be modified externally.
         *              </ul>
-        *              <li>{@link NameValuePairs}
+        *              <li>For multi-value parameters:
         *              <ul>
-        *                      <li>Values converted directly to strings.
+        *                      <li>{@link Map} / {@link OMap} / bean
+        *                      <ul>
+        *                              <li>Values can be any POJO.
+        *                              <li>Values converted to a string using 
the configured part serializer.
+        *                              <li>Values are converted to strings at 
runtime to allow them to be modified externally.
+        *                      </ul>
+        *                      <li>{@link NameValuePairs}
+        *                      <ul>
+        *                              <li>Values converted directly to 
strings.
+        *                      </ul>
+        *                      <li>{@link Reader} / {@link InputStream} / 
{@link CharSequence}
+        *                      <ul>
+        *                              <li>Sets the entire query string to the 
contents of the input.
+        *                      </ul>
         *              </ul>
-        *              <li><jk>null</jk> - Will be a no-op.
         *      </ul>
         * @return This object (for method chaining).
         * @throws RestCallException Invalid input.
         */
-       @SuppressWarnings("rawtypes")
-       public RestRequest query(EnumSet<AddFlag> flags, Object...params) 
throws RestCallException {
+       public RestRequest query(EnumSet<AddFlag> flags, String name, Object 
value) throws RestCallException {
+               return query(flags, name, value, null, partSerializer);
+       }
+
+       /**
+        * Adds a query parameter to the URI.
+        *
+        * <h5 class='section'>Example:</h5>
+        * <p class='bcode w800'>
+        *      client
+        *              .get(<jsf>URL</jsf>)
+        *              .query(<js>"foo"</js>, ()-&gt;<js>"bar"</js>)
+        *              .run();
+        * </p>
+        *
+        * @param flags Instructions on 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.
+        *              <li>{@link AddFlag#SKIP_IF_EMPTY} - Don't add if value 
is an empty string.
+        *      </ul>
+        * @param name The parameter name.
+        *      <ul>
+        *              <li>If the name is <js>"*"</js>, the value is assumed 
to be a collection of parameters.
+        *      </ul>
+        * @param value The parameter value supplier.
+        *      <ul>
+        *              <li>For single value parameters:
+        *              <ul>
+        *                      <li>Can be any POJO.
+        *                      <li>Converted to a string using the specified 
part serializer.
+        *                      <li>Values are converted to strings at runtime 
to allow them to be modified externally.
+        *              </ul>
+        *              <li>For multi-value parameters:
+        *              <ul>
+        *                      <li>{@link Map} / {@link OMap} / bean
+        *                      <ul>
+        *                              <li>Values can be any POJO.
+        *                              <li>Values converted to a string using 
the configured part serializer.
+        *                              <li>Values are converted to strings at 
runtime to allow them to be modified externally.
+        *                      </ul>
+        *                      <li>{@link NameValuePairs}
+        *                      <ul>
+        *                              <li>Values converted directly to 
strings.
+        *                      </ul>
+        *                      <li>{@link Reader} / {@link InputStream} / 
{@link CharSequence}
+        *                      <ul>
+        *                              <li>Sets the entire query string to the 
contents of the input.
+        *                      </ul>
+        *              </ul>
+        *      </ul>
+        * @return This object (for method chaining).
+        * @throws RestCallException Invalid input.
+        */
+       public RestRequest query(EnumSet<AddFlag> flags, String name, 
Supplier<?> value) throws RestCallException {
+               return query(flags, name, value, null, partSerializer);
+       }
+
+       /**
+        * Sets multiple parameters on the query string.
+        *
+        * <h5 class='section'>Example:</h5>
+        * <p class='bcode w800'>
+        *      client
+        *              .get(<jsf>URL</jsf>)
+        *              .query(<jk>new</jk> BasicNameValuePair(<js>"foo"</js>, 
<js>"bar"</js>))
+        *              .run();
+        * </p>
+        *
+        * @param params The parameters to set.
+        *      <br>Can be any of the following types:
+        *      <ul>
+        *              <li>{@link NameValuePair}
+        *              <li>{@link Map} / {@link OMap} / bean
+        *              <ul>
+        *                      <li>Values can be any POJO.
+        *                      <li>Values converted to a string using the 
configured part serializer.
+        *                      <li>Values are converted to strings at runtime 
to allow them to be modified externally.
+        *              </ul>
+        *              <li>{@link NameValuePairs}
+        *              <ul>
+        *                      <li>Values converted directly to strings.
+        *              </ul>
+        *              <li><jk>null</jk> - Will be a no-op.
+        *      </ul>
+        * @return This object (for method chaining).
+        * @throws RestCallException Invalid input.
+        */
+       public RestRequest query(Object...params) throws RestCallException {
+               return query(DEFAULT_FLAGS, params);
+       }
+
+       /**
+        * Sets multiple parameters on the query string.
+        *
+        * <h5 class='section'>Example:</h5>
+        * <p class='bcode w800'>
+        *      client
+        *              .get(<jsf>URL</jsf>)
+        *              
.query(EnumSet.<jsm>of</jsm>(<jsf>REPLACE</jsf>,<jsf>SKIP_IF_EMPTY</jsf>),<jk>new</jk>
 BasicNameValuePair(<js>"Foo"</js>, <js>"bar"</js>))
+        *              .run();
+        * </p>
+        *
+        * @param flags Instructions on 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.
+        *              <li>{@link AddFlag#SKIP_IF_EMPTY} - Don't add if value 
is an empty string.
+        *      </ul>
+        * @param params The parameters to set.
+        *      <br>Can be any of the following types:
+        *      <ul>
+        *              <li>{@link NameValuePair}
+        *              <li>{@link Map} / {@link OMap} / bean
+        *              <ul>
+        *                      <li>Values can be any POJO.
+        *                      <li>Values converted to a string using the 
configured part serializer.
+        *                      <li>Values are converted to strings at runtime 
to allow them to be modified externally.
+        *              </ul>
+        *              <li>{@link NameValuePairs}
+        *              <ul>
+        *                      <li>Values converted directly to strings.
+        *              </ul>
+        *              <li><jk>null</jk> - Will be a no-op.
+        *      </ul>
+        * @return This object (for method chaining).
+        * @throws RestCallException Invalid input.
+        */
+       @SuppressWarnings("rawtypes")
+       public RestRequest query(EnumSet<AddFlag> flags, Object...params) 
throws RestCallException {
                List<NameValuePair> l = new ArrayList<>();
                boolean skipIfEmpty = flags.contains(SKIP_IF_EMPTY);
                for (Object o : params) {
@@ -1543,6 +1763,27 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
                return this;
        }
 
+       @SuppressWarnings("unchecked")
+       RestRequest query(EnumSet<AddFlag> flags, String name, Object value, 
HttpPartSchema schema, HttpPartSerializerSession serializer) throws 
RestCallException {
+               serializer = (serializer == null ? partSerializer : serializer);
+               flags = AddFlag.orDefault(flags);
+               boolean isMulti = isEmpty(name) || "*".equals(name) || value 
instanceof NameValuePairs;
+               if (! isMulti) {
+                       innerQuery(flags, toQuery(flags, name, value, 
serializer, schema));
+               } else if (value instanceof NameValuePairs) {
+                       innerQuery(flags, AList.of((NameValuePairs)value));
+               } else if (value instanceof Map) {
+                       innerQuery(flags, toQuery(flags, 
(Map<String,Object>)value, serializer, schema));
+               } else if (isBean(value)) {
+                       query(flags, name, toBeanMap(value), schema, 
serializer);
+               } else if (value instanceof Reader || value instanceof 
InputStream || value instanceof CharSequence) {
+                       queryCustom(value);
+               } else {
+                       throw new RestCallException("Invalid name ''{0}'' 
passed to query() for data type ''{1}''", name, className(value));
+               }
+               return this;
+       }
+
        private RestRequest innerQuery(EnumSet<AddFlag> flags, NameValuePair 
param) {
                return innerQuery(flags, AList.of(param));
        }
@@ -1618,9 +1859,57 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
         *                      </ul>
         *              </ul>
         *      </ul>
-        * @param serializer The serializer to use for serializing the value to 
a string.
+        * @param schema The schema object that defines the format of the 
output.
+        *      <ul>
+        *              <li>If <jk>null</jk>, defaults to {@link 
HttpPartSchema#DEFAULT}.
+        *              <li>Only used if serializer is schema-aware (e.g. 
{@link OpenApiSerializer}).
+        *      </ul>
+        * @return This object (for method chaining).
+        * @throws RestCallException Invalid input.
+        */
+       public RestRequest formData(EnumSet<AddFlag> flags, String name, Object 
value, HttpPartSchema schema) throws RestCallException {
+               return formData(flags, name, value, schema, partSerializer);
+       }
+
+       /**
+        * Adds a form-data parameter to the request body.
+        *
+        * @param flags Instructions on 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.
+        *              <li>{@link AddFlag#SKIP_IF_EMPTY} - Don't add if value 
is an empty string.
+        *      </ul>
+        * @param name The parameter name.
+        *      <ul>
+        *              <li>If the name is <js>"*"</js>, the value is assumed 
to be a collection of parameters.
+        *      </ul>
+        * @param value The parameter value supplier.
         *      <ul>
-        *              <li>If <jk>null</jk>, then the {@link 
HttpPartSerializer} defined on the client is used ({@link OpenApiSerializer} by 
default).
+        *              <li>For single value parameters:
+        *              <ul>
+        *                      <li>Can be any POJO.
+        *                      <li>Converted to a string using the specified 
part serializer.
+        *                      <li>Values are converted to strings at runtime 
to allow them to be modified externally.
+        *              </ul>
+        *              <li>For multi-value parameters:
+        *              <ul>
+        *                      <li>{@link Map} / {@link OMap} / bean
+        *                      <ul>
+        *                              <li>Values can be any POJO.
+        *                              <li>Values converted to a string using 
the configured part serializer.
+        *                              <li>Values are converted to strings at 
runtime to allow them to be modified externally.
+        *                      </ul>
+        *                      <li>{@link NameValuePairs}
+        *                      <ul>
+        *                              <li>Values converted directly to 
strings.
+        *                      </ul>
+        *                      <li>{@link Reader} / {@link InputStream} / 
{@link CharSequence} / {@link HttpEntity}
+        *                      <ul>
+        *                              <li>Sets the entire query string to the 
contents of the input.
+        *                      </ul>
+        *              </ul>
         *      </ul>
         * @param schema The schema object that defines the format of the 
output.
         *      <ul>
@@ -1630,35 +1919,171 @@ public class RestRequest extends BeanSession 
implements HttpUriRequest, Configur
         * @return This object (for method chaining).
         * @throws RestCallException Invalid input.
         */
-       @SuppressWarnings("unchecked")
-       public RestRequest formData(EnumSet<AddFlag> flags, String name, Object 
value, HttpPartSerializerSession serializer, HttpPartSchema schema) throws 
RestCallException {
-               serializer = (serializer == null ? partSerializer : serializer);
-               flags = AddFlag.orDefault(flags);
-               boolean isMulti = isEmpty(name) || "*".equals(name) || value 
instanceof NameValuePairs;
-               if (! isMulti) {
-                       innerFormData(flags, toQuery(flags, name, value, 
serializer, schema));
-               } else if (value instanceof NameValuePairs) {
-                       innerFormData(flags, AList.of((NameValuePairs)value));
-               } else if (value instanceof Map) {
-                       innerFormData(flags, toQuery(flags, 
(Map<String,Object>)value, serializer, schema));
-               } else if (isBean(value)) {
-                       formData(flags, name, toBeanMap(value), serializer, 
schema);
-               } else if (value instanceof Reader || value instanceof 
InputStream || value instanceof CharSequence || value instanceof HttpEntity) {
-                       formDataCustom(value);
-               } else {
-                       throw new RestCallException("Invalid name ''{0}'' 
passed to formData() for data type ''{1}''", name, className(value));
-               }
-               return this;
+       public RestRequest formData(EnumSet<AddFlag> flags, String name, 
Supplier<?> value, HttpPartSchema schema) throws RestCallException {
+               return formData(flags, name, value, schema, partSerializer);
+       }
+
+       /**
+        * Adds a form-data parameter to the request body.
+        *
+        * <h5 class='section'>Example:</h5>
+        * <p class='bcode w800'>
+        *      client
+        *              .formPost(<jsf>URL</jsf>)
+        *              .formData(<js>"foo"</js>, <js>"bar"</js>)
+        *              .run();
+        * </p>
+        *
+        * @param name The parameter name.
+        *      <ul>
+        *              <li>If the name is <js>"*"</js>, the value is assumed 
to be a collection of parameters.
+        *      </ul>
+        * @param value The parameter value.
+        *      <ul>
+        *              <li>For single value parameters:
+        *              <ul>
+        *                      <li>Can be any POJO.
+        *                      <li>Converted to a string using the specified 
part serializer.
+        *                      <li>Values are converted to strings at runtime 
to allow them to be modified externally.
+        *              </ul>
+        *              <li>For multi-value parameters:
+        *              <ul>
+        *                      <li>{@link Map} / {@link OMap} / bean
+        *                      <ul>
+        *                              <li>Values can be any POJO.
+        *                              <li>Values converted to a string using 
the configured part serializer.
+        *                              <li>Values are converted to strings at 
runtime to allow them to be modified externally.
+        *                      </ul>
+        *                      <li>{@link NameValuePairs}
+        *                      <ul>
+        *                              <li>Values converted directly to 
strings.
+        *                      </ul>
+        *                      <li>{@link Reader} / {@link InputStream} / 
{@link CharSequence}
+        *                      <ul>
+        *                              <li>Sets the entire query string to the 
contents of the input.
+        *                      </ul>
+        *              </ul>
+        *      </ul>
+        * @return This object (for method chaining).
+        * @throws RestCallException Invalid input.
+        */
+       public RestRequest formData(String name, Object value) throws 
RestCallException {
+               return formData(DEFAULT_FLAGS, name, value, null, 
partSerializer);
+       }
+
+       /**
+        * Adds a form-data parameter to the request body.
+        *
+        * <h5 class='section'>Example:</h5>
+        * <p class='bcode w800'>
+        *      client
+        *              .formPost(<jsf>URL</jsf>)
+        *              .formData(<js>"foo"</js>, ()-&gt;<js>"bar"</js>)
+        *              .run();
+        * </p>
+        *
+        * @param name The parameter name.
+        *      <ul>
+        *              <li>If the name is <js>"*"</js>, the value is assumed 
to be a collection of parameters.
+        *      </ul>
+        * @param value The parameter value supplier.
+        *      <ul>
+        *              <li>For single value parameters:
+        *              <ul>
+        *                      <li>Can be any POJO.
+        *                      <li>Converted to a string using the specified 
part serializer.
+        *                      <li>Values are converted to strings at runtime 
to allow them to be modified externally.
+        *              </ul>
+        *              <li>For multi-value parameters:
+        *              <ul>
+        *                      <li>{@link Map} / {@link OMap} / bean
+        *                      <ul>
+        *                              <li>Values can be any POJO.
+        *                              <li>Values converted to a string using 
the configured part serializer.
+        *                              <li>Values are converted to strings at 
runtime to allow them to be modified externally.
+        *                      </ul>
+        *                      <li>{@link NameValuePairs}
+        *                      <ul>
+        *                              <li>Values converted directly to 
strings.
+        *                      </ul>
+        *                      <li>{@link Reader} / {@link InputStream} / 
{@link CharSequence}
+        *                      <ul>
+        *                              <li>Sets the entire query string to the 
contents of the input.
+        *                      </ul>
+        *              </ul>
+        *      </ul>
+        * @return This object (for method chaining).
+        * @throws RestCallException Invalid input.
+        */
+       public RestRequest formData(String name, Supplier<?> value) throws 
RestCallException {
+               return formData(DEFAULT_FLAGS, name, value, null, 
partSerializer);
+       }
+
+       /**
+        * Adds a form-data parameter to the request body.
+        *
+        * <p>
+        * The optional schema allows for specifying how part should be 
serialized (as a pipe-delimited list for example).
+        *
+        * <h5 class='section'>Example:</h5>
+        * <p class='bcode w800'>
+        *      <jc>// Creates form-data parameter "foo=bar|baz"</jc>
+        *      client
+        *              .formPost(<jsf>URL</jsf>)
+        *              .formData(<js>"foo"</js>, 
AList.<jsm>of</jsm>(<js>"bar"</js>,<js>"baz"</js>), 
HttpPartSchema.<jsf>T_ARRAY_PIPES</jsf>)
+        *              .run();
+        * </p>
+        *
+        * @param name The parameter name.
+        *      <ul>
+        *              <li>If the name is <js>"*"</js>, the value is assumed 
to be a collection of parameters.
+        *      </ul>
+        * @param value The parameter value.
+        *      <ul>
+        *              <li>For single value parameters:
+        *              <ul>
+        *                      <li>Can be any POJO.
+        *                      <li>Converted to a string using the specified 
part serializer.
+        *                      <li>Values are converted to strings at runtime 
to allow them to be modified externally.
+        *              </ul>
+        *              <li>For multi-value parameters:
+        *              <ul>
+        *                      <li>{@link Map} / {@link OMap} / bean
+        *                      <ul>
+        *                              <li>Values can be any POJO.
+        *                              <li>Values converted to a string using 
the configured part serializer.
+        *                              <li>Values are converted to strings at 
runtime to allow them to be modified externally.
+        *                      </ul>
+        *                      <li>{@link NameValuePairs}
+        *                      <ul>
+        *                              <li>Values converted directly to 
strings.
+        *                      </ul>
+        *                      <li>{@link Reader} / {@link InputStream} / 
{@link CharSequence}
+        *                      <ul>
+        *                              <li>Sets the entire query string to the 
contents of the input.
+        *                      </ul>
+        *              </ul>
+        *      </ul>
+        * @param schema The HTTP part schema.  Can be <jk>null</jk>.
+        * @return This object (for method chaining).
+        * @throws RestCallException Invalid input.
+        */
+       public RestRequest formData(String name, Object value, HttpPartSchema 
schema) throws RestCallException {
+               return formData(DEFAULT_FLAGS, name, value, schema, 
partSerializer);
        }
 
        /**
         * Adds a form-data parameter to the request body.
         *
+        * <p>
+        * The optional schema allows for specifying how part should be 
serialized (as a pipe-delimited list for example).
+        *
         * <h5 class='section'>Example:</h5>
         * <p class='bcode w800'>
+        *      <jc>// Creates form-data parameter "foo=bar|baz"</jc>
         *      client
         *              .formPost(<jsf>URL</jsf>)
-        *              .formData(<js>"foo"</js>, <js>"bar"</js>)
+        *              .formData(<js>"foo"</js>, 
()-&gt;AList.<jsm>of</jsm>(<js>"bar"</js>,<js>"baz"</js>), 
HttpPartSchema.<jsf>T_ARRAY_PIPES</jsf>)
         *              .run();
         * </p>
         *
@@ -1666,7 +2091,7 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
         *      <ul>
         *              <li>If the name is <js>"*"</js>, the value is assumed 
to be a collection of parameters.
         *      </ul>
-        * @param value The parameter value.
+        * @param value The parameter value supplier.
         *      <ul>
         *              <li>For single value parameters:
         *              <ul>
@@ -1692,28 +2117,32 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
         *                      </ul>
         *              </ul>
         *      </ul>
+        * @param schema The HTTP part schema.  Can be <jk>null</jk>.
         * @return This object (for method chaining).
         * @throws RestCallException Invalid input.
         */
-       public RestRequest formData(String name, Object value) throws 
RestCallException {
-               return formData(DEFAULT_FLAGS, name, value, partSerializer, 
null);
+       public RestRequest formData(String name, Supplier<?> value, 
HttpPartSchema schema) throws RestCallException {
+               return formData(DEFAULT_FLAGS, name, value, schema, 
partSerializer);
        }
 
        /**
         * Adds a form-data parameter to the request body.
         *
-        * <p>
-        * The optional schema allows for specifying how part should be 
serialized (as a pipe-delimited list for example).
-        *
         * <h5 class='section'>Example:</h5>
         * <p class='bcode w800'>
-        *      <jc>// Creates form-data parameter "foo=bar|baz"</jc>
         *      client
         *              .formPost(<jsf>URL</jsf>)
-        *              .formData(<js>"foo"</js>, 
AList.<jsm>of</jsm>(<js>"bar"</js>,<js>"baz"</js>), 
HttpPartSchema.<jsf>T_ARRAY_PIPES</jsf>)
+        *              
.formData(EnumSet.<jsm>of</jsm>(<jsf>REPLACE</jsf>,<jsf>SKIP_IF_EMPTY</jsf>), 
<js>"foo"</js>, <js>"bar"</js>)
         *              .run();
         * </p>
         *
+        * @param flags Instructions on 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.
+        *              <li>{@link AddFlag#SKIP_IF_EMPTY} - Don't add if value 
is an empty string.
+        *      </ul>
         * @param name The parameter name.
         *      <ul>
         *              <li>If the name is <js>"*"</js>, the value is assumed 
to be a collection of parameters.
@@ -1744,12 +2173,11 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
         *                      </ul>
         *              </ul>
         *      </ul>
-        * @param schema The HTTP part schema.  Can be <jk>null</jk>.
         * @return This object (for method chaining).
         * @throws RestCallException Invalid input.
         */
-       public RestRequest formData(String name, Object value, HttpPartSchema 
schema) throws RestCallException {
-               return formData(DEFAULT_FLAGS, name, value, partSerializer, 
schema);
+       public RestRequest formData(EnumSet<AddFlag> flags, String name, Object 
value) throws RestCallException {
+               return formData(flags, name, value, null, partSerializer);
        }
 
        /**
@@ -1759,7 +2187,7 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
         * <p class='bcode w800'>
         *      client
         *              .formPost(<jsf>URL</jsf>)
-        *              
.formData(EnumSet.<jsm>of</jsm>(<jsf>REPLACE</jsf>,<jsf>SKIP_IF_EMPTY</jsf>), 
<js>"foo"</js>, <js>"bar"</js>)
+        *              
.formData(EnumSet.<jsm>of</jsm>(<jsf>REPLACE</jsf>,<jsf>SKIP_IF_EMPTY</jsf>), 
<js>"foo"</js>, ()-&gt;<js>"bar"</js>)
         *              .run();
         * </p>
         *
@@ -1774,7 +2202,7 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
         *      <ul>
         *              <li>If the name is <js>"*"</js>, the value is assumed 
to be a collection of parameters.
         *      </ul>
-        * @param value The parameter value.
+        * @param value The parameter value supplier.
         *      <ul>
         *              <li>For single value parameters:
         *              <ul>
@@ -1803,8 +2231,8 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
         * @return This object (for method chaining).
         * @throws RestCallException Invalid input.
         */
-       public RestRequest formData(EnumSet<AddFlag> flags, String name, Object 
value) throws RestCallException {
-               return formData(flags, name, value, partSerializer, null);
+       public RestRequest formData(EnumSet<AddFlag> flags, String name, 
Supplier<?> value) throws RestCallException {
+               return formData(flags, name, value, null, partSerializer);
        }
 
        /**
@@ -1972,6 +2400,27 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
                return this;
        }
 
+       @SuppressWarnings("unchecked")
+       RestRequest formData(EnumSet<AddFlag> flags, String name, Object value, 
HttpPartSchema schema, HttpPartSerializerSession serializer) throws 
RestCallException {
+               serializer = (serializer == null ? partSerializer : serializer);
+               flags = AddFlag.orDefault(flags);
+               boolean isMulti = isEmpty(name) || "*".equals(name) || value 
instanceof NameValuePairs;
+               if (! isMulti) {
+                       innerFormData(flags, toQuery(flags, name, value, 
serializer, schema));
+               } else if (value instanceof NameValuePairs) {
+                       innerFormData(flags, AList.of((NameValuePairs)value));
+               } else if (value instanceof Map) {
+                       innerFormData(flags, toQuery(flags, 
(Map<String,Object>)value, serializer, schema));
+               } else if (isBean(value)) {
+                       formData(flags, name, toBeanMap(value), schema, 
serializer);
+               } else if (value instanceof Reader || value instanceof 
InputStream || value instanceof CharSequence || value instanceof HttpEntity) {
+                       formDataCustom(value);
+               } else {
+                       throw new RestCallException("Invalid name ''{0}'' 
passed to formData() for data type ''{1}''", name, className(value));
+               }
+               return this;
+       }
+
        private RestRequest innerFormData(EnumSet<AddFlag> flags, NameValuePair 
param) {
                return innerFormData(flags, AList.of(param));
        }
@@ -2150,9 +2599,53 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
         *                      </ul>
         *              </ul>
         *      </ul>
-        * @param serializer The serializer to use for serializing the value to 
a string.
+        * @param schema The schema object that defines the format of the 
output.
+        *      <ul>
+        *              <li>If <jk>null</jk>, defaults to {@link 
HttpPartSchema#DEFAULT}.
+        *              <li>Only used if serializer is schema-aware (e.g. 
{@link OpenApiSerializer}).
+        *      </ul>
+        * @return This object (for method chaining).
+        * @throws RestCallException Invalid input.
+        */
+       public RestRequest header(EnumSet<AddFlag> flags, String name, Object 
value, HttpPartSchema schema) throws RestCallException {
+               return header(flags, name, value, schema, partSerializer);
+       }
+
+       /**
+        * Sets a header on the request.
+        *
+        * @param flags Instructions on 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.
+        *              <li>{@link AddFlag#SKIP_IF_EMPTY} - Don't add if value 
is an empty string.
+        *      </ul>
+        * @param name The header name.
+        *      <ul>
+        *              <li>If the name is <js>"*"</js>, the value is assumed 
to be a collection of headers.
+        *      </ul>
+        * @param value The header value supplier.
         *      <ul>
-        *              <li>If <jk>null</jk>, then the {@link 
HttpPartSerializer} defined on the client is used ({@link OpenApiSerializer} by 
default).
+        *              <li>For single value headers:
+        *              <ul>
+        *                      <li>Can be any POJO.
+        *                      <li>Converted to a string using the specified 
part serializer.
+        *                      <li>Values are converted to strings at runtime 
to allow them to be modified externally.
+        *              </ul>
+        *              <li>For multi-value headers:
+        *              <ul>
+        *                      <li>{@link Map} / {@link OMap} / bean
+        *                      <ul>
+        *                              <li>Values can be any POJO.
+        *                              <li>Values converted to a string using 
the configured part serializer.
+        *                              <li>Values are converted to strings at 
runtime to allow them to be modified externally.
+        *                      </ul>
+        *                      <li>{@link NameValuePairs}
+        *                      <ul>
+        *                              <li>Values converted directly to 
strings.
+        *                      </ul>
+        *              </ul>
         *      </ul>
         * @param schema The schema object that defines the format of the 
output.
         *      <ul>
@@ -2162,23 +2655,8 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
         * @return This object (for method chaining).
         * @throws RestCallException Invalid input.
         */
-       @SuppressWarnings("unchecked")
-       public RestRequest header(EnumSet<AddFlag> flags, String name, Object 
value, HttpPartSerializerSession serializer, HttpPartSchema schema) throws 
RestCallException {
-               serializer = (serializer == null ? partSerializer : serializer);
-               flags = AddFlag.orDefault(flags);
-               boolean isMulti = isEmpty(name) || "*".equals(name) || value 
instanceof NameValuePairs;
-               if (! isMulti) {
-                       innerHeader(flags, toHeader(flags, name, value, 
serializer, schema));
-               } else if (value instanceof NameValuePairs) {
-                       innerHeaders(flags, toHeaders((NameValuePairs)value));
-               } else if (value instanceof Map) {
-                       innerHeaders(flags, toHeaders(flags, 
(Map<String,Object>)value, serializer, schema));
-               } else if (isBean(value)) {
-                       return header(flags, name, toBeanMap(value), 
serializer, schema);
-               } else {
-                       throw new RestCallException("Invalid name ''{0}'' 
passed to header(name,value,skipIfEmpty) for data type ''{1}''", name, 
className(value));
-               }
-               return this;
+       public RestRequest header(EnumSet<AddFlag> flags, String name, 
Supplier<?> value, HttpPartSchema schema) throws RestCallException {
+               return header(flags, name, value, schema, partSerializer);
        }
 
        /**
@@ -2222,7 +2700,51 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
         * @throws RestCallException Invalid input.
         */
        public RestRequest header(String name, Object value) throws 
RestCallException {
-               return header(DEFAULT_FLAGS, name, value, partSerializer, null);
+               return header(DEFAULT_FLAGS, name, value, null, partSerializer);
+       }
+
+       /**
+        * Appends a header on the request.
+        *
+        * <h5 class='section'>Example:</h5>
+        * <p class='bcode w800'>
+        *      client
+        *              .get(<jsf>URL</jsf>)
+        *              .header(<js>"Foo"</js>, ()-&gt;<js>"bar"</js>)
+        *              .run();
+        * </p>
+        *
+        * @param name The header name.
+        *      <ul>
+        *              <li>If the name is <js>"*"</js>, the value is assumed 
to be a collection of headers.
+        *      </ul>
+        * @param value The header value.
+        *      <ul>
+        *              <li>For single value headers:
+        *              <ul>
+        *                      <li>Can be any POJO.
+        *                      <li>Converted to a string using the specified 
part serializer.
+        *                      <li>Values are converted to strings at runtime 
to allow them to be modified externally.
+        *              </ul>
+        *              <li>For multi-value headers:
+        *              <ul>
+        *                      <li>{@link Map} / {@link OMap} / bean
+        *                      <ul>
+        *                              <li>Values can be any POJO.
+        *                              <li>Values converted to a string using 
the configured part serializer.
+        *                              <li>Values are converted to strings at 
runtime to allow them to be modified externally.
+        *                      </ul>
+        *                      <li>{@link NameValuePairs}
+        *                      <ul>
+        *                              <li>Values converted directly to 
strings.
+        *                      </ul>
+        *              </ul>
+        *      </ul>
+        * @return This object (for method chaining).
+        * @throws RestCallException Invalid input.
+        */
+       public RestRequest header(String name, Supplier<?> value) throws 
RestCallException {
+               return header(DEFAULT_FLAGS, name, value, null, partSerializer);
        }
 
        /**
@@ -2271,7 +2793,56 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
         * @throws RestCallException Invalid input.
         */
        public RestRequest header(String name, Object value, HttpPartSchema 
schema) throws RestCallException {
-               return header(DEFAULT_FLAGS, name, value, partSerializer, 
schema);
+               return header(DEFAULT_FLAGS, name, value, schema, 
partSerializer);
+       }
+
+       /**
+        * Appends a header on the request.
+        *
+        * <p>
+        * The optional schema allows for specifying how part should be 
serialized (as a pipe-delimited list for example).
+        *
+        * <h5 class='section'>Example:</h5>
+        * <p class='bcode w800'>
+        *      <jc>// Creates header "Foo=bar|baz"</jc>
+        *      client
+        *              .get(<jsf>URL</jsf>)
+        *              .header(<js>"Foo"</js>, 
()-&gt;AList.<jsm>of</jsm>(<js>"bar"</js>,<js>"baz"</js>), 
HttpPartSchema.<jsf>T_ARRAY_PIPES</jsf>)
+        *              .run();
+        * </p>
+        *
+        * @param name The header name.
+        *      <ul>
+        *              <li>If the name is <js>"*"</js>, the value is assumed 
to be a collection of headers.
+        *      </ul>
+        * @param value The header value.
+        *      <ul>
+        *              <li>For single value headers:
+        *              <ul>
+        *                      <li>Can be any POJO.
+        *                      <li>Converted to a string using the specified 
part serializer.
+        *                      <li>Values are converted to strings at runtime 
to allow them to be modified externally.
+        *              </ul>
+        *              <li>For multi-value headers:
+        *              <ul>
+        *                      <li>{@link Map} / {@link OMap} / bean
+        *                      <ul>
+        *                              <li>Values can be any POJO.
+        *                              <li>Values converted to a string using 
the configured part serializer.
+        *                              <li>Values are converted to strings at 
runtime to allow them to be modified externally.
+        *                      </ul>
+        *                      <li>{@link NameValuePairs}
+        *                      <ul>
+        *                              <li>Values converted directly to 
strings.
+        *                      </ul>
+        *              </ul>
+        *      </ul>
+        * @param schema The HTTP part schema.  Can be <jk>null</jk>.
+        * @return This object (for method chaining).
+        * @throws RestCallException Invalid input.
+        */
+       public RestRequest header(String name, Supplier<?> value, 
HttpPartSchema schema) throws RestCallException {
+               return header(DEFAULT_FLAGS, name, value, schema, 
partSerializer);
        }
 
        /**
@@ -2322,7 +2893,58 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
         * @throws RestCallException Invalid input.
         */
        public RestRequest header(EnumSet<AddFlag> flags, String name, Object 
value) throws RestCallException {
-               return header(flags, name, value, partSerializer, null);
+               return header(flags, name, value, null, partSerializer);
+       }
+
+       /**
+        * Sets a header on the request.
+        *
+        * <h5 class='section'>Example:</h5>
+        * <p class='bcode w800'>
+        *      client
+        *              .get(<jsf>URL</jsf>)
+        *              
.header(EnumSet.<jsm>of</jsm>(<jsf>REPLACE</jsf>,<jsf>SKIP_IF_EMPTY</jsf>),<js>"Foo"</js>,
 ()-&gt;<js>"bar"</js>)
+        *              .run();
+        * </p>
+        *
+        * @param flags Instructions on 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.
+        *              <li>{@link AddFlag#SKIP_IF_EMPTY} - Don't add if value 
is an empty string.
+        *      </ul>
+        * @param name The header name.
+        *      <ul>
+        *              <li>If the name is <js>"*"</js>, the value is assumed 
to be a collection of headers.
+        *      </ul>
+        * @param value The header value supplier.
+        *      <ul>
+        *              <li>For single value headers:
+        *              <ul>
+        *                      <li>Can be any POJO.
+        *                      <li>Converted to a string using the specified 
part serializer.
+        *                      <li>Values are converted to strings at runtime 
to allow them to be modified externally.
+        *              </ul>
+        *              <li>For multi-value headers:
+        *              <ul>
+        *                      <li>{@link Map} / {@link OMap} / bean
+        *                      <ul>
+        *                              <li>Values can be any POJO.
+        *                              <li>Values converted to a string using 
the configured part serializer.
+        *                              <li>Values are converted to strings at 
runtime to allow them to be modified externally.
+        *                      </ul>
+        *                      <li>{@link NameValuePairs}
+        *                      <ul>
+        *                              <li>Values converted directly to 
strings.
+        *                      </ul>
+        *              </ul>
+        *      </ul>
+        * @return This object (for method chaining).
+        * @throws RestCallException Invalid input.
+        */
+       public RestRequest header(EnumSet<AddFlag> flags, String name, 
Supplier<?> value) throws RestCallException {
+               return header(flags, name, value, null, partSerializer);
        }
 
        /**
@@ -2512,6 +3134,25 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
                return innerHeaders(DEFAULT_FLAGS, l);
        }
 
+       @SuppressWarnings("unchecked")
+       RestRequest header(EnumSet<AddFlag> flags, String name, Object value, 
HttpPartSchema schema, HttpPartSerializerSession serializer) throws 
RestCallException {
+               serializer = (serializer == null ? partSerializer : serializer);
+               flags = AddFlag.orDefault(flags);
+               boolean isMulti = isEmpty(name) || "*".equals(name) || value 
instanceof NameValuePairs;
+               if (! isMulti) {
+                       innerHeader(flags, toHeader(flags, name, value, 
serializer, schema));
+               } else if (value instanceof NameValuePairs) {
+                       innerHeaders(flags, toHeaders((NameValuePairs)value));
+               } else if (value instanceof Map) {
+                       innerHeaders(flags, toHeaders(flags, 
(Map<String,Object>)value, serializer, schema));
+               } else if (isBean(value)) {
+                       return header(flags, name, toBeanMap(value), schema, 
serializer);
+               } else {
+                       throw new RestCallException("Invalid name ''{0}'' 
passed to header(name,value,skipIfEmpty) for data type ''{1}''", name, 
className(value));
+               }
+               return this;
+       }
+
        private RestRequest innerHeader(EnumSet<AddFlag> flags, Header header) {
                return innerHeaders(flags, AList.of(header));
        }
diff --git 
a/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock2/MockRestClientBuilder.java
 
b/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock2/MockRestClientBuilder.java
index d5389d4..3455455 100644
--- 
a/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock2/MockRestClientBuilder.java
+++ 
b/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock2/MockRestClientBuilder.java
@@ -892,8 +892,8 @@ public class MockRestClientBuilder extends 
RestClientBuilder {
        }
 
        @Override /* GENERATED - RestClientBuilder */
-       public MockRestClientBuilder formData(String name, Object value, 
HttpPartSerializer serializer, HttpPartSchema schema) {
-               super.formData(name, value, serializer, schema);
+       public MockRestClientBuilder formData(String name, Object value, 
HttpPartSchema schema, HttpPartSerializer serializer) {
+               super.formData(name, value, schema, serializer);
                return this;
        }
 
@@ -934,8 +934,8 @@ public class MockRestClientBuilder extends 
RestClientBuilder {
        }
 
        @Override /* GENERATED - RestClientBuilder */
-       public MockRestClientBuilder header(String name, Object value, 
HttpPartSerializer serializer, HttpPartSchema schema) {
-               super.header(name, value, serializer, schema);
+       public MockRestClientBuilder header(String name, Object value, 
HttpPartSchema schema, HttpPartSerializer serializer) {
+               super.header(name, value, schema, serializer);
                return this;
        }
 
@@ -1308,8 +1308,8 @@ public class MockRestClientBuilder extends 
RestClientBuilder {
        }
 
        @Override /* GENERATED - RestClientBuilder */
-       public MockRestClientBuilder query(String name, Object value, 
HttpPartSerializer serializer, HttpPartSchema schema) {
-               super.query(name, value, serializer, schema);
+       public MockRestClientBuilder query(String name, Object value, 
HttpPartSchema schema, HttpPartSerializer serializer) {
+               super.query(name, value, schema, serializer);
                return this;
        }
 

Reply via email to