Package org.apache.hc.core5.http
Interface MessageHeaders
- All Known Subinterfaces:
ClassicHttpRequest
,ClassicHttpResponse
,HttpMessage
,HttpRequest
,HttpResponse
- All Known Implementing Classes:
AbstractMessageWrapper
,BasicClassicHttpRequest
,BasicClassicHttpResponse
,BasicHttpRequest
,BasicHttpResponse
,HeaderGroup
,HttpRequestWrapper
,HttpResponseWrapper
public interface MessageHeaders
Messages head consisting of multiple message headers.
- Since:
- 5.0
-
Method Summary
Modifier and TypeMethodDescriptionboolean
containsHeader
(String name) Checks if a certain header is present in this message.int
countHeaders
(String name) Checks if a certain header is present in this message and how many times.getFirstHeader
(String name) Returns the first header with a specified name of this message.Gets single first header with the given name.Header[]
Returns all the headers of this message.Header[]
getHeaders
(String name) Returns all the headers with a specified name of this message.getLastHeader
(String name) Returns the last header with a specified name of this message.Returns an iterator of all the headers.headerIterator
(String name) Returns an iterator of the headers with a given name.
-
Method Details
-
containsHeader
Checks if a certain header is present in this message. Header values are ignored.- Parameters:
name
- the header name to check for.- Returns:
- true if at least one header with this name is present.
-
countHeaders
Checks if a certain header is present in this message and how many times.- Parameters:
name
- the header name to check for.- Returns:
- number of occurrences of the header in the message.
-
getFirstHeader
Returns the first header with a specified name of this message. Header values are ignored. If there is more than one matching header in the message the first element ofgetHeaders(String)
is returned. If there is no matching header in the messagenull
is returned.- Parameters:
name
- the name of the header to return.- Returns:
- the first header whose name property equals
name
ornull
if no such header could be found.
-
getHeader
Gets single first header with the given name.Header name comparison is case insensitive.
- Parameters:
name
- the name of the header to get- Returns:
- the first header or
null
- Throws:
ProtocolException
- in case multiple headers with the given name are found.
-
getHeaders
Header[] getHeaders()Returns all the headers of this message. Headers are ordered in the sequence they will be sent over a connection.- Returns:
- all the headers of this message
-
getHeaders
Returns all the headers with a specified name of this message. Header values are ignored. Headers are ordered in the sequence they will be sent over a connection.- Parameters:
name
- the name of the headers to return.- Returns:
- the headers whose name property equals
name
.
-
getLastHeader
Returns the last header with a specified name of this message. Header values are ignored. If there is more than one matching header in the message the last element ofgetHeaders(String)
is returned. If there is no matching header in the messagenull
is returned.- Parameters:
name
- the name of the header to return.- Returns:
- the last header whose name property equals
name
. ornull
if no such header could be found.
-
headerIterator
Returns an iterator of all the headers.- Returns:
- Iterator that returns Header objects in the sequence they are sent over a connection.
-
headerIterator
Returns an iterator of the headers with a given name.- Parameters:
name
- the name of the headers over which to iterate, ornull
for all headers- Returns:
- Iterator that returns Header objects with the argument name in the sequence they are sent over a connection.
-