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 MessageHeadersMessages head consisting of multiple message headers.- Since:
- 5.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancontainsHeader(java.lang.String name)Checks if a certain header is present in this message.intcountHeaders(java.lang.String name)Checks if a certain header is present in this message and how many times.HeadergetFirstHeader(java.lang.String name)Returns the first header with a specified name of this message.HeadergetHeader(java.lang.String name)Gets single first header with the given name.Header[]getHeaders()Returns all the headers of this message.Header[]getHeaders(java.lang.String name)Returns all the headers with a specified name of this message.HeadergetLastHeader(java.lang.String name)Returns the last header with a specified name of this message.java.util.Iterator<Header>headerIterator()Returns an iterator of all the headers.java.util.Iterator<Header>headerIterator(java.lang.String name)Returns an iterator of the headers with a given name.
-
-
-
Method Detail
-
containsHeader
boolean containsHeader(java.lang.String name)
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
int countHeaders(java.lang.String name)
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
Header getFirstHeader(java.lang.String name)
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 messagenullis returned.- Parameters:
name- the name of the header to return.- Returns:
- the first header whose name property equals
nameornullif no such header could be found.
-
getHeader
Header getHeader(java.lang.String name) throws ProtocolException
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
Header[] getHeaders(java.lang.String name)
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
Header getLastHeader(java.lang.String name)
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 messagenullis returned.- Parameters:
name- the name of the header to return.- Returns:
- the last header whose name property equals
name. ornullif no such header could be found.
-
headerIterator
java.util.Iterator<Header> headerIterator()
Returns an iterator of all the headers.- Returns:
- Iterator that returns Header objects in the sequence they are sent over a connection.
-
headerIterator
java.util.Iterator<Header> headerIterator(java.lang.String name)
Returns an iterator of the headers with a given name.- Parameters:
name- the name of the headers over which to iterate, ornullfor all headers- Returns:
- Iterator that returns Header objects with the argument name in the sequence they are sent over a connection.
-
-