Package org.apache.hc.core5.http.message
Class AbstractMessageWrapper<T extends HttpMessage>
java.lang.Object
org.apache.hc.core5.http.message.AbstractMessageWrapper<T>
- Type Parameters:
T- AHttpMessagetype.
- All Implemented Interfaces:
HttpMessage,MessageHeaders
- Direct Known Subclasses:
HttpRequestWrapper,HttpResponseWrapper
public abstract class AbstractMessageWrapper<T extends HttpMessage>
extends Object
implements HttpMessage
Abstract
HttpMessage wrapper.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a header to this message.voidAdds a header to this message.booleancontainsHeader(String name) Checks if a certain header is present in this message.intcountHeaders(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.(package private) TReturns protocol version ornullwhen not available.Returns an iterator of all the headers.headerIterator(String name) Returns an iterator of the headers with a given name.booleanremoveHeader(Header header) Removes a header from this message.booleanremoveHeaders(String name) Removes all headers with a certain name from this message.voidOverwrites the first header with the same name.voidOverwrites the first header with the same name.voidsetHeaders(Header... headers) Overwrites all the headers in the message.voidsetVersion(ProtocolVersion version) Sets protocol version.toString()
-
Field Details
-
message
-
-
Constructor Details
-
AbstractMessageWrapper
-
-
Method Details
-
setVersion
Description copied from interface:HttpMessageSets protocol version.For incoming messages it represents protocol version this message was transmitted with. For outgoing messages it represents a hint what protocol version should be used to transmit the message.
- Specified by:
setVersionin interfaceHttpMessage
-
getVersion
Description copied from interface:HttpMessageReturns protocol version ornullwhen not available.For incoming messages it represents protocol version this message was transmitted with. For outgoing messages it represents a hint what protocol version should be used to transmit the message.
- Specified by:
getVersionin interfaceHttpMessage
-
addHeader
Description copied from interface:HttpMessageAdds a header to this message. The header will be appended to the end of the list.- Specified by:
addHeaderin interfaceHttpMessage- Parameters:
header- the header to append.
-
addHeader
Description copied from interface:HttpMessageAdds a header to this message. The header will be appended to the end of the list.- Specified by:
addHeaderin interfaceHttpMessage- Parameters:
name- the name of the header.value- the value of the header, taken as the value'sObject.toString().
-
setHeader
Description copied from interface:HttpMessageOverwrites the first header with the same name. The new header will be appended to the end of the list, if no header with the given name can be found.- Specified by:
setHeaderin interfaceHttpMessage- Parameters:
header- the header to set.
-
setHeader
Description copied from interface:HttpMessageOverwrites the first header with the same name. The new header will be appended to the end of the list, if no header with the given name can be found.- Specified by:
setHeaderin interfaceHttpMessage- Parameters:
name- the name of the header.value- the value of the header, taken as the value'sObject.toString().
-
setHeaders
Description copied from interface:HttpMessageOverwrites all the headers in the message.- Specified by:
setHeadersin interfaceHttpMessage- Parameters:
headers- the array of headers to set.
-
removeHeader
Description copied from interface:HttpMessageRemoves a header from this message.- Specified by:
removeHeaderin interfaceHttpMessage- Parameters:
header- the header to remove.- Returns:
trueif a header was removed as a result of this call.
-
removeHeaders
Description copied from interface:HttpMessageRemoves all headers with a certain name from this message.- Specified by:
removeHeadersin interfaceHttpMessage- Parameters:
name- The name of the headers to remove.- Returns:
trueif any header was removed as a result of this call.
-
containsHeader
Description copied from interface:MessageHeadersChecks if a certain header is present in this message. Header values are ignored.- Specified by:
containsHeaderin interfaceMessageHeaders- Parameters:
name- the header name to check for.- Returns:
- true if at least one header with this name is present.
-
countHeaders
Description copied from interface:MessageHeadersChecks if a certain header is present in this message and how many times.- Specified by:
countHeadersin interfaceMessageHeaders- Parameters:
name- the header name to check for.- Returns:
- number of occurrences of the header in the message.
-
getHeaders
Description copied from interface:MessageHeadersReturns 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.- Specified by:
getHeadersin interfaceMessageHeaders- Parameters:
name- the name of the headers to return.- Returns:
- the headers whose name property equals
name.
-
getHeader
Description copied from interface:MessageHeadersGets single first header with the given name.Header name comparison is case insensitive.
- Specified by:
getHeaderin interfaceMessageHeaders- 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.
-
getFirstHeader
Description copied from interface:MessageHeadersReturns 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 ofMessageHeaders.getHeaders(String)is returned. If there is no matching header in the messagenullis returned.- Specified by:
getFirstHeaderin interfaceMessageHeaders- Parameters:
name- the name of the header to return.- Returns:
- the first header whose name property equals
nameornullif no such header could be found.
-
getLastHeader
Description copied from interface:MessageHeadersReturns 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 ofMessageHeaders.getHeaders(String)is returned. If there is no matching header in the messagenullis returned.- Specified by:
getLastHeaderin interfaceMessageHeaders- 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.
-
getMessage
T getMessage() -
getHeaders
Description copied from interface:MessageHeadersReturns all the headers of this message. Headers are ordered in the sequence they will be sent over a connection.- Specified by:
getHeadersin interfaceMessageHeaders- Returns:
- all the headers of this message
-
headerIterator
Description copied from interface:MessageHeadersReturns an iterator of all the headers.- Specified by:
headerIteratorin interfaceMessageHeaders- Returns:
- Iterator that returns Header objects in the sequence they are sent over a connection.
-
headerIterator
Description copied from interface:MessageHeadersReturns an iterator of the headers with a given name.- Specified by:
headerIteratorin interfaceMessageHeaders- 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.
-
toString
-