001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.http;
018
019import static org.apache.juneau.commons.utils.ThrowableUtils.*;
020import static org.apache.juneau.commons.utils.Utils.*;
021
022import java.net.*;
023import java.time.*;
024import java.util.*;
025import java.util.function.*;
026
027import org.apache.http.*;
028import org.apache.juneau.*;
029import org.apache.juneau.commons.lang.*;
030import org.apache.juneau.commons.reflect.*;
031import org.apache.juneau.http.header.*;
032import org.apache.juneau.http.header.Date;
033import org.apache.juneau.http.part.*;
034import org.apache.juneau.httppart.*;
035import org.apache.juneau.oapi.*;
036
037/**
038 * Standard predefined HTTP headers.
039 *
040 * <h5 class='section'>See Also:</h5><ul>
041 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauRestCommonBasics">juneau-rest-common Basics</a>
042 * </ul>
043 */
044public class HttpHeaders {
045
046   // @formatter:off
047   @SuppressWarnings("javadoc")
048   public static final Accept
049      ACCEPT_APPLICATION_ATOM_XML = Accept.APPLICATION_ATOM_XML,
050      ACCEPT_APPLICATION_FORM_URLENCODED = Accept.APPLICATION_FORM_URLENCODED,
051      ACCEPT_APPLICATION_JSON = Accept.APPLICATION_JSON,
052      ACCEPT_APPLICATION_OCTET_STREAM = Accept.APPLICATION_OCTET_STREAM,
053      ACCEPT_APPLICATION_SOAP_XML = Accept.APPLICATION_SOAP_XML,
054      ACCEPT_APPLICATION_SVG_XML = Accept.APPLICATION_SVG_XML,
055      ACCEPT_APPLICATION_XHTML_XML = Accept.APPLICATION_XHTML_XML,
056      ACCEPT_APPLICATION_XML = Accept.APPLICATION_XML,
057      ACCEPT_IMAGE_BMP = Accept.IMAGE_BMP,
058      ACCEPT_IMAGE_GIF = Accept.IMAGE_GIF,
059      ACCEPT_IMAGE_JPEG = Accept.IMAGE_JPEG,
060      ACCEPT_IMAGE_PNG = Accept.IMAGE_PNG,
061      ACCEPT_IMAGE_SVG = Accept.IMAGE_SVG,
062      ACCEPT_IMAGE_TIFF = Accept.IMAGE_TIFF,
063      ACCEPT_IMAGE_WEBP = Accept.IMAGE_WEBP,
064      ACCEPT_MULTIPART_FORM_DATA = Accept.MULTIPART_FORM_DATA,
065      ACCEPT_TEXT_HTML = Accept.TEXT_HTML,
066      ACCEPT_TEXT_PLAIN = Accept.TEXT_PLAIN,
067      ACCEPT_TEXT_XML = Accept.TEXT_XML,
068      ACCEPT_WILDCARD = Accept.WILDCARD;
069
070   @SuppressWarnings("javadoc")
071   public static final ContentType
072      CONTENTTYPE_APPLICATION_ATOM_XML = ContentType.APPLICATION_ATOM_XML,
073      CONTENTTYPE_APPLICATION_FORM_URLENCODED = ContentType.APPLICATION_FORM_URLENCODED,
074      CONTENTTYPE_APPLICATION_JSON = ContentType.APPLICATION_JSON,
075      CONTENTTYPE_APPLICATION_OCTET_STREAM = ContentType.APPLICATION_OCTET_STREAM,
076      CONTENTTYPE_APPLICATION_SOAP_XML = ContentType.APPLICATION_SOAP_XML,
077      CONTENTTYPE_APPLICATION_SVG_XML = ContentType.APPLICATION_SVG_XML,
078      CONTENTTYPE_APPLICATION_XHTML_XML = ContentType.APPLICATION_XHTML_XML,
079      CONTENTTYPE_APPLICATION_XML = ContentType.APPLICATION_XML,
080      CONTENTTYPE_IMAGE_BMP = ContentType.IMAGE_BMP,
081      CONTENTTYPE_IMAGE_GIF = ContentType.IMAGE_GIF,
082      CONTENTTYPE_IMAGE_JPEG = ContentType.IMAGE_JPEG,
083      CONTENTTYPE_IMAGE_PNG = ContentType.IMAGE_PNG,
084      CONTENTTYPE_IMAGE_SVG = ContentType.IMAGE_SVG,
085      CONTENTTYPE_IMAGE_TIFF = ContentType.IMAGE_TIFF,
086      CONTENTTYPE_IMAGE_WEBP = ContentType.IMAGE_WEBP,
087      CONTENTTYPE_MULTIPART_FORM_DATA = ContentType.MULTIPART_FORM_DATA,
088      CONTENTTYPE_TEXT_HTML = ContentType.TEXT_HTML,
089      CONTENTTYPE_TEXT_PLAIN = ContentType.TEXT_PLAIN,
090      CONTENTTYPE_TEXT_XML = ContentType.TEXT_XML,
091      CONTENTTYPE_WILDCARD = ContentType.WILDCARD;
092   // @formatter:on
093
094   /**
095    * Creates a new {@link Accept} header.
096    *
097    * @param value
098    *    The header value.
099    *    <br>Can be <jk>null</jk>.
100    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
101    */
102   public static final Accept accept(MediaRanges value) {
103      return Accept.of(value);
104   }
105
106   /**
107    * Creates a new {@link Accept} header.
108    *
109    * @param value
110    *    The header value.
111    *    <br>Can be <jk>null</jk>.
112    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
113    */
114   public static final Accept accept(MediaType value) {
115      return Accept.of(value);
116   }
117
118   /**
119    * Creates a new {@link Accept} header.
120    *
121    * @param value
122    *    The header value.
123    *    <br>Must be parsable by {@link MediaRanges#of(String)}.
124    *    <br>Can be <jk>null</jk>.
125    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
126    */
127   public static final Accept accept(String value) {
128      return Accept.of(value);
129   }
130
131   /**
132    * Creates a new {@link Accept} header with a delayed value.
133    *
134    * <p>
135    * Header value is re-evaluated on each call to {@link Header#getValue()}.
136    *
137    * @param value
138    *    The header value.
139    *    <br>Can be <jk>null</jk>.
140    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
141    */
142   public static final Accept accept(Supplier<MediaRanges> value) {
143      return Accept.of(value);
144   }
145
146   /**
147    * Creates a new {@link AcceptCharset} header.
148    *
149    * @param value
150    *    The header value.
151    *    <br>Must be parsable by {@link StringRanges#of(String)}.
152    *    <br>Can be <jk>null</jk>.
153    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
154    */
155   public static final AcceptCharset acceptCharset(String value) {
156      return AcceptCharset.of(value);
157   }
158
159   /**
160    * Creates a new {@link AcceptCharset} header.
161    *
162    * @param value
163    *    The header value.
164    *    <br>Can be <jk>null</jk>.
165    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
166    */
167   public static final AcceptCharset acceptCharset(StringRanges value) {
168      return AcceptCharset.of(value);
169   }
170
171   /**
172    * Creates a new {@link AcceptCharset} header with a delayed value.
173    *
174    * <p>
175    * Header value is re-evaluated on each call to {@link Header#getValue()}.
176    *
177    * @param value
178    *    The supplier of the header value.
179    *    <br>Can be <jk>null</jk>.
180    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
181    */
182   public static final AcceptCharset acceptCharset(Supplier<StringRanges> value) {
183      return AcceptCharset.of(value);
184   }
185
186   /**
187    * Creates a new {@link AcceptEncoding} header.
188    *
189    * @param value
190    *    The header value.
191    *    <br>Must be parsable by {@link StringRanges#of(String)}.
192    *    <br>Can be <jk>null</jk>.
193    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
194    */
195   public static final AcceptEncoding acceptEncoding(String value) {
196      return AcceptEncoding.of(value);
197   }
198
199   /**
200    * Creates a new {@link AcceptEncoding} header.
201    *
202    * @param value
203    *    The header value.
204    *    <br>Can be <jk>null</jk>.
205    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
206    */
207   public static final AcceptEncoding acceptEncoding(StringRanges value) {
208      return AcceptEncoding.of(value);
209   }
210
211   /**
212    * Creates a new {@link AcceptEncoding} header with a delayed value.
213    *
214    * <p>
215    * Header value is re-evaluated on each call to {@link Header#getValue()}.
216    *
217    * @param value
218    *    The supplier of the header value.
219    *    <br>Can be <jk>null</jk>.
220    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
221    */
222   public static final AcceptEncoding acceptEncoding(Supplier<StringRanges> value) {
223      return AcceptEncoding.of(value);
224   }
225
226   /**
227    * Creates a new {@link AcceptLanguage} header.
228    *
229    * @param value
230    *    The header value.
231    *    <br>Must be parsable by {@link StringRanges#of(String)}.
232    *    <br>Can be <jk>null</jk>.
233    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
234    */
235   public static final AcceptLanguage acceptLanguage(String value) {
236      return AcceptLanguage.of(value);
237   }
238
239   /**
240    * Creates a new {@link AcceptLanguage} header.
241    *
242    * @param value
243    *    The header value.
244    *    <br>Can be <jk>null</jk>.
245    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
246    */
247   public static final AcceptLanguage acceptLanguage(StringRanges value) {
248      return AcceptLanguage.of(value);
249   }
250
251   /**
252    * Creates a new {@link AcceptLanguage} header with a delayed value.
253    *
254    * <p>
255    * Header value is re-evaluated on each call to {@link Header#getValue()}.
256    *
257    * @param value
258    *    The supplier of the header value.
259    *    <br>Can be <jk>null</jk>.
260    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
261    */
262   public static final AcceptLanguage acceptLanguage(Supplier<StringRanges> value) {
263      return AcceptLanguage.of(value);
264   }
265
266   /**
267    * Creates a new {@link AcceptRanges} header.
268    *
269    * @param value
270    *    The header value.
271    *    <br>Can be <jk>null</jk>.
272    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
273    */
274   public static final AcceptRanges acceptRanges(String value) {
275      return AcceptRanges.of(value);
276   }
277
278   /**
279    * Creates a new {@link AcceptRanges} header with a delayed value.
280    *
281    * <p>
282    * Header value is re-evaluated on each call to {@link Header#getValue()}.
283    *
284    * @param value
285    *    The supplier of the header value.
286    *    <br>Can be <jk>null</jk>.
287    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
288    */
289   public static final AcceptRanges acceptRanges(Supplier<String> value) {
290      return AcceptRanges.of(value);
291   }
292
293   /**
294    * Creates a new {@link Age} header.
295    *
296    * @param value
297    *    The header value.
298    *    <br>Can be <jk>null</jk>.
299    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
300    */
301   public static final Age age(Integer value) {
302      return Age.of(value);
303   }
304
305   /**
306    * Creates a new {@link Age} header.
307    *
308    * @param value
309    *    The header value.
310    *    <br>Must be parsable using {@link Integer#parseInt(String)}.
311    *    <br>Can be <jk>null</jk>.
312    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
313    */
314   public static final Age age(String value) {
315      return Age.of(value);
316   }
317
318   /**
319    * Creates a new {@link Age} header with a delayed value.
320    *
321    * <p>
322    * Header value is re-evaluated on each call to {@link Header#getValue()}.
323    *
324    * @param value
325    *    The supplier of the header value.
326    *    <br>Can be <jk>null</jk>.
327    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
328    */
329   public static final Age age(Supplier<Integer> value) {
330      return Age.of(value);
331   }
332
333   /**
334    * Creates a new {@link Allow} header.
335    *
336    * @param value
337    *    The header value.
338    *    <br>Can be <jk>null</jk>.
339    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
340    */
341   public static final Allow allow(String value) {
342      return Allow.of(value);
343   }
344
345   /**
346    * Creates a new {@link Allow} header.
347    *
348    * @param value
349    *    The header value.
350    *    <br>Can be <jk>null</jk>.
351    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
352    */
353   public static final Allow allow(String...value) {
354      return Allow.of(value);
355   }
356
357   /**
358    * Creates a new {@link Allow} header with a delayed value.
359    *
360    * <p>
361    * Header value is re-evaluated on each call to {@link Header#getValue()}.
362    *
363    * @param value
364    *    The supplier of the header value.
365    *    <br>Can be <jk>null</jk>.
366    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
367    */
368   public static final Allow allow(Supplier<String[]> value) {
369      return Allow.of(value);
370   }
371
372   /**
373    * Creates a new {@link Authorization} header.
374    *
375    * @param value
376    *    The header value.
377    *    <br>Can be <jk>null</jk>.
378    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
379    */
380   public static final Authorization authorization(String value) {
381      return Authorization.of(value);
382   }
383
384   /**
385    * Creates a new {@link Authorization} header with a delayed value.
386    *
387    * <p>
388    * Header value is re-evaluated on each call to {@link Header#getValue()}.
389    *
390    * @param value
391    *    The supplier of the header value.
392    *    <br>Can be <jk>null</jk>.
393    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
394    */
395   public static final Authorization authorization(Supplier<String> value) {
396      return Authorization.of(value);
397   }
398
399   /**
400    * Creates a new {@link BasicHeader} header.
401    *
402    * @param name The parameter name.
403    * @param value
404    *    The parameter value.
405    *    <br>Can be <jk>null</jk>.
406    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
407    */
408   public static final BasicHeader basicHeader(String name, Object value) {
409      return BasicHeader.of(name, value);
410   }
411
412   /**
413    * Creates a new {@link BasicHeader} header with a delayed value.
414    *
415    * <p>
416    * Header value is re-evaluated on each call to {@link Header#getValue()}.
417    *
418    * @param name The header name.
419    * @param value
420    *    The supplier of the header value.
421    *    <br>Can be <jk>null</jk>.
422    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
423    * */
424   public static final BasicHeader basicHeader(String name, Supplier<?> value) {
425      return new BasicHeader(name, value);
426   }
427
428   /**
429    * Creates a new {@link BasicBooleanHeader} header.
430    *
431    * @param name The header name.
432    * @param value
433    *    The header value.
434    *    <br>Can be <jk>null</jk>.
435    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
436    */
437   public static final BasicBooleanHeader booleanHeader(String name, Boolean value) {
438      return BasicBooleanHeader.of(name, value);
439   }
440
441   /**
442    * Creates a new {@link BasicBooleanHeader} header.
443    *
444    * @param name The header name.
445    * @param value
446    *    The header value.
447    *    <br>Must be parsable by {@link Boolean#parseBoolean(String)}.
448    *    <br>Can be <jk>null</jk>.
449    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
450    */
451   public static final BasicBooleanHeader booleanHeader(String name, String value) {
452      return BasicBooleanHeader.of(name, value);
453   }
454
455   /**
456    * Creates a new {@link BasicBooleanHeader} header with a delayed value.
457    *
458    * <p>
459    * Header value is re-evaluated on each call to {@link Header#getValue()}.
460    *
461    * @param name The header name.
462    * @param value
463    *    The supplier of the header value.
464    *    <br>Can be <jk>null</jk>.
465    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
466    */
467   public static final BasicBooleanHeader booleanHeader(String name, Supplier<Boolean> value) {
468      return BasicBooleanHeader.of(name, value);
469   }
470
471   /**
472    * Creates a new {@link CacheControl} header.
473    *
474    * @param value
475    *    The header value.
476    *    <br>Can be <jk>null</jk>.
477    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
478    */
479   public static final CacheControl cacheControl(String value) {
480      return CacheControl.of(value);
481   }
482
483   /**
484    * Creates a new {@link CacheControl} header with a delayed value.
485    *
486    * <p>
487    * Header value is re-evaluated on each call to {@link Header#getValue()}.
488    *
489    * @param value
490    *    The supplier of the header value.
491    *    <br>Can be <jk>null</jk>.
492    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
493    */
494   public static final CacheControl cacheControl(Supplier<String> value) {
495      return CacheControl.of(value);
496   }
497
498   /**
499    * Returns <jk>true</jk> if the {@link #cast(Object)} method can be used on the specified object.
500    *
501    * @param o The object to check.
502    * @return <jk>true</jk> if the {@link #cast(Object)} method can be used on the specified object.
503    */
504   public static boolean canCast(Object o) {
505      if (o == null)
506         return false;
507      var ci = ClassInfo.of(o);
508      return nn(ci) && ci.isChildOfAny(Header.class, Headerable.class, NameValuePair.class, NameValuePairable.class, Map.Entry.class);
509   }
510
511   /**
512    * Utility method for converting an arbitrary object to a {@link Header}.
513    *
514    * @param o
515    *    The object to cast or convert to a {@link Header}.
516    * @return Either the same object cast as a {@link Header} or converted to a {@link Header}.
517   */
518   public static Header cast(Object o) {
519      if (o instanceof Header o2)
520         return o2;
521   if (o instanceof Headerable o3)
522      return o3.asHeader();
523   if (o instanceof NameValuePair o4)
524      return BasicHeader.of(o4);
525   if (o instanceof NameValuePairable o5)
526      return BasicHeader.of(o5.asNameValuePair());
527      if (o instanceof Map.Entry e) {
528         return BasicHeader.of(s(e.getKey()), s(e.getValue()));
529      }
530      throw rex("Object of type {0} could not be converted to a Header.", cn(o));
531   }
532
533   /**
534    * Creates a new {@link ClientVersion} header.
535    *
536    * @param value
537    *    The header value.
538    *    <br>Must be parsable by {@link Version#of(String)}
539    *    <br>Can be <jk>null</jk>.
540    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
541    */
542   public static final ClientVersion clientVersion(String value) {
543      return ClientVersion.of(value);
544   }
545
546   /**
547    * Creates a new {@link ClientVersion} header with a delayed value.
548    *
549    * <p>
550    * Header value is re-evaluated on each call to {@link Header#getValue()}.
551    *
552    * @param value
553    *    The supplier of the header value.
554    *    <br>Can be <jk>null</jk>.
555    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
556    */
557   public static final ClientVersion clientVersion(Supplier<Version> value) {
558      return ClientVersion.of(value);
559   }
560
561   /**
562    * Creates a new {@link ClientVersion} header.
563    *
564    * @param value
565    *    The header value.
566    *    <br>Can be <jk>null</jk>.
567    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
568    */
569   public static final ClientVersion clientVersion(Version value) {
570      return ClientVersion.of(value);
571   }
572
573   /**
574    * Creates a new {@link Connection} header.
575    *
576    * @param value
577    *    The header value.
578    *    <br>Can be <jk>null</jk>.
579    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
580    */
581   public static final Connection connection(String value) {
582      return Connection.of(value);
583   }
584
585   /**
586    * Creates a new {@link Connection} header with a delayed value.
587    *
588    * <p>
589    * Header value is re-evaluated on each call to {@link Header#getValue()}.
590    *
591    * @param value
592    *    The supplier of the header value.
593    *    <br>Can be <jk>null</jk>.
594    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
595    */
596   public static final Connection connection(Supplier<String> value) {
597      return Connection.of(value);
598   }
599
600   /**
601    * Creates a new {@link ContentDisposition} header.
602    *
603    * @param value
604    *    The header value.
605    *    <br>Must be parsable by {@link StringRanges#of(String)}.
606    *    <br>Can be <jk>null</jk>.
607    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
608    */
609   public static final ContentDisposition contentDisposition(String value) {
610      return ContentDisposition.of(value);
611   }
612
613   /**
614    * Creates a new {@link ContentDisposition} header.
615    *
616    * @param value
617    *    The header value.
618    *    <br>Can be <jk>null</jk>.
619    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
620    */
621   public static final ContentDisposition contentDisposition(StringRanges value) {
622      return ContentDisposition.of(value);
623   }
624
625   /**
626    * Creates a new {@link ContentDisposition} header with a delayed value.
627    *
628    * <p>
629    * Header value is re-evaluated on each call to {@link Header#getValue()}.
630    *
631    * @param value
632    *    The supplier of the header value.
633    *    <br>Can be <jk>null</jk>.
634    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
635    */
636   public static final ContentDisposition contentDisposition(Supplier<StringRanges> value) {
637      return ContentDisposition.of(value);
638   }
639
640   /**
641    * Creates a new {@link ContentEncoding} header.
642    *
643    * @param value
644    *    The header value.
645    *    <br>Can be <jk>null</jk>.
646    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
647    */
648   public static final ContentEncoding contentEncoding(String value) {
649      return ContentEncoding.of(value);
650   }
651
652   /**
653    * Creates a new {@link ContentEncoding} header with a delayed value.
654    *
655    * <p>
656    * Header value is re-evaluated on each call to {@link Header#getValue()}.
657    *
658    * @param value
659    *    The supplier of the header value.
660    *    <br>Can be <jk>null</jk>.
661    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
662    */
663   public static final ContentEncoding contentEncoding(Supplier<String> value) {
664      return ContentEncoding.of(value);
665   }
666
667   /**
668    * Creates a new {@link ContentLanguage} header.
669    *
670    * @param value
671    *    The header value.
672    *    <br>Can be <jk>null</jk>.
673    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
674    */
675   public static final ContentLanguage contentLanguage(String value) {
676      return ContentLanguage.of(value);
677   }
678
679   /**
680    * Creates a new {@link ContentLanguage} header.
681    *
682    * @param value
683    *    The header value.
684    *    <br>Can be <jk>null</jk>.
685    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
686    */
687   public static final ContentLanguage contentLanguage(String...value) {
688      return ContentLanguage.of(value);
689   }
690
691   /**
692    * Creates a new {@link ContentLanguage} header with a delayed value.
693    *
694    * <p>
695    * Header value is re-evaluated on each call to {@link Header#getValue()}.
696    *
697    * @param value
698    *    The supplier of the header value.
699    *    <br>Can be <jk>null</jk>.
700    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
701    */
702   public static final ContentLanguage contentLanguage(Supplier<String[]> value) {
703      return ContentLanguage.of(value);
704   }
705
706   /**
707    * Creates a new {@link ContentLength} header.
708    *
709    * @param value
710    *    The header value.
711    *    <br>Can be <jk>null</jk>.
712    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
713    */
714   public static final ContentLength contentLength(Long value) {
715      return ContentLength.of(value);
716   }
717
718   /**
719    * Creates a new {@link ContentLength} header.
720    *
721    * @param value
722    *    The header value.
723    *    <br>Must be parsable using {@link Long#parseLong(String)}.
724    *    <br>Can be <jk>null</jk>.
725    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
726    */
727   public static final ContentLength contentLength(String value) {
728      return ContentLength.of(value);
729   }
730
731   /**
732    * Creates a new {@link ContentLength} header with a delayed value.
733    *
734    * <p>
735    * Header value is re-evaluated on each call to {@link Header#getValue()}.
736    *
737    * @param value
738    *    The supplier of the header value.
739    *    <br>Can be <jk>null</jk>.
740    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
741    */
742   public static final ContentLength contentLength(Supplier<Long> value) {
743      return ContentLength.of(value);
744   }
745
746   /**
747    * Creates a new {@link ContentLocation} header.
748    *
749    * @param value
750    *    The header value.
751    *    <br>Must be parsable by {@link URI#create(String)}.
752    *    <br>Can be <jk>null</jk>.
753    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
754    */
755   public static final ContentLocation contentLocation(String value) {
756      return ContentLocation.of(value);
757   }
758
759   /**
760    * Creates a new {@link ContentLocation} header with a delayed value.
761    *
762    * <p>
763    * Header value is re-evaluated on each call to {@link Header#getValue()}.
764    *
765    * @param value
766    *    The supplier of the header value.
767    *    <br>Can be <jk>null</jk>.
768    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
769    */
770   public static final ContentLocation contentLocation(Supplier<URI> value) {
771      return ContentLocation.of(value);
772   }
773
774   /**
775    * Creates a new {@link ContentLocation} header.
776    *
777    * @param value
778    *    The header value.
779    *    <br>Can be <jk>null</jk>.
780    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
781    */
782   public static final ContentLocation contentLocation(URI value) {
783      return ContentLocation.of(value);
784   }
785
786   /**
787    * Creates a new {@link ContentRange} header.
788    *
789    * @param value
790    *    The header value.
791    *    <br>Can be <jk>null</jk>.
792    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
793    */
794   public static final ContentRange contentRange(String value) {
795      return ContentRange.of(value);
796   }
797
798   /**
799    * Creates a new {@link ContentRange} header with a delayed value.
800    *
801    * <p>
802    * Header value is re-evaluated on each call to {@link Header#getValue()}.
803    *
804    * @param value
805    *    The supplier of the header value.
806    *    <br>Can be <jk>null</jk>.
807    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
808    */
809   public static final ContentRange contentRange(Supplier<String> value) {
810      return ContentRange.of(value);
811   }
812
813   /**
814    * Creates a new {@link ContentType} header.
815    *
816    * @param value
817    *    The header value.
818    *    <br>Can be <jk>null</jk>.
819    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
820    */
821   public static final ContentType contentType(MediaType value) {
822      return ContentType.of(value);
823   }
824
825   /**
826    * Creates a new {@link ContentType} header.
827    *
828    * @param value
829    *    The header value.
830    *    <br>Must be parsable by {@link MediaType#of(String)}.
831    *    <br>Can be <jk>null</jk>.
832    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
833    */
834   public static final ContentType contentType(String value) {
835      return ContentType.of(value);
836   }
837
838   /**
839    * Creates a new {@link ContentType} header with a delayed value.
840    *
841    * <p>
842    * Header value is re-evaluated on each call to {@link Header#getValue()}.
843    *
844    * @param value
845    *    The header value.
846    *    <br>Can be <jk>null</jk>.
847    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
848    */
849   public static final ContentType contentType(Supplier<MediaType> value) {
850      return ContentType.of(value);
851   }
852
853   /**
854    * Creates a new {@link BasicCsvHeader} header.
855    *
856    * @param name The header name.
857    * @param value
858    *    The header value.
859    *    <br>Must be a comma-delimited list.
860    *    <br>Can be <jk>null</jk>.
861    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
862    */
863   public static final BasicCsvHeader csvHeader(String name, String value) {
864      return BasicCsvHeader.of(name, value);
865   }
866
867   /**
868    * Creates a new {@link BasicCsvHeader} header.
869    *
870    * @param name The header name.
871    * @param value
872    *    The header value.
873    *    <br>Can be <jk>null</jk>.
874    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
875    */
876   public static final BasicCsvHeader csvHeader(String name, String...value) {
877      return BasicCsvHeader.of(name, value);
878   }
879
880   /**
881    * Creates a new {@link BasicCsvHeader} header with a delayed value.
882    *
883    * <p>
884    * Header value is re-evaluated on each call to {@link Header#getValue()}.
885    *
886    * @param name The header name.
887    * @param value
888    *    The supplier of the header value.
889    *    <br>Can be <jk>null</jk>.
890    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
891    */
892   public static final BasicCsvHeader csvHeader(String name, Supplier<String[]> value) {
893      return BasicCsvHeader.of(name, value);
894   }
895
896   /**
897    * Creates a new {@link Date} header.
898    *
899    * @param value
900    *    The header value.
901    *    <br>Must be an RFC-1123 formated string (e.g. <js>"Sat, 29 Oct 1994 19:43:31 GMT"</js>).
902    *    <br>Can be <jk>null</jk>.
903    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
904    */
905   public static final Date date(String value) {
906      return Date.of(value);
907   }
908
909   /**
910    * Creates a new {@link Date} header with a delayed value.
911    *
912    * <p>
913    * Header value is re-evaluated on each call to {@link Header#getValue()}.
914    *
915    * @param value
916    *    The supplier of the header value.
917    *    <br>Can be <jk>null</jk>.
918    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
919    */
920   public static final Date date(Supplier<ZonedDateTime> value) {
921      return Date.of(value);
922   }
923
924   /**
925    * Creates a new {@link Date} header.
926    *
927    * @param value
928    *    The header value.
929    *    <br>Can be <jk>null</jk>.
930    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
931    */
932   public static final Date date(ZonedDateTime value) {
933      return Date.of(value);
934   }
935
936   /**
937    * Creates a new {@link BasicDateHeader} header.
938    *
939    * @param name The header name.
940    * @param value
941    *    The header value.
942    *    <br>Must be an RFC-1123 formated string (e.g. <js>"Sat, 29 Oct 1994 19:43:31 GMT"</js>).
943    *    <br>Can be <jk>null</jk>.
944    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
945    */
946   public static final BasicDateHeader dateHeader(String name, String value) {
947      return BasicDateHeader.of(name, value);
948   }
949
950   /**
951    * Creates a new {@link BasicDateHeader} header with a delayed value.
952    *
953    * <p>
954    * Header value is re-evaluated on each call to {@link Header#getValue()}.
955    *
956    * @param name The header name.
957    * @param value
958    *    The supplier of the header value.
959    *    <br>Can be <jk>null</jk>.
960    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
961    */
962   public static final BasicDateHeader dateHeader(String name, Supplier<ZonedDateTime> value) {
963      return BasicDateHeader.of(name, value);
964   }
965
966   /**
967    * Creates a new {@link BasicDateHeader} header.
968    *
969    * @param name The header name.
970    * @param value
971    *    The header value.
972    *    <br>Can be <jk>null</jk>.
973    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
974    */
975   public static final BasicDateHeader dateHeader(String name, ZonedDateTime value) {
976      return BasicDateHeader.of(name, value);
977   }
978
979   /**
980    * Creates a new {@link Debug} header.
981    *
982    * @param value
983    *    The header value.
984    *    <br>Must be parsable by {@link Boolean#parseBoolean(String)}.
985    *    <br>Can be <jk>null</jk>.
986    * @return A new header bean, or <jk>null</jk> if the value was <jk>null</jk>.
987    */
988   public static final Debug debug(Boolean value) {
989      return Debug.of(value);
990   }
991
992   /**
993    * Creates a new {@link Debug} header.
994    *
995    * @param value
996    *    The header value.
997    *    <br>Must be parsable by {@link Boolean#parseBoolean(String)}.
998    *    <br>Can be <jk>null</jk>.
999    * @return A new header bean, or <jk>null</jk> if the value was <jk>null</jk>.
1000    */
1001   public static final Debug debug(String value) {
1002      return Debug.of(value);
1003   }
1004
1005   /**
1006    * Creates a new {@link Debug} header with a delayed value.
1007    *
1008    * <p>
1009    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1010    *
1011    * @param value
1012    *    The header value supplier.
1013    *    <br>Can be <jk>null</jk>.
1014    * @return A new header bean, or <jk>null</jk> if the value was <jk>null</jk>.
1015    */
1016   public static final Debug debug(Supplier<Boolean> value) {
1017      return Debug.of(value);
1018   }
1019
1020   /**
1021    * Creates a new {@link BasicEntityTagHeader} header.
1022    *
1023    * @param name The header name.
1024    * @param value
1025    *    The header value.
1026    *    <br>Can be <jk>null</jk>.
1027    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1028    */
1029   public static final BasicEntityTagHeader entityTagHeader(String name, EntityTag value) {
1030      return BasicEntityTagHeader.of(name, value);
1031   }
1032
1033   /**
1034    * Creates a new {@link BasicEntityTagHeader} header.
1035    *
1036    * @param name The header name.
1037    * @param value
1038    *    The header value.
1039    *    <br>Must be an entity tag value (e.g. <js>"\"xyzzy\""</js>).
1040    *    <br>Can be <jk>null</jk>.
1041    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1042    */
1043   public static final BasicEntityTagHeader entityTagHeader(String name, String value) {
1044      return BasicEntityTagHeader.of(name, value);
1045   }
1046
1047   /**
1048    * Creates a new {@link BasicEntityTagHeader} header with a delayed value.
1049    *
1050    * <p>
1051    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1052    *
1053    * @param name The header name.
1054    * @param value
1055    *    The supplier of the header value.
1056    *    <br>Can be <jk>null</jk>.
1057    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1058    */
1059   public static final BasicEntityTagHeader entityTagHeader(String name, Supplier<EntityTag> value) {
1060      return BasicEntityTagHeader.of(name, value);
1061   }
1062
1063   /**
1064    * Creates a new {@link BasicEntityTagsHeader} header.
1065    *
1066    * @param name The header name.
1067    * @param value
1068    *    The header value.
1069    *    <br>Can be <jk>null</jk>.
1070    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1071    */
1072   public static final BasicEntityTagsHeader entityTagsHeader(String name, EntityTags value) {
1073      return BasicEntityTagsHeader.of(name, value);
1074   }
1075
1076   /**
1077    * Creates a new {@link BasicEntityTagsHeader} header.
1078    *
1079    * @param name The header name.
1080    * @param value
1081    *    The header value.
1082    *    <br>Must be a comma-delimited list of entity validator values (e.g. <js>"\"xyzzy\", \"r2d2xxxx\", \"c3piozzzz\""</js>).
1083    *    <br>Can be <jk>null</jk>.
1084    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1085    */
1086   public static final BasicEntityTagsHeader entityTagsHeader(String name, String value) {
1087      return BasicEntityTagsHeader.of(name, value);
1088   }
1089
1090   /**
1091    * Creates a new {@link BasicEntityTagsHeader} header with a delayed value.
1092    *
1093    * <p>
1094    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1095    *
1096    * @param name The header name.
1097    * @param value
1098    *    The supplier of the header value.
1099    *    <br>Can be <jk>null</jk>.
1100    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1101    */
1102   public static final BasicEntityTagsHeader entityTagsHeader(String name, Supplier<EntityTags> value) {
1103      return BasicEntityTagsHeader.of(name, value);
1104   }
1105
1106   /**
1107    * Creates a new {@link ETag} header.
1108    *
1109    * @param value
1110    *    The header value.
1111    *    <br>Can be <jk>null</jk>.
1112    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1113    */
1114   public static final ETag eTag(EntityTag value) {
1115      return ETag.of(value);
1116   }
1117
1118   /**
1119    * Creates a new {@link ETag} header.
1120    *
1121    * @param value
1122    *    The header value.
1123    *    <br>Must be an entity tag value (e.g. <js>"\"xyzzy\""</js>).
1124    *    <br>Can be <jk>null</jk>.
1125    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1126    */
1127   public static final ETag eTag(String value) {
1128      return ETag.of(value);
1129   }
1130
1131   /**
1132    * Creates a new {@link ETag} header with a delayed value.
1133    *
1134    * <p>
1135    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1136    *
1137    * @param value
1138    *    The supplier of the header value.
1139    *    <br>Can be <jk>null</jk>.
1140    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1141    */
1142   public static final ETag eTag(Supplier<EntityTag> value) {
1143      return ETag.of(value);
1144   }
1145
1146   /**
1147    * Creates a new {@link Expect} header.
1148    *
1149    * @param value
1150    *    The header value.
1151    *    <br>Can be <jk>null</jk>.
1152    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1153    */
1154   public static final Expect expect(String value) {
1155      return Expect.of(value);
1156   }
1157
1158   /**
1159    * Creates a new {@link Expect} header with a delayed value.
1160    *
1161    * <p>
1162    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1163    *
1164    * @param value
1165    *    The supplier of the header value.
1166    *    <br>Can be <jk>null</jk>.
1167    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1168    */
1169   public static final Expect expect(Supplier<String> value) {
1170      return Expect.of(value);
1171   }
1172
1173   /**
1174    * Creates a new {@link Expires} header.
1175    *
1176    * @param value
1177    *    The header value.
1178    *    <br>Must be an RFC-1123 formated string (e.g. <js>"Sat, 29 Oct 1994 19:43:31 GMT"</js>).
1179    *    <br>Can be <jk>null</jk>.
1180    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1181    */
1182   public static final Expires expires(String value) {
1183      return Expires.of(value);
1184   }
1185
1186   /**
1187    * Creates a new {@link Expires} header with a delayed value.
1188    *
1189    * <p>
1190    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1191    *
1192    * @param value
1193    *    The supplier of the header value.
1194    *    <br>Can be <jk>null</jk>.
1195    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1196    */
1197   public static final Expires expires(Supplier<ZonedDateTime> value) {
1198      return Expires.of(value);
1199   }
1200
1201   /**
1202    * Creates a new {@link Expires} header.
1203    *
1204    * @param value
1205    *    The header value.
1206    *    <br>Can be <jk>null</jk>.
1207    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1208    */
1209   public static final Expires expires(ZonedDateTime value) {
1210      return Expires.of(value);
1211   }
1212
1213   /**
1214    * Creates a new {@link Forwarded} header.
1215    *
1216    * @param value
1217    *    The header value.
1218    *    <br>Can be <jk>null</jk>.
1219    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1220    */
1221   public static final Forwarded forwarded(String value) {
1222      return Forwarded.of(value);
1223   }
1224
1225   /**
1226    * Creates a new {@link Forwarded} header with a delayed value.
1227    *
1228    * <p>
1229    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1230    *
1231    * @param value
1232    *    The supplier of the header value.
1233    *    <br>Can be <jk>null</jk>.
1234    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1235    */
1236   public static final Forwarded forwarded(Supplier<String> value) {
1237      return Forwarded.of(value);
1238   }
1239
1240   /**
1241    * Creates a new {@link From} header.
1242    *
1243    * @param value
1244    *    The header value.
1245    *    <br>Can be <jk>null</jk>.
1246    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1247    */
1248   public static final From from(String value) {
1249      return From.of(value);
1250   }
1251
1252   /**
1253    * Creates a new {@link From} header with a delayed value.
1254    *
1255    * <p>
1256    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1257    *
1258    * @param value
1259    *    The supplier of the header value.
1260    *    <br>Can be <jk>null</jk>.
1261    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1262    */
1263   public static final From from(Supplier<String> value) {
1264      return From.of(value);
1265   }
1266
1267   /**
1268    * Creates a new {@link Header} of the specified type.
1269    *
1270    * <p>
1271    * Same as {@link #header(Class, String, Object)} but the header name is pulled from the {@link org.apache.juneau.http.annotation.Header#name() @Header(name)} or
1272    *    {@link org.apache.juneau.http.annotation.Header#value() @Header(value)} annotations.
1273    *
1274    * @param <T> The header implementation class.
1275    * @param type The header implementation class.
1276    * @param value The header value.
1277    * @return A new unmodifiable instance, never <jk>null</jk>.
1278    */
1279   public static final <T extends Header> T header(Class<T> type, Object value) {
1280      return HeaderBeanMeta.of(type).construct(null, value);
1281   }
1282
1283   /**
1284    * Creates a new {@link Header} of the specified type.
1285    *
1286    * <p>
1287    * The implementation class must have a public constructor taking in one of the following argument lists:
1288    * <ul>
1289    *    <li><c><jk>public</jk> X(String <jv>headerValue</jv>)</c>
1290    *    <li><c><jk>public</jk> X(Object <jv>headerValue</jv>)</c>
1291    *    <li><c><jk>public</jk> X(String <jv>headerName</jv>, String <jv>headerValue</jv>)</c>
1292    *    <li><c><jk>public</jk> X(String <jv>headerName</jv>, Object <jv>headerValue</jv>)</c>
1293    * </ul>
1294    *
1295    * @param <T> The header implementation class.
1296    * @param type The header implementation class.
1297    * @param name The header name.
1298    * @param value The header value.
1299    * @return A new unmodifiable instance, never <jk>null</jk>.
1300    */
1301   public static final <T extends Header> T header(Class<T> type, String name, Object value) {
1302      return HeaderBeanMeta.of(type).construct(name, value);
1303   }
1304
1305   /**
1306    * Instantiates a new {@link org.apache.juneau.http.header.HeaderList}.
1307    *
1308    * @return A new empty builder.
1309    */
1310   public static final HeaderList headerList() {
1311      return HeaderList.create();
1312   }
1313
1314   /**
1315    * Creates a new {@link HeaderList} initialized with the specified headers.
1316    *
1317    * @param headers The headers to add to the list.  <jk>null</jk> entries are ignored.
1318    * @return A new unmodifiable instance, never <jk>null</jk>.
1319    */
1320   public static final HeaderList headerList(Header...headers) {
1321      return HeaderList.of(headers);
1322   }
1323
1324   /**
1325    * Creates a new {@link HeaderList} initialized with the specified headers.
1326    *
1327    * @param headers The headers to add to the list.  Can be <jk>null</jk>.  <jk>null</jk> entries are ignored.
1328    * @return A new unmodifiable instance, never <jk>null</jk>.
1329    */
1330   public static final HeaderList headerList(List<Header> headers) {
1331      return HeaderList.of(headers);
1332   }
1333
1334   /**
1335    * Creates a new {@link HeaderList} initialized with the specified name/value pairs.
1336    *
1337    * @param pairs
1338    *    Initial list of pairs.
1339    *    <br>Must be an even number of parameters representing key/value pairs.
1340    * @throws RuntimeException If odd number of parameters were specified.
1341    * @return A new instance.
1342    */
1343   public static HeaderList headerList(String...pairs) {
1344      return HeaderList.ofPairs(pairs);
1345   }
1346
1347   /**
1348    * Creates a new {@link Host} header.
1349    *
1350    * @param value
1351    *    The header value.
1352    *    <br>Can be <jk>null</jk>.
1353    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1354    */
1355   public static final Host host(String value) {
1356      return Host.of(value);
1357   }
1358
1359   /**
1360    * Creates a new {@link Host} header with a delayed value.
1361    *
1362    * <p>
1363    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1364    *
1365    * @param value
1366    *    The supplier of the header value.
1367    *    <br>Can be <jk>null</jk>.
1368    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1369    */
1370   public static final Host host(Supplier<String> value) {
1371      return Host.of(value);
1372   }
1373
1374   /**
1375    * Creates a new {@link IfMatch} header.
1376    *
1377    * @param value
1378    *    The header value.
1379    *    <br>Can be <jk>null</jk>.
1380    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1381    */
1382   public static final IfMatch ifMatch(EntityTags value) {
1383      return IfMatch.of(value);
1384   }
1385
1386   /**
1387    * Creates a new {@link IfMatch} header.
1388    *
1389    * @param value
1390    *    The header value.
1391    *    <br>Must be a comma-delimited list of entity validator values (e.g. <js>"\"xyzzy\", \"r2d2xxxx\", \"c3piozzzz\""</js>).
1392    *    <br>Can be <jk>null</jk>.
1393    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1394    */
1395   public static final IfMatch ifMatch(String value) {
1396      return IfMatch.of(value);
1397   }
1398
1399   /**
1400    * Creates a new {@link IfMatch} header with a delayed value.
1401    *
1402    * <p>
1403    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1404    *
1405    * @param value
1406    *    The supplier of the header value.
1407    *    <br>Can be <jk>null</jk>.
1408    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1409    */
1410   public static final IfMatch ifMatch(Supplier<EntityTags> value) {
1411      return IfMatch.of(value);
1412   }
1413
1414   /**
1415    * Creates a new {@link IfModifiedSince} header.
1416    *
1417    * @param value
1418    *    The header value.
1419    *    <br>Must be an RFC-1123 formated string (e.g. <js>"Sat, 29 Oct 1994 19:43:31 GMT"</js>).
1420    *    <br>Can be <jk>null</jk>.
1421    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1422    */
1423   public static final IfModifiedSince ifModifiedSince(String value) {
1424      return IfModifiedSince.of(value);
1425   }
1426
1427   /**
1428    * Creates a new {@link IfModifiedSince} header with a delayed value.
1429    *
1430    * <p>
1431    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1432    *
1433    * @param value
1434    *    The supplier of the header value.
1435    *    <br>Can be <jk>null</jk>.
1436    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1437    */
1438   public static final IfModifiedSince ifModifiedSince(Supplier<ZonedDateTime> value) {
1439      return IfModifiedSince.of(value);
1440   }
1441
1442   /**
1443    * Creates a new {@link IfModifiedSince} header.
1444    *
1445    * @param value
1446    *    The header value.
1447    *    <br>Can be <jk>null</jk>.
1448    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1449    */
1450   public static final IfModifiedSince ifModifiedSince(ZonedDateTime value) {
1451      return IfModifiedSince.of(value);
1452   }
1453
1454   /**
1455    * Creates a new {@link IfNoneMatch} header.
1456    *
1457    * @param value
1458    *    The header value.
1459    *    <br>Can be <jk>null</jk>.
1460    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1461    */
1462   public static final IfNoneMatch ifNoneMatch(EntityTags value) {
1463      return IfNoneMatch.of(value);
1464   }
1465
1466   /**
1467    * Creates a new {@link IfNoneMatch} header.
1468    *
1469    * @param value
1470    *    The header value.
1471    *    <br>Must be a comma-delimited list of entity validator values (e.g. <js>"\"xyzzy\", \"r2d2xxxx\", \"c3piozzzz\""</js>).
1472    *    <br>Can be <jk>null</jk>.
1473    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1474    */
1475   public static final IfNoneMatch ifNoneMatch(String value) {
1476      return IfNoneMatch.of(value);
1477   }
1478
1479   /**
1480    * Creates a new {@link IfNoneMatch} header with a delayed value.
1481    *
1482    * <p>
1483    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1484    *
1485    * @param value
1486    *    The supplier of the header value.
1487    *    <br>Can be <jk>null</jk>.
1488    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1489    */
1490   public static final IfNoneMatch ifNoneMatch(Supplier<EntityTags> value) {
1491      return IfNoneMatch.of(value);
1492   }
1493
1494   /**
1495    * Creates a new {@link IfRange} header.
1496    *
1497    * @param value
1498    *    The header value.
1499    *    <br>Can be <jk>null</jk>.
1500    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1501    */
1502   public static final IfRange ifRange(EntityTag value) {
1503      return IfRange.of(value);
1504   }
1505
1506   /**
1507    * Creates a new {@link IfRange} header.
1508    *
1509    * @param value
1510    *    The header value.
1511    *    <br>Must be an RFC-1123 formated string (e.g. <js>"Sat, 29 Oct 1994 19:43:31 GMT"</js>).
1512    *    <br>Can be <jk>null</jk>.
1513    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1514    */
1515   public static final IfRange ifRange(String value) {
1516      return IfRange.of(value);
1517   }
1518
1519   /**
1520    * Creates a new {@link IfRange} header with a delayed value.
1521    *
1522    * <p>
1523    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1524    *
1525    * @param value
1526    *    The supplier of the header value.
1527    *    <br>Supplier must supply either {@link EntityTag} or {@link ZonedDateTime} objects.
1528    *    <br>Can be <jk>null</jk>.
1529    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1530    */
1531   public static final IfRange ifRange(Supplier<?> value) {
1532      return IfRange.of(value);
1533   }
1534
1535   /**
1536    * Creates a new {@link IfRange} header.
1537    *
1538    * @param value
1539    *    The header value.
1540    *    <br>Can be <jk>null</jk>.
1541    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1542    */
1543   public static final IfRange ifRange(ZonedDateTime value) {
1544      return IfRange.of(value);
1545   }
1546
1547   /**
1548    * Creates a new {@link IfUnmodifiedSince} header.
1549    *
1550    * @param value
1551    *    The header value.
1552    *    <br>Must be an RFC-1123 formated string (e.g. <js>"Sat, 29 Oct 1994 19:43:31 GMT"</js>).
1553    *    <br>Can be <jk>null</jk>.
1554    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1555    */
1556   public static final IfUnmodifiedSince ifUnmodifiedSince(String value) {
1557      return IfUnmodifiedSince.of(value);
1558   }
1559
1560   /**
1561    * Creates a new {@link IfUnmodifiedSince} header with a delayed value.
1562    *
1563    * <p>
1564    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1565    *
1566    * @param value
1567    *    The supplier of the header value.
1568    *    <br>Can be <jk>null</jk>.
1569    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1570    */
1571   public static final IfUnmodifiedSince ifUnmodifiedSince(Supplier<ZonedDateTime> value) {
1572      return IfUnmodifiedSince.of(value);
1573   }
1574
1575   /**
1576    * Creates a new {@link IfUnmodifiedSince} header.
1577    *
1578    * @param value
1579    *    The header value.
1580    *    <br>Can be <jk>null</jk>.
1581    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1582    */
1583   public static final IfUnmodifiedSince ifUnmodifiedSince(ZonedDateTime value) {
1584      return IfUnmodifiedSince.of(value);
1585   }
1586
1587   /**
1588    * Creates a new {@link BasicIntegerHeader} header.
1589    *
1590    * @param name The header name.
1591    * @param value
1592    *    The header value.
1593    *    <br>Can be <jk>null</jk>.
1594    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1595    */
1596   public static final BasicIntegerHeader integerHeader(String name, Integer value) {
1597      return BasicIntegerHeader.of(name, value);
1598   }
1599
1600   /**
1601    * Creates a new {@link BasicIntegerHeader} header.
1602    *
1603    * @param name The header name.
1604    * @param value
1605    *    The header value.
1606    *    <br>Must be parsable using {@link Integer#parseInt(String)}.
1607    *    <br>Can be <jk>null</jk>.
1608    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1609    */
1610   public static final BasicIntegerHeader integerHeader(String name, String value) {
1611      return BasicIntegerHeader.of(name, value);
1612   }
1613
1614   /**
1615    * Creates a new {@link BasicIntegerHeader} header with a delayed value.
1616    *
1617    * <p>
1618    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1619    *
1620    * @param name The header name.
1621    * @param value
1622    *    The supplier of the header value.
1623    *    <br>Can be <jk>null</jk>.
1624    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1625    */
1626   public static final BasicIntegerHeader integerHeader(String name, Supplier<Integer> value) {
1627      return BasicIntegerHeader.of(name, value);
1628   }
1629
1630   /**
1631    * Creates a new {@link LastModified} header.
1632    *
1633    * @param value
1634    *    The header value.
1635    *    <br>Must be an RFC-1123 formated string (e.g. <js>"Sat, 29 Oct 1994 19:43:31 GMT"</js>).
1636    *    <br>Can be <jk>null</jk>.
1637    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1638    */
1639   public static final LastModified lastModified(String value) {
1640      return LastModified.of(value);
1641   }
1642
1643   /**
1644    * Creates a new {@link LastModified} header with a delayed value.
1645    *
1646    * <p>
1647    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1648    *
1649    * @param value
1650    *    The supplier of the header value.
1651    *    <br>Can be <jk>null</jk>.
1652    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1653    */
1654   public static final LastModified lastModified(Supplier<ZonedDateTime> value) {
1655      return LastModified.of(value);
1656   }
1657
1658   /**
1659    * Creates a new {@link LastModified} header.
1660    *
1661    * @param value
1662    *    The header value.
1663    *    <br>Can be <jk>null</jk>.
1664    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1665    */
1666   public static final LastModified lastModified(ZonedDateTime value) {
1667      return LastModified.of(value);
1668   }
1669
1670   /**
1671    * Creates a new {@link Location} header.
1672    *
1673    * @param value
1674    *    The header value.
1675    *    <br>Must be parsable by {@link URI#create(String)}.
1676    *    <br>Can be <jk>null</jk>.
1677    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1678    */
1679   public static final Location location(String value) {
1680      return Location.of(value);
1681   }
1682
1683   /**
1684    * Creates a new {@link Location} header with a delayed value.
1685    *
1686    * <p>
1687    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1688    *
1689    * @param value
1690    *    The supplier of the header value.
1691    *    <br>Can be <jk>null</jk>.
1692    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1693    */
1694   public static final Location location(Supplier<URI> value) {
1695      return Location.of(value);
1696   }
1697
1698   /**
1699    * Creates a new {@link Location} header.
1700    *
1701    * @param value
1702    *    The header value.
1703    *    <br>Can be <jk>null</jk>.
1704    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1705    */
1706   public static final Location location(URI value) {
1707      return Location.of(value);
1708   }
1709
1710   /**
1711    * Creates a new {@link BasicLongHeader} header.
1712    *
1713    * @param name The header name.
1714    * @param value
1715    *    The header value.
1716    *    <br>Must be parsable by {@link Long#parseLong(String)}.
1717    *    <br>Can be <jk>null</jk>.
1718    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1719    */
1720   public static final BasicLongHeader longHeader(String name, Long value) {
1721      return BasicLongHeader.of(name, value);
1722   }
1723
1724   /**
1725    * Creates a new {@link BasicLongHeader} header.
1726    *
1727    * @param name The header name.
1728    * @param value
1729    *    The header value.
1730    *    <br>Must be parsable by {@link Long#parseLong(String)}.
1731    *    <br>Can be <jk>null</jk>.
1732    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1733    */
1734   public static final BasicLongHeader longHeader(String name, String value) {
1735      return BasicLongHeader.of(name, value);
1736   }
1737
1738   /**
1739    * Creates a new {@link BasicLongHeader} header with a delayed value.
1740    *
1741    * <p>
1742    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1743    *
1744    * @param name The header name.
1745    * @param value
1746    *    The supplier of the header value.
1747    *    <br>Can be <jk>null</jk>.
1748    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1749    */
1750   public static final BasicLongHeader longHeader(String name, Supplier<Long> value) {
1751      return BasicLongHeader.of(name, value);
1752   }
1753
1754   /**
1755    * Creates a new {@link MaxForwards} header.
1756    *
1757    * @param value
1758    *    The header value.
1759    *    <br>Can be <jk>null</jk>.
1760    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1761    */
1762   public static final MaxForwards maxForwards(Integer value) {
1763      return MaxForwards.of(value);
1764   }
1765
1766   /**
1767    * Creates a new {@link MaxForwards} header.
1768    *
1769    * @param value
1770    *    The header value.
1771    *    <br>Must be parsable using {@link Integer#parseInt(String)}.
1772    *    <br>Can be <jk>null</jk>.
1773    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1774    */
1775   public static final MaxForwards maxForwards(String value) {
1776      return MaxForwards.of(value);
1777   }
1778
1779   /**
1780    * Creates a new {@link MaxForwards} header with a delayed value.
1781    *
1782    * <p>
1783    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1784    *
1785    * @param value
1786    *    The supplier of the header value.
1787    *    <br>Can be <jk>null</jk>.
1788    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1789    */
1790   public static final MaxForwards maxForwards(Supplier<Integer> value) {
1791      return MaxForwards.of(value);
1792   }
1793
1794   /**
1795    * Creates a new {@link BasicMediaRangesHeader} header.
1796    *
1797    * @param name The header name.
1798    * @param value
1799    *    The header value.
1800    *    <br>Can be <jk>null</jk>.
1801    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1802    */
1803   public static final BasicMediaRangesHeader mediaRangesHeader(String name, MediaRanges value) {
1804      return BasicMediaRangesHeader.of(name, value);
1805   }
1806
1807   /**
1808    * Creates a new {@link BasicMediaRangesHeader} header.
1809    *
1810    * @param name The header name.
1811    * @param value
1812    *    The header value.
1813    *    <br>Must be parsable by {@link MediaRanges#of(String)}.
1814    *    <br>Can be <jk>null</jk>.
1815    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1816    */
1817   public static final BasicMediaRangesHeader mediaRangesHeader(String name, String value) {
1818      return BasicMediaRangesHeader.of(name, value);
1819   }
1820
1821   /**
1822    * Creates a new {@link BasicMediaRangesHeader} header with a delayed value.
1823    *
1824    * <p>
1825    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1826    *
1827    * @param name The header name.
1828    * @param value
1829    *    The header value.
1830    *    <br>Must be parsable by {@link MediaRanges#of(String)}.
1831    *    <br>Can be <jk>null</jk>.
1832    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1833    */
1834   public static final BasicMediaRangesHeader mediaRangesHeader(String name, Supplier<MediaRanges> value) {
1835      return value == null ? null : new BasicMediaRangesHeader(name, value);
1836   }
1837
1838   /**
1839    * Creates a new {@link BasicMediaTypeHeader} header.
1840    *
1841    * @param name The header name.
1842    * @param value
1843    *    The header value.
1844    *    <br>Can be <jk>null</jk>.
1845    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1846    */
1847   public static final BasicMediaTypeHeader mediaTypeHeader(String name, MediaType value) {
1848      return BasicMediaTypeHeader.of(name, value);
1849   }
1850
1851   /**
1852    * Creates a new {@link BasicMediaTypeHeader} header.
1853    *
1854    * @param name The header name.
1855    * @param value
1856    *    The header value.
1857    *    <br>Must be parsable by {@link MediaType#of(String)}.
1858    *    <br>Can be <jk>null</jk>.
1859    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1860    */
1861   public static final BasicMediaTypeHeader mediaTypeHeader(String name, String value) {
1862      return BasicMediaTypeHeader.of(name, value);
1863   }
1864
1865   /**
1866    * Creates a new {@link BasicMediaTypeHeader} header with a delayed value.
1867    *
1868    * <p>
1869    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1870    *
1871    * @param name The header name.
1872    * @param value
1873    *    The header value.
1874    *    <br>Can be <jk>null</jk>.
1875    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
1876    */
1877   public static final BasicMediaTypeHeader mediaTypeHeader(String name, Supplier<MediaType> value) {
1878      return value == null ? null : new BasicMediaTypeHeader(name, value);
1879   }
1880
1881   /**
1882    * Creates a new {@link NoTrace} header.
1883    *
1884    * @param value
1885    *    The header value.
1886    *    <br>Can be <jk>null</jk>.
1887    * @return A new header bean, or <jk>null</jk> if the value was <jk>null</jk>.
1888    */
1889   public static final NoTrace noTrace(Boolean value) {
1890      return NoTrace.of(value);
1891   }
1892
1893   /**
1894    * Creates a new {@link NoTrace} header.
1895    *
1896    * @param value
1897    *    The header value.
1898    *    <br>Must be parsable by {@link Boolean#parseBoolean(String)}.
1899    *    <br>Can be <jk>null</jk>.
1900    * @return A new header bean, or <jk>null</jk> if the value was <jk>null</jk>.
1901    */
1902   public static final NoTrace noTrace(String value) {
1903      return NoTrace.of(value);
1904   }
1905
1906   /**
1907    * Creates a new {@link NoTrace} header with a delayed value.
1908    *
1909    * <p>
1910    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1911    *
1912    * @param value
1913    *    The header value supplier.
1914    *    <br>Can be <jk>null</jk>.
1915    * @return A new header bean, or <jk>null</jk> if the value was <jk>null</jk>.
1916    */
1917   public static final NoTrace noTrace(Supplier<Boolean> value) {
1918      return NoTrace.of(value);
1919   }
1920
1921   /**
1922    * Creates a new {@link Origin} header.
1923    *
1924    * @param value
1925    *    The header value.
1926    *    <br>Can be <jk>null</jk>.
1927    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1928    */
1929   public static final Origin origin(String value) {
1930      return Origin.of(value);
1931   }
1932
1933   /**
1934    * Creates a new {@link Origin} header with a delayed value.
1935    *
1936    * <p>
1937    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1938    *
1939    * @param value
1940    *    The supplier of the header value.
1941    *    <br>Can be <jk>null</jk>.
1942    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1943    */
1944   public static final Origin origin(Supplier<String> value) {
1945      return Origin.of(value);
1946   }
1947
1948   /**
1949    * Creates a new {@link Pragma} header.
1950    *
1951    * @param value
1952    *    The header value.
1953    *    <br>Can be <jk>null</jk>.
1954    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1955    */
1956   public static final Pragma pragma(String value) {
1957      return Pragma.of(value);
1958   }
1959
1960   /**
1961    * Creates a new {@link Pragma} header with a delayed value.
1962    *
1963    * <p>
1964    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1965    *
1966    * @param value
1967    *    The header value.
1968    *    <br>Can be <jk>null</jk>.
1969    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1970    */
1971   public static final Pragma pragma(Supplier<String> value) {
1972      return Pragma.of(value);
1973   }
1974
1975   /**
1976    * Creates a new {@link ProxyAuthenticate} header.
1977    *
1978    * @param value
1979    *    The header value.
1980    *    <br>Can be <jk>null</jk>.
1981    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1982    */
1983   public static final ProxyAuthenticate proxyAuthenticate(String value) {
1984      return ProxyAuthenticate.of(value);
1985   }
1986
1987   /**
1988    * Creates a new {@link ProxyAuthenticate} header with a delayed value.
1989    *
1990    * <p>
1991    * Header value is re-evaluated on each call to {@link Header#getValue()}.
1992    *
1993    * @param value
1994    *    The supplier of the header value.
1995    *    <br>Can be <jk>null</jk>.
1996    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
1997    */
1998   public static final ProxyAuthenticate proxyAuthenticate(Supplier<String> value) {
1999      return ProxyAuthenticate.of(value);
2000   }
2001
2002   /**
2003    * Creates a new {@link ProxyAuthorization} header.
2004    *
2005    * @param value
2006    *    The header value.
2007    *    <br>Can be <jk>null</jk>.
2008    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2009    */
2010   public static final ProxyAuthorization proxyAuthorization(String value) {
2011      return ProxyAuthorization.of(value);
2012   }
2013
2014   /**
2015    * Creates a new {@link ProxyAuthorization} header with a delayed value.
2016    *
2017    * <p>
2018    * Header value is re-evaluated on each call to {@link Header#getValue()}.
2019    *
2020    * @param value
2021    *    The supplier of the header value.
2022    *    <br>Can be <jk>null</jk>.
2023    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2024    */
2025   public static final ProxyAuthorization proxyAuthorization(Supplier<String> value) {
2026      return ProxyAuthorization.of(value);
2027   }
2028
2029   /**
2030    * Creates a new {@link Range} header.
2031    *
2032    * @param value
2033    *    The header value.
2034    *    <br>Can be <jk>null</jk>.
2035    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2036    */
2037   public static final Range range(String value) {
2038      return Range.of(value);
2039   }
2040
2041   /**
2042    * Creates a new {@link Range} header with a delayed value.
2043    *
2044    * <p>
2045    * Header value is re-evaluated on each call to {@link Header#getValue()}.
2046    *
2047    * @param value
2048    *    The supplier of the header value.
2049    *    <br>Can be <jk>null</jk>.
2050    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2051    */
2052   public static final Range range(Supplier<String> value) {
2053      return Range.of(value);
2054   }
2055
2056   /**
2057    * Creates a new {@link Referer} header.
2058    *
2059    * @param value
2060    *    The header value.
2061    *    <br>Must be parsable by {@link URI#create(String)}.
2062    *    <br>Can be <jk>null</jk>.
2063    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2064    */
2065   public static final Referer referer(String value) {
2066      return Referer.of(value);
2067   }
2068
2069   /**
2070    * Creates a new {@link Referer} header with a delayed value.
2071    *
2072    * <p>
2073    * Header value is re-evaluated on each call to {@link Header#getValue()}.
2074    *
2075    * @param value
2076    *    The supplier of the header value.
2077    *    <br>Can be <jk>null</jk>.
2078    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2079    */
2080   public static final Referer referer(Supplier<URI> value) {
2081      return Referer.of(value);
2082   }
2083
2084   /**
2085    * Creates a new {@link Referer} header.
2086    *
2087    * @param value
2088    *    The header value.
2089    *    <br>Must be parsable by {@link URI#create(String)}.
2090    *    <br>Can be <jk>null</jk>.
2091    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2092    */
2093   public static final Referer referer(URI value) {
2094      return Referer.of(value);
2095   }
2096
2097   /**
2098    * Creates a new {@link RetryAfter} header.
2099    *
2100    * @param value
2101    *    The header value.
2102    *    <br>Can be <jk>null</jk>.
2103    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
2104    */
2105   public static final RetryAfter retryAfter(Integer value) {
2106      return RetryAfter.of(value);
2107   }
2108
2109   /**
2110    * Creates a new {@link RetryAfter} header.
2111    *
2112    * @param value
2113    *    The header value.
2114    *    <br>Must be an RFC-1123 formated string (e.g. <js>"Sat, 29 Oct 1994 19:43:31 GMT"</js>) or an integer.
2115    *    <br>Can be <jk>null</jk>.
2116    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
2117    */
2118   public static final RetryAfter retryAfter(String value) {
2119      return RetryAfter.of(value);
2120   }
2121
2122   /**
2123    * Creates a new {@link RetryAfter} header with a delayed value.
2124    *
2125    * <p>
2126    * Header value is re-evaluated on each call to {@link Header#getValue()}.
2127    *
2128    * @param value
2129    *    The supplier of the header value.
2130    *    <br>Supplier must supply either {@link Integer} or {@link ZonedDateTime} objects.
2131    *    <br>Can be <jk>null</jk>.
2132    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
2133    */
2134   public static final RetryAfter retryAfter(Supplier<?> value) {
2135      return RetryAfter.of(value);
2136   }
2137
2138   /**
2139    * Creates a new {@link RetryAfter} header.
2140    *
2141    * @param value
2142    *    The header value.
2143    *    <br>Can be <jk>null</jk>.
2144    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
2145    */
2146   public static final RetryAfter retryAfter(ZonedDateTime value) {
2147      return RetryAfter.of(value);
2148   }
2149
2150   /**
2151    * Creates a new {@link SerializedHeader} header.
2152    *
2153    * @param name The header name.
2154    * @param value
2155    *    The POJO to serialize as the header value.
2156    *    <br>Can be <jk>null</jk>.
2157    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty.
2158    */
2159   public static final SerializedHeader serializedHeader(String name, Object value) {
2160      return SerializedHeader.of(name, value);
2161   }
2162
2163   /**
2164    * Creates a new {@link SerializedHeader} header.
2165    *
2166    * @param name The HTTP header name name.
2167    * @param value
2168    *    The POJO to serialize as the header value.
2169    * @param serializer
2170    *    The serializer to use for serializing the value to a string value.
2171    * @param schema
2172    *    The schema object that defines the format of the output.
2173    *    <br>If <jk>null</jk>, defaults to the schema defined on the serializer.
2174    *    <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
2175    *    <br>Only used if serializer is schema-aware (e.g. {@link OpenApiSerializer}).
2176    *    <br>Can also be a {@link Supplier}.
2177    * @param skipIfEmpty If value is a blank string, the value should return as <jk>null</jk>.
2178    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty.
2179    */
2180   public static SerializedHeader serializedHeader(String name, Object value, HttpPartSerializerSession serializer, HttpPartSchema schema, boolean skipIfEmpty) {
2181      return SerializedHeader.of(name, value, serializer, schema, skipIfEmpty);
2182   }
2183
2184   /**
2185    * Creates a new {@link SerializedHeader} header with a delayed value.
2186    *
2187    * <p>
2188    * Header value is re-evaluated on each call to {@link Header#getValue()}.
2189    *
2190    * @param name The header name.
2191    * @param value
2192    *    The supplier of the POJO to serialize as the header value.
2193    *    <br>Can be <jk>null</jk>.
2194    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty.
2195    */
2196   public static final SerializedHeader serializedHeader(String name, Supplier<?> value) {
2197      return SerializedHeader.of(name, value);
2198   }
2199
2200   /**
2201    * Creates a new {@link SerializedHeader} header.
2202    *
2203    * <p>
2204    * Header value is re-evaluated on each call to {@link Header#getValue()}.
2205    *
2206    * @param name The HTTP header name name.
2207    * @param value
2208    *    The supplier of the POJO to serialize as the header value.
2209    * @param serializer
2210    *    The serializer to use for serializing the value to a string value.
2211    * @param schema
2212    *    The schema object that defines the format of the output.
2213    *    <br>If <jk>null</jk>, defaults to the schema defined on the serializer.
2214    *    <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
2215    *    <br>Only used if serializer is schema-aware (e.g. {@link OpenApiSerializer}).
2216    *    <br>Can also be a {@link Supplier}.
2217    * @param skipIfEmpty If value is a blank string, the value should return as <jk>null</jk>.
2218    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty.
2219    */
2220   public static SerializedHeader serializedHeader(String name, Supplier<?> value, HttpPartSerializerSession serializer, HttpPartSchema schema, boolean skipIfEmpty) {
2221      return SerializedHeader.of(name, value, serializer, schema, skipIfEmpty);
2222   }
2223
2224   /**
2225    * Creates a new {@link Server} header.
2226    *
2227    * @param value
2228    *    The header value.
2229    *    <br>Can be <jk>null</jk>.
2230    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2231    */
2232   public static final Server server(String value) {
2233      return Server.of(value);
2234   }
2235
2236   /**
2237    * Creates a new {@link Server} header with a delayed value.
2238    *
2239    * <p>
2240    * Header value is re-evaluated on each call to {@link Header#getValue()}.
2241    *
2242    * @param value
2243    *    The supplier of the header value.
2244    *    <br>Can be <jk>null</jk>.
2245    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2246    */
2247   public static final Server server(Supplier<String> value) {
2248      return Server.of(value);
2249   }
2250
2251   /**
2252    * Creates a {@link BasicHeader} from a name/value pair string (e.g. <js>"Foo: bar"</js>)
2253    *
2254    * @param pair The pair string.
2255    * @return A new header bean, or <jk>null</jk> if the value was <jk>null</jk>.
2256    */
2257   public static final BasicStringHeader stringHeader(String pair) {
2258      return BasicStringHeader.ofPair(pair);
2259   }
2260
2261   /**
2262    * Creates a new {@link BasicStringHeader} header.
2263    *
2264    * @param name The header name.
2265    * @param value
2266    *    The header value.
2267    *    <br>Can be <jk>null</jk>.
2268    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
2269    */
2270   public static final BasicStringHeader stringHeader(String name, String value) {
2271      return BasicStringHeader.of(name, value);
2272   }
2273
2274   /**
2275    * Creates a new {@link BasicStringHeader} header with a delayed value.
2276    *
2277    * <p>
2278    * Header value is re-evaluated on each call to {@link Header#getValue()}.
2279    *
2280    * @param name The header name.
2281    * @param value
2282    *    The supplier of the header value.
2283    *    <br>Can be <jk>null</jk>.
2284    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
2285    */
2286   public static final BasicStringHeader stringHeader(String name, Supplier<String> value) {
2287      return BasicStringHeader.of(name, value);
2288   }
2289
2290   /**
2291    * Creates a new {@link BasicStringRangesHeader} header.
2292    *
2293    * @param name The header name.
2294    * @param value
2295    *    The header value.
2296    *    <br>Must be parsable by {@link StringRanges#of(String)}.
2297    *    <br>Can be <jk>null</jk>.
2298    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
2299    */
2300   public static final BasicStringRangesHeader stringRangesHeader(String name, String value) {
2301      return BasicStringRangesHeader.of(name, value);
2302   }
2303
2304   /**
2305    * Creates a new {@link BasicStringRangesHeader} header.
2306    *
2307    * @param name The header name.
2308    * @param value
2309    *    The header value.
2310    *    <br>Can be <jk>null</jk>.
2311    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
2312    */
2313   public static final BasicStringRangesHeader stringRangesHeader(String name, StringRanges value) {
2314      return BasicStringRangesHeader.of(name, value);
2315   }
2316
2317   /**
2318    * Creates a new {@link BasicStringRangesHeader} header with a delayed value.
2319    *
2320    * <p>
2321    * Header value is re-evaluated on each call to {@link Header#getValue()}.
2322    *
2323    * @param name The header name.
2324    * @param value
2325    *    The supplier of the header value.
2326    *    <br>Can be <jk>null</jk>.
2327    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
2328    */
2329   public static final BasicStringRangesHeader stringRangesHeader(String name, Supplier<StringRanges> value) {
2330      return BasicStringRangesHeader.of(name, value);
2331   }
2332
2333   /**
2334    * Creates a new {@link TE} header.
2335    *
2336    * @param value
2337    *    The header value.
2338    *    <br>Must be parsable by {@link StringRanges#of(String)}.
2339    *    <br>Can be <jk>null</jk>.
2340    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2341    */
2342   public static final TE te(String value) {
2343      return TE.of(value);
2344   }
2345
2346   /**
2347    * Creates a new {@link TE} header.
2348    *
2349    * @param value
2350    *    The header value.
2351    *    <br>Can be <jk>null</jk>.
2352    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2353    */
2354   public static final TE te(StringRanges value) {
2355      return TE.of(value);
2356   }
2357
2358   /**
2359    * Creates a new {@link TE} header with a delayed value.
2360    *
2361    * <p>
2362    * Header value is re-evaluated on each call to {@link Header#getValue()}.
2363    *
2364    * @param value
2365    *    The supplier of the header value.
2366    *    <br>Can be <jk>null</jk>.
2367    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2368    */
2369   public static final TE te(Supplier<StringRanges> value) {
2370      return TE.of(value);
2371   }
2372
2373   /**
2374    * Creates a new {@link Thrown} header.
2375    *
2376    * @param value
2377    *    The header value.
2378    *    <br>Can be <jk>null</jk>.
2379    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2380    */
2381   public static final Thrown thrown(String value) {
2382      return Thrown.of(value);
2383   }
2384
2385   /**
2386    * Creates a new {@link Thrown} header.
2387    *
2388    * @param value
2389    *    The header value.
2390    *    <br>Can be <jk>null</jk>.
2391    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2392    */
2393   public static final Thrown thrown(Throwable...value) {
2394      return Thrown.of(value);
2395   }
2396
2397   /**
2398    * Creates a new {@link Trailer} header.
2399    *
2400    * @param value
2401    *    The header value.
2402    *    <br>Can be <jk>null</jk>.
2403    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2404    */
2405   public static final Trailer trailer(String value) {
2406      return Trailer.of(value);
2407   }
2408
2409   /**
2410    * Creates a new {@link Trailer} header with a delayed value.
2411    *
2412    * <p>
2413    * Header value is re-evaluated on each call to {@link Header#getValue()}.
2414    *
2415    * @param value
2416    *    The supplier of the header value.
2417    *    <br>Can be <jk>null</jk>.
2418    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2419    */
2420   public static final Trailer trailer(Supplier<String> value) {
2421      return Trailer.of(value);
2422   }
2423
2424   /**
2425    * Creates a new {@link TransferEncoding} header.
2426    *
2427    * @param value
2428    *    The header value.
2429    *    <br>Can be <jk>null</jk>.
2430    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2431    */
2432   public static final TransferEncoding transferEncoding(String value) {
2433      return TransferEncoding.of(value);
2434   }
2435
2436   /**
2437    * Creates a new {@link TransferEncoding} header with a delayed value.
2438    *
2439    * <p>
2440    * Header value is re-evaluated on each call to {@link Header#getValue()}.
2441    *
2442    * @param value
2443    *    The supplier of the header value.
2444    *    <br>Can be <jk>null</jk>.
2445    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2446    */
2447   public static final TransferEncoding transferEncoding(Supplier<String> value) {
2448      return TransferEncoding.of(value);
2449   }
2450
2451   /**
2452    * Creates a new {@link Upgrade} header.
2453    *
2454    * @param value
2455    *    The header value.
2456    *    <br>Can be <jk>null</jk>.
2457    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2458    */
2459   public static final Upgrade upgrade(String value) {
2460      return Upgrade.of(value);
2461   }
2462
2463   /**
2464    * Creates a new {@link Upgrade} header.
2465    *
2466    * @param value
2467    *    The header value.
2468    *    <br>Can be <jk>null</jk>.
2469    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2470    */
2471   public static final Upgrade upgrade(String...value) {
2472      return Upgrade.of(value);
2473   }
2474
2475   /**
2476    * Creates a new {@link Upgrade} header with a delayed value.
2477    *
2478    * <p>
2479    * Header value is re-evaluated on each call to {@link Header#getValue()}.
2480    *
2481    * @param value
2482    *    The supplier of the header value.
2483    *    <br>Can be <jk>null</jk>.
2484    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2485    */
2486   public static final Upgrade upgrade(Supplier<String[]> value) {
2487      return Upgrade.of(value);
2488   }
2489
2490   /**
2491    * Creates a new {@link BasicUriHeader} header.
2492    *
2493    * @param name The header name.
2494    * @param value
2495    *    The header value.
2496    *    <br>Must be parsable by {@link URI#create(String)}.
2497    *    <br>Can be <jk>null</jk>.
2498    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
2499    */
2500   public static final BasicUriHeader uriHeader(String name, String value) {
2501      return BasicUriHeader.of(name, value);
2502   }
2503
2504   /**
2505    * Creates a new {@link BasicUriHeader} header with a delayed value.
2506    *
2507    * <p>
2508    * Header value is re-evaluated on each call to {@link Header#getValue()}.
2509    *
2510    * @param name The header name.
2511    * @param value
2512    *    The supplier of the header value.
2513    *    <br>Can be <jk>null</jk>.
2514    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
2515    */
2516   public static final BasicUriHeader uriHeader(String name, Supplier<URI> value) {
2517      return BasicUriHeader.of(name, value);
2518   }
2519
2520   /**
2521    * Creates a new {@link BasicUriHeader} header.
2522    *
2523    * @param name The header name.
2524    * @param value
2525    *    The header value.
2526    *    <br>Can be <jk>null</jk>.
2527    * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>.
2528    */
2529   public static final BasicUriHeader uriHeader(String name, URI value) {
2530      return BasicUriHeader.of(name, value);
2531   }
2532
2533   /**
2534    * Creates a new {@link UserAgent} header.
2535    *
2536    * @param value
2537    *    The header value.
2538    *    <br>Can be <jk>null</jk>.
2539    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2540    */
2541   public static final UserAgent userAgent(String value) {
2542      return UserAgent.of(value);
2543   }
2544
2545   /**
2546    * Creates a new {@link UserAgent} header with a delayed value.
2547    *
2548    * <p>
2549    * Header value is re-evaluated on each call to {@link Header#getValue()}.
2550    *
2551    * @param value
2552    *    The supplier of the header value.
2553    *    <br>Can be <jk>null</jk>.
2554    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2555    */
2556   public static final UserAgent userAgent(Supplier<String> value) {
2557      return UserAgent.of(value);
2558   }
2559
2560   /**
2561    * Creates a new {@link Vary} header.
2562    *
2563    * @param value
2564    *    The header value.
2565    *    <br>Can be <jk>null</jk>.
2566    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2567    */
2568   public static final Vary vary(String value) {
2569      return Vary.of(value);
2570   }
2571
2572   /**
2573    * Creates a new {@link Vary} header with a delayed value.
2574    *
2575    * <p>
2576    * Header value is re-evaluated on each call to {@link Header#getValue()}.
2577    *
2578    * @param value
2579    *    The supplier of the header value.
2580    *    <br>Can be <jk>null</jk>.
2581    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2582    */
2583   public static final Vary vary(Supplier<String> value) {
2584      return Vary.of(value);
2585   }
2586
2587   /**
2588    * Creates a new {@link Via} header.
2589    *
2590    * @param value
2591    *    The header value.
2592    *    <br>Can be <jk>null</jk>.
2593    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2594    */
2595   public static final Via via(String value) {
2596      return Via.of(value);
2597   }
2598
2599   /**
2600    * Creates a new {@link Via} header.
2601    *
2602    * @param value
2603    *    The header value.
2604    *    <br>Can be <jk>null</jk>.
2605    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2606    */
2607   public static final Via via(String...value) {
2608      return Via.of(value);
2609   }
2610
2611   /**
2612    * Creates a new {@link Via} header with a delayed value.
2613    *
2614    * <p>
2615    * Header value is re-evaluated on each call to {@link Header#getValue()}.
2616    *
2617    * @param value
2618    *    The supplier of the header value.
2619    *    <br>Can be <jk>null</jk>.
2620    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2621    */
2622   public static final Via via(Supplier<String[]> value) {
2623      return Via.of(value);
2624   }
2625
2626   /**
2627    * Creates a new {@link Warning} header.
2628    *
2629    * @param value
2630    *    The header value.
2631    *    <br>Can be <jk>null</jk>.
2632    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2633    */
2634   public static final Warning warning(String value) {
2635      return Warning.of(value);
2636   }
2637
2638   /**
2639    * Creates a new {@link Warning} header with a delayed value.
2640    *
2641    * <p>
2642    * Header value is re-evaluated on each call to {@link Header#getValue()}.
2643    *
2644    * @param value
2645    *    The supplier of the header value.
2646    *    <br>Can be <jk>null</jk>.
2647    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2648    */
2649   public static final Warning warning(Supplier<String> value) {
2650      return Warning.of(value);
2651   }
2652
2653   /**
2654    * Creates a new {@link WwwAuthenticate} header.
2655    *
2656    * @param value
2657    *    The header value.
2658    *    <br>Can be <jk>null</jk>.
2659    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2660    */
2661   public static final WwwAuthenticate wwwAuthenticate(String value) {
2662      return WwwAuthenticate.of(value);
2663   }
2664
2665   /**
2666    * Creates a new {@link WwwAuthenticate} header with a delayed value.
2667    *
2668    * <p>
2669    * Header value is re-evaluated on each call to {@link Header#getValue()}.
2670    *
2671    * @param value
2672    *    The supplier of the header value.
2673    *    <br>Can be <jk>null</jk>.
2674    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
2675    */
2676   public static final WwwAuthenticate wwwAuthenticate(Supplier<String> value) {
2677      return WwwAuthenticate.of(value);
2678   }
2679}