Class ResponseHeader
- All Implemented Interfaces:
- Serializable,- Cloneable,- Header,- NameValuePair
 An extension of an HttpClient Header that provides various support for converting the header to POJOs and
 other convenience methods.
 
See Also:
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionResponseHeader(String name, RestRequest request, RestResponse response, Header header) Constructor.
- 
Method SummaryModifier and TypeMethodDescription<T> Optional<T>Converts this header to the specified type.<T> Optional<T>Converts this header to the specified type.<T> Optional<T>Converts this header to the specified type.<T> RestResponseSame asas(Class)but sets the value in a mutable for fluent calls.<T> RestResponseSame asas(Type,Type...)but sets the value in a mutable for fluent calls.<T> RestResponseSame asas(ClassMeta)but sets the value in a mutable for fluent calls.Returns the value of this header as a boolean.Returns the value of this header as an boolean header.Returns the value of this header as a list from a comma-delimited string.Returns the value of this header as a CSV array header.asDate()Returns the value of this header as a date.Returns the value of this header as a date header.Returns the value of this header as an entity validator header.Returns the value of this header as an entity validator array header.<T extends BasicHeader>
 TReturns the value of this header as aBasicHeader.Returns the value of this header as an integer.Returns the value of this header as an integer header.asLong()Returns the value of this header as a long.Returns the value of this header as a long header.Matches the specified pattern against this header value.Matches the specified pattern against this header value.Matches the specified pattern against this header value.Shortcut for callingassertValue().asInteger() .Shortcut for callingassertValue().asLong() .Shortcut for callingassertValue().asString() .Provides the ability to perform fluent-style assertions on this response header.Shortcut for callingassertValue().asZonedDateTime() .Same asBasicHeader.asString()but sets the value in a mutable for fluent calls.Returns the value of this header as a string header.Returns the value of this header as a range array header.Returns the value of this header as a URI header.Parses the value.parser(HttpPartParserSession value) Specifies the part parser to use for this header.response()Returns the response that created this object.schema(HttpPartSchema value) Specifies the part schema for this header.Methods inherited from class org.apache.juneau.http.header.BasicHeaderassertName, assertStringValue, asString, equals, equalsIgnoreCase, get, getName, getValue, hashCode, isNotEmpty, isPresent, of, of, orElse, toString
- 
Constructor Details- 
ResponseHeaderConstructor.- Parameters:
- name- The header name.
- request- The request object.
- response- The response object.
- header- The wrapped header. Can be- null .
- Throws:
- IllegalArgumentException- If name is- null or empty.
 
 
- 
- 
Method Details- 
schemaSpecifies the part schema for this header.Used by schema-based part parsers such as OpenApiParser.- Parameters:
- value- The part schema.
- Returns:
- This object.
 
- 
parserSpecifies the part parser to use for this header.If not specified, uses the part parser defined on the client by calling RestClient.Builder.partParser(Class).- Parameters:
- value- The new part parser to use for this header.
 If- null ,- SimplePartParser.DEFAULTwill be used.
- Returns:
- This object.
 
- 
asIntegerReturns the value of this header as an integer.- Returns:
- The value of this header as an integer, or Optional.empty()if the header was not present.
 
- 
asBooleanReturns the value of this header as a boolean.- Returns:
- The value of this header as a boolean, or Optional.empty()if the header was not present.
 
- 
asLongReturns the value of this header as a long.- Returns:
- The value of this header as a long, or Optional.empty()if the header was not present.
 
- 
asDateReturns the value of this header as a date.- Returns:
- The value of this header as a date, or Optional.empty()if the header was not present.
 
- 
asCsvArrayReturns the value of this header as a list from a comma-delimited string.- Returns:
- The value of this header as a list from a comma-delimited string, or Optional.empty()if the header was not present.
 
- 
asHeaderReturns the value of this header as aBasicHeader.- Type Parameters:
- T- The subclass of- BasicHeaderto instantiate.
- Parameters:
- c- The subclass of- BasicHeaderto instantiate.
- Returns:
- The value of this header as a string, never null .
 
- 
asCsvHeaderReturns the value of this header as a CSV array header.- Returns:
- The value of this header as a CSV array header, never null .
 
- 
asDateHeaderReturns the value of this header as a date header.- Returns:
- The value of this header as a date header, never null .
 
- 
asEntityTagsHeaderReturns the value of this header as an entity validator array header.- Returns:
- The value of this header as an entity validator array header, never null .
 
- 
asEntityTagHeaderReturns the value of this header as an entity validator header.- Returns:
- The value of this header as an entity validator array, never null .
 
- 
asIntegerHeaderReturns the value of this header as an integer header.- Returns:
- The value of this header as an integer header, never null .
 
- 
asBooleanHeaderReturns the value of this header as an boolean header.- Returns:
- The value of this header as an boolean header, never null .
 
- 
asLongHeaderReturns the value of this header as a long header.- Returns:
- The value of this header as a long header, never null .
 
- 
asStringRangesHeaderReturns the value of this header as a range array header.- Returns:
- The value of this header as a range array header, never null .
 
- 
asStringHeaderReturns the value of this header as a string header.- Returns:
- The value of this header as a string header, never null .
 
- 
asUriHeaderReturns the value of this header as a URI header.- Returns:
- The value of this header as a URI header, never null .
 
- 
asStringSame asBasicHeader.asString()but sets the value in a mutable for fluent calls.- Parameters:
- value- The mutable to set the header value in.
- Returns:
- This object.
 
- 
asConverts this header to the specified type.See Complex Data Types for information on defining complex generic types of MapsandCollections.- Type Parameters:
- T- The type to convert to.
- Parameters:
- type- The type to convert to.
- args- The type parameters.
- Returns:
- The converted type, or null if header is not present.
 
- 
asSame asas(Type,Type...)but sets the value in a mutable for fluent calls.See Complex Data Types for information on defining complex generic types of MapsandCollections.- Type Parameters:
- T- The type to convert to.
- Parameters:
- value- The mutable to set the parsed header value in.
- type- The type to convert to.
- args- The type parameters.
- Returns:
- This object.
 
- 
asConverts this header to the specified type.- Type Parameters:
- T- The type to convert to.
- Parameters:
- type- The type to convert to.
- Returns:
- The converted type, or null if header is not present.
 
- 
asSame asas(Class)but sets the value in a mutable for fluent calls.- Type Parameters:
- T- The type to convert to.
- Parameters:
- value- The mutable to set the parsed header value in.
- type- The type to convert to.
- Returns:
- This object.
 
- 
asConverts this header to the specified type.- Type Parameters:
- T- The type to convert to.
- Parameters:
- type- The type to convert to.
- Returns:
- The converted type, or null if header is not present.
 
- 
asSame asas(ClassMeta)but sets the value in a mutable for fluent calls.- Type Parameters:
- T- The type to convert to.
- Parameters:
- value- The mutable to set the parsed header value in.
- type- The type to convert to.
- Returns:
- This object.
 
- 
asMatcherMatches the specified pattern against this header value.Example:// Parse header using a regular expression. Matchermatcher =client .get(URI ) .run() .getResponseHeader("Content-Type" ).asMatcher(Pattern.compile ("application/(.*)" ));if (matcher .matches()) { StringmediaType =matcher .group(1); }- Parameters:
- pattern- The regular expression pattern to match.
- Returns:
- The matcher.
 
- 
asMatcherMatches the specified pattern against this header value.Example:// Parse header using a regular expression. Matchermatcher =client .get(URI ) .run() .getHeader("Content-Type" ).asMatcher("application/(.*)" );if (matcher .matches()) { StringmediaType =matcher .group(1); }- Parameters:
- regex- The regular expression pattern to match.
- Returns:
- The matcher.
 
- 
asMatcherMatches the specified pattern against this header value.Example:// Parse header using a regular expression. Matchermatcher =client .get(URI ) .run() .getHeader("Content-Type" ).asMatcher("application/(.*)" ,CASE_INSENSITIVE );if (matcher .matches()) { StringmediaType =matcher .group(1); }- Parameters:
- regex- The regular expression pattern to match.
- flags- Pattern match flags. See- Pattern.compile(String, int).
- Returns:
- The matcher.
 
- 
assertValueProvides the ability to perform fluent-style assertions on this response header.Examples:// Validates the content type header is provided. client .get(URI ) .run() .getHeader("Content-Type" ).assertValue().exists();// Validates the content type is JSON. client .get(URI ) .run() .getHeader("Content-Type" ).assertValue().equals("application/json" );// Validates the content type is JSON using test predicate. client .get(URI ) .run() .getHeader("Content-Type" ).assertValue().is(x ->x .equals("application/json" ));// Validates the content type is JSON by just checking for substring. client .get(URI ) .run() .getHeader("Content-Type" ).assertValue().contains("json" );// Validates the content type is JSON using regular expression. client .get(URI ) .run() .getHeader("Content-Type" ).assertValue().isPattern(".*json.*" );// Validates the content type is JSON using case-insensitive regular expression. client .get(URI ) .run() .getHeader("Content-Type" ).assertValue().isPattern(".*json.*" ,CASE_INSENSITIVE );The assertion test returns the original response object allowing you to chain multiple requests like so: // Validates the header and converts it to a bean. MediaTypemediaType =client .get(URI ) .run() .getHeader("Content-Type" ).assertValue().isNotEmpty() .getHeader("Content-Type" ).assertValue().isPattern(".*json.*" ) .getHeader("Content-Type" ).as(MediaType.class );- Returns:
- A new fluent assertion object.
 
- 
assertStringShortcut for callingassertValue().asString() .- Returns:
- A new fluent assertion.
 
- 
assertIntegerShortcut for callingassertValue().asInteger() .- Returns:
- A new fluent assertion.
 
- 
assertLongShortcut for callingassertValue().asLong() .- Returns:
- A new fluent assertion.
 
- 
assertZonedDateTimeShortcut for callingassertValue().asZonedDateTime() .- Returns:
- A new fluent assertion.
 
- 
responseReturns the response that created this object.- Returns:
- The response that created this object.
 
- 
getElementsParses the value.- Specified by:
- getElementsin interface- Header
- Overrides:
- getElementsin class- BasicHeader
- Returns:
- An array of HeaderElemententries, may be empty, but is nevernull .
- Throws:
- ParseException- In case of a parsing error.
 
 
-