public final class Headers extends Object
Request and
Response for interpreted headers. This class maintains the order of the header fields within the HTTP message.
This class tracks header values line-by-line. A field with multiple comma- separated values on the same line will be treated as a field with a single value by this class. It is the caller's responsibility to detect and split on commas if their field permits multiple values. This simplifies use of single-valued fields whose values routinely contain commas, such as cookies or dates.
This class trims whitespace from values. It never returns values with leading or trailing whitespace.
Instances of this class are immutable. Use Headers.Builder to create instances.
| Modifier and Type | Class and Description |
|---|---|
static class |
Headers
|
| Modifier and Type | Method and Description |
|---|---|
String |
get(String
Returns the last value corresponding to the specified field, or null.
|
Date |
getDate(String
Returns the last value corresponding to the specified field parsed as an HTTP date, or null if either the field is absent or cannot be parsed as a date.
|
String |
name(int index)
Returns the field at
position.
|
Set |
names()
Returns an immutable case-insensitive set of header names.
|
Headers |
newBuilder()
|
static Headers |
of(Map
Returns headers for the header names and values in the
Map.
|
static Headers |
of(String
Returns headers for the alternating header names and values.
|
int |
size()
Returns the number of field values.
|
Map |
toMultimap()
|
String |
toString()
|
String |
value(int index)
Returns the value at
index.
|
List |
values(String
Returns an immutable list of the header values for
name.
|
public Stringget(String name)
public DategetDate(String name)
public int size()
public Stringname(int index)
position.
public Stringvalue(int index)
index.
public List<String > values(String name)
name.
public Headers.Builder newBuilder()
public StringtoString()
public static Headersof(String ... namesAndValues)