Package org.apache.hc.core5.http
Interface HttpMessage
-
- All Superinterfaces:
MessageHeaders
- All Known Subinterfaces:
ClassicHttpRequest
,ClassicHttpResponse
,HttpRequest
,HttpResponse
- All Known Implementing Classes:
AbstractMessageWrapper
,BasicClassicHttpRequest
,BasicClassicHttpResponse
,BasicHttpRequest
,BasicHttpResponse
,HttpRequestWrapper
,HttpResponseWrapper
public interface HttpMessage extends MessageHeaders
HTTP messages consist of requests from client to server and responses from server to client.- Since:
- 4.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addHeader(java.lang.String name, java.lang.Object value)
Adds a header to this message.void
addHeader(Header header)
Adds a header to this message.ProtocolVersion
getVersion()
Returns protocol version ornull
when not available.boolean
removeHeader(Header header)
Removes a header from this message.boolean
removeHeaders(java.lang.String name)
Removes all headers with a certain name from this message.void
setHeader(java.lang.String name, java.lang.Object value)
Overwrites the first header with the same name.void
setHeader(Header header)
Overwrites the first header with the same name.void
setHeaders(Header... headers)
Overwrites all the headers in the message.void
setVersion(ProtocolVersion version)
Sets protocol version.-
Methods inherited from interface org.apache.hc.core5.http.MessageHeaders
containsHeader, countHeaders, getFirstHeader, getHeader, getHeaders, getHeaders, getLastHeader, headerIterator, headerIterator
-
-
-
-
Method Detail
-
setVersion
void setVersion(ProtocolVersion version)
Sets 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.
- Since:
- 5.0
-
getVersion
ProtocolVersion getVersion()
Returns protocol version ornull
when 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.
- Since:
- 5.0
-
addHeader
void addHeader(Header header)
Adds a header to this message. The header will be appended to the end of the list.- Parameters:
header
- the header to append.
-
addHeader
void addHeader(java.lang.String name, java.lang.Object value)
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, taken as the value'sObject.toString()
.
-
setHeader
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
- the header to set.
-
setHeader
void setHeader(java.lang.String name, java.lang.Object 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
- the name of the header.value
- the value of the header, taken as the value'sObject.toString()
.
-
setHeaders
void setHeaders(Header... headers)
Overwrites all the headers in the message.- Parameters:
headers
- the array of headers to set.
-
removeHeader
boolean removeHeader(Header header)
Removes a header from this message.- Parameters:
header
- the header to remove.- Returns:
true
if a header was removed as a result of this call.
-
removeHeaders
boolean removeHeaders(java.lang.String name)
Removes all headers with a certain name from this message.- Parameters:
name
- The name of the headers to remove.- Returns:
true
if any header was removed as a result of this call.
-
-