Package org.apache.http
Interface HttpMessage
- All Known Subinterfaces:
CloseableHttpResponse
,HttpEntityEnclosingRequest
,HttpRequest
,HttpResponse
,HttpUriRequest
- All Known Implementing Classes:
AbstractExecutionAwareRequest
,AbstractHttpMessage
,BaseDavRequest
,BasicHttpEntityEnclosingRequest
,BasicHttpRequest
,BasicHttpResponse
,EntityEnclosingRequestWrapper
,HttpBind
,HttpCheckin
,HttpCheckout
,HttpCopy
,HttpDelete
,HttpDelete
,HttpEntityEnclosingRequestBase
,HttpGet
,HttpHead
,HttpLabel
,HttpLock
,HttpMerge
,HttpMkcol
,HttpMkworkspace
,HttpMove
,HttpOptions
,HttpOptions
,HttpOrderpatch
,HttpPatch
,HttpPoll
,HttpPost
,HttpPropfind
,HttpProppatch
,HttpPut
,HttpRebind
,HttpReport
,HttpRequestBase
,HttpRequestWrapper
,HttpSearch
,HttpSubscribe
,HttpTrace
,HttpUnbind
,HttpUnlock
,HttpUnsubscribe
,HttpUpdate
,HttpVersionControl
,RequestWrapper
public interface HttpMessage
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 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 configuration classes provided 'org.apache.http.config' and 'org.apache.http.client.config'Returns the protocol version this message is compatible with.Returns 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 configuration classes provided 'org.apache.http.config' and 'org.apache.http.client.config'
-
Method Details
-
getProtocolVersion
ProtocolVersion getProtocolVersion()Returns the protocol version this message is compatible with. -
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.
-
getHeaders
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
- the name of the headers to return.- Returns:
- the headers whose name property equals
name
.
-
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.
-
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.
-
getAllHeaders
Header[] getAllHeaders()Returns all the headers of this message. Headers are orderd in the sequence they will be sent over a connection.- Returns:
- all the headers of this message
-
addHeader
Adds a header to this message. The header will be appended to the end of the list.- Parameters:
header
- the header to append.
-
addHeader
Adds a header to this message. The header will be appended to the end of the list.- Parameters:
name
- the name of the header.value
- the value of the header.
-
setHeader
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
- the header to set.
-
setHeader
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
- the name of the header.value
- the value of the header.
-
setHeaders
Overwrites all the headers in the message.- Parameters:
headers
- the array of headers to set.
-
removeHeader
Removes a header from this message.- Parameters:
header
- the header to remove.
-
removeHeaders
Removes all headers with a certain name from this message.- Parameters:
name
- The name of the headers to remove.
-
headerIterator
HeaderIterator 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.
-
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 bysetParams(HttpParams)
. -
setParams
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
- the parameters
-