Top Description Methods
org.apache.http

public Interface HttpMessage

Known Direct Subinterfaces
org.apache.http.HttpRequest, org.apache.http.HttpResponse
Known Direct Implementers
org.apache.http.message.AbstractHttpMessage
Annotations
@SuppressWarnings:deprecation
Imports
org.apache.http.params.HttpParams

HTTP messages consist of requests from client to server and responses from server to client.
    HTTP-message   = Request | Response     ; HTTP/1.1 messages

HTTP messages use the generic message format of RFC 822 for transferring entities (the payload of the message). Both types of message consist of a start-line, zero or more header fields (also known as "headers"), an empty line (i.e., a line with nothing preceding the CRLF) indicating the end of the header fields, and possibly a message-body.

     generic-message = start-line
                       *(message-header CRLF)
                       CRLF
                       [ message-body ]
     start-line      = Request-Line | Status-Line
Since
4.0

Method Summary

Modifier and TypeMethod and Description
public void
addHeader(Header
the header to append.
header
)

Adds a header to this message.

public void
addHeader(String
the name of the header.
name
,
String
the value of the header.
value
)

Adds a header to this message.

public boolean

Returns:

true if at least one header with this name is present.
containsHeader
(String
the header name to check for.
name
)

Checks if a certain header is present in this message.

public Header[]

Returns:

all the headers of this message
getAllHeaders
()

Returns all the headers of this message.

public Header

Returns:

the first header whose name property equals name or null if no such header could be found.
getFirstHeader
(String
the name of the header to return.
name
)

Returns the first header with a specified name of this message.

public Header[]

Returns:

the headers whose name property equals name.
getHeaders
(String
the name of the headers to return.
name
)

Returns all the headers with a specified name of this message.

public Header

Returns:

the last header whose name property equals name. or null if no such header could be found.
getLastHeader
(String
the name of the header to return.
name
)

Returns the last header with a specified name of this message.

public HttpParams
getParams()

Deprecated (4.3) use configuration classes provided 'org.apache.http.config' and 'org.apache.http.client.config'
Returns the parameters effective for this message as set by setParams(HttpParams).
public ProtocolVersion
getProtocolVersion()

Returns the protocol version this message is compatible with.

public HeaderIterator

Returns:

Iterator that returns Header objects in the sequence they are sent over a connection.
headerIterator
()

Returns an iterator of all the headers.

public HeaderIterator

Returns:

Iterator that returns Header objects with the argument name in the sequence they are sent over a connection.
headerIterator
(String
the name of the headers over which to iterate, or null for all headers
name
)

Returns an iterator of the headers with a given name.

public void
removeHeader(Header
the header to remove.
header
)

Removes a header from this message.

public void
removeHeaders(String
The name of the headers to remove.
name
)

Removes all headers with a certain name from this message.

public void
setHeader(Header
the header to set.
header
)

Overwrites the first header with the same name.

public void
setHeader(String
the name of the header.
name
,
String
the value of the header.
value
)

Overwrites the first header with the same name.

public void
setHeaders(Header[]
the array of headers to set.
headers
)

Overwrites all the headers in the message.

public void
setParams(HttpParams
the parameters
params
)

Deprecated (4.3) use configuration classes provided 'org.apache.http.config' and 'org.apache.http.client.config'
Provides parameters to be used for the processing of this message.

Method Detail

addHeaderback to summary
public void addHeader(Header header)

Adds a header to this message. The header will be appended to the end of the list.

Parameters
header:Header

the header to append.

addHeaderback to summary
public void addHeader(String name, String value)

Adds a header to this message. The header will be appended to the end of the list.

Parameters
name:String

the name of the header.

value:String

the value of the header.

containsHeaderback to summary
public boolean containsHeader(String name)

Checks if a certain header is present in this message. Header values are ignored.

Parameters
name:String

the header name to check for.

Returns:boolean

true if at least one header with this name is present.

getAllHeadersback to summary
public Header[] getAllHeaders()

Returns all the headers of this message. Headers are orderd in the sequence they will be sent over a connection.

Returns:Header[]

all the headers of this message

getFirstHeaderback to summary
public Header getFirstHeader(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 of getHeaders(String) is returned. If there is no matching header in the message null is returned.

Parameters
name:String

the name of the header to return.

Returns:Header

the first header whose name property equals name or null if no such header could be found.

getHeadersback to summary
public Header[] getHeaders(String name)

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.

Parameters
name:String

the name of the headers to return.

Returns:Header[]

the headers whose name property equals name.

getLastHeaderback to summary
public Header getLastHeader(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 of getHeaders(String) is returned. If there is no matching header in the message null is returned.

Parameters
name:String

the name of the header to return.

Returns:Header

the last header whose name property equals name. or null if no such header could be found.

getParamsback to summary
public HttpParams getParams()

Deprecated

(4.3) use configuration classes provided 'org.apache.http.config' and 'org.apache.http.client.config'

Returns the parameters effective for this message as set by setParams(HttpParams).

Annotations
@Deprecated
getProtocolVersionback to summary
public ProtocolVersion getProtocolVersion()

Returns the protocol version this message is compatible with.

headerIteratorback to summary
public HeaderIterator headerIterator()

Returns an iterator of all the headers.

Returns:HeaderIterator

Iterator that returns Header objects in the sequence they are sent over a connection.

headerIteratorback to summary
public HeaderIterator headerIterator(String name)

Returns an iterator of the headers with a given name.

Parameters
name:String

the name of the headers over which to iterate, or null for all headers

Returns:HeaderIterator

Iterator that returns Header objects with the argument name in the sequence they are sent over a connection.

removeHeaderback to summary
public void removeHeader(Header header)

Removes a header from this message.

Parameters
header:Header

the header to remove.

removeHeadersback to summary
public void removeHeaders(String name)

Removes all headers with a certain name from this message.

Parameters
name:String

The name of the headers to remove.

setHeaderback to summary
public void setHeader(Header header)

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.

Parameters
header:Header

the header to set.

setHeaderback to summary
public void setHeader(String name, String value)

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.

Parameters
name:String

the name of the header.

value:String

the value of the header.

setHeadersback to summary
public void setHeaders(Header[] headers)

Overwrites all the headers in the message.

Parameters
headers:Header[]

the array of headers to set.

setParamsback to summary
public void setParams(HttpParams params)

Deprecated

(4.3) use configuration classes provided 'org.apache.http.config' and 'org.apache.http.client.config'

Provides parameters to be used for the processing of this message.

Parameters
params:HttpParams

the parameters

Annotations
@Deprecated