Package org.apache.http.message
Class AbstractHttpMessage
java.lang.Object
org.apache.http.message.AbstractHttpMessage
- All Implemented Interfaces:
HttpMessage
- Direct Known Subclasses:
AbstractExecutionAwareRequest
,BasicHttpRequest
,BasicHttpResponse
,HttpRequestWrapper
,RequestWrapper
Basic implementation of
HttpMessage
.- Since:
- 4.0
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a header to this message.void
Adds a header to this message.boolean
containsHeader
(String name) Checks if a certain header is present in this message.Header[]
Returns all the headers of this message.getFirstHeader
(String name) Returns the first header with a specified name 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.Deprecated.(4.3) use constructor parameters of configuration API provided by HttpClientReturns an iterator of all the headers.headerIterator
(String name) Returns an iterator of the headers with a given name.void
removeHeader
(Header header) Removes a header from this message.void
removeHeaders
(String name) Removes all headers with a certain name from this message.void
Overwrites the first header with the same name.void
Overwrites the first header with the same name.void
setHeaders
(Header[] headers) Overwrites all the headers in the message.void
setParams
(HttpParams params) Deprecated.(4.3) use constructor parameters of configuration API provided by HttpClientMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.http.HttpMessage
getProtocolVersion
-
Method Details
-
containsHeader
Description copied from interface:HttpMessage
Checks if a certain header is present in this message. Header values are ignored.- Specified by:
containsHeader
in interfaceHttpMessage
- Parameters:
name
- the header name to check for.- Returns:
- true if at least one header with this name is present.
-
getHeaders
Description copied from interface:HttpMessage
Returns all the headers with a specified name of this message. Header values are ignored. Headers are orderd in the sequence they will be sent over a connection.- Specified by:
getHeaders
in interfaceHttpMessage
- Parameters:
name
- the name of the headers to return.- Returns:
- the headers whose name property equals
name
.
-
getFirstHeader
Description copied from interface:HttpMessage
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 ofHttpMessage.getHeaders(String)
is returned. If there is no matching header in the messagenull
is returned.- Specified by:
getFirstHeader
in interfaceHttpMessage
- 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.
-
getLastHeader
Description copied from interface:HttpMessage
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 ofHttpMessage.getHeaders(String)
is returned. If there is no matching header in the messagenull
is returned.- Specified by:
getLastHeader
in interfaceHttpMessage
- 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.
-
getAllHeaders
Description copied from interface:HttpMessage
Returns all the headers of this message. Headers are orderd in the sequence they will be sent over a connection.- Specified by:
getAllHeaders
in interfaceHttpMessage
- Returns:
- all the headers of this message
-
addHeader
Description copied from interface:HttpMessage
Adds a header to this message. The header will be appended to the end of the list.- Specified by:
addHeader
in interfaceHttpMessage
- Parameters:
header
- the header to append.
-
addHeader
Description copied from interface:HttpMessage
Adds a header to this message. The header will be appended to the end of the list.- Specified by:
addHeader
in interfaceHttpMessage
- Parameters:
name
- the name of the header.value
- the value of the header.
-
setHeader
Description copied from interface:HttpMessage
Overwrites 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:
setHeader
in interfaceHttpMessage
- Parameters:
header
- the header to set.
-
setHeader
Description copied from interface:HttpMessage
Overwrites 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:
setHeader
in interfaceHttpMessage
- Parameters:
name
- the name of the header.value
- the value of the header.
-
setHeaders
Description copied from interface:HttpMessage
Overwrites all the headers in the message.- Specified by:
setHeaders
in interfaceHttpMessage
- Parameters:
headers
- the array of headers to set.
-
removeHeader
Description copied from interface:HttpMessage
Removes a header from this message.- Specified by:
removeHeader
in interfaceHttpMessage
- Parameters:
header
- the header to remove.
-
removeHeaders
Description copied from interface:HttpMessage
Removes all headers with a certain name from this message.- Specified by:
removeHeaders
in interfaceHttpMessage
- Parameters:
name
- The name of the headers to remove.
-
headerIterator
Description copied from interface:HttpMessage
Returns an iterator of all the headers.- Specified by:
headerIterator
in interfaceHttpMessage
- Returns:
- Iterator that returns Header objects in the sequence they are sent over a connection.
-
headerIterator
Description copied from interface:HttpMessage
Returns an iterator of the headers with a given name.- Specified by:
headerIterator
in interfaceHttpMessage
- 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.
-
getParams
Deprecated.(4.3) use constructor parameters of configuration API provided by HttpClientDescription copied from interface:HttpMessage
Returns the parameters effective for this message as set byHttpMessage.setParams(HttpParams)
.- Specified by:
getParams
in interfaceHttpMessage
-
setParams
Deprecated.(4.3) use constructor parameters of configuration API provided by HttpClientDescription copied from interface:HttpMessage
Provides parameters to be used for the processing of this message.- Specified by:
setParams
in interfaceHttpMessage
- Parameters:
params
- the parameters
-