Interface HttpResponse
-
- All Known Subinterfaces:
MockHttpResponseBuilder
- All Known Implementing Classes:
ProcessAwareHttpResponse
public interface HttpResponse
HttpResponse
for theServerHttpConnection
.- Author:
- Daniel Sagenschneider
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.nio.charset.Charset
getContentCharset()
Obtains theCharset
for the content.java.lang.String
getContentType()
Obtains theContent-Type
.HttpResponseCookies
getCookies()
Obtains theHttpResponseCookies
.ServerOutputStream
getEntity()
Obtains theServerOutputStream
to write the entity of the response.ServerWriter
getEntityWriter()
Obtains theServerWriter
to write the entity of the response.HttpEscalationHandler
getEscalationHandler()
Obtains theHttpEscalationHandler
.HttpResponseHeaders
getHeaders()
Obtains theHttpResponseHeaders
.HttpStatus
getStatus()
Obtains theHttpStatus
.HttpVersion
getVersion()
Obtains theHttpVersion
.void
reset()
Resets theHttpResponse
by clearingHttpHeader
instances and the entity.void
send()
Sends thisHttpResponse
.void
setContentType(java.lang.String contentType, java.nio.charset.Charset charset)
Specifies theContent-Type
and optionally theCharset
.void
setContentType(HttpHeaderValue contentTypeAndCharsetValue, java.nio.charset.Charset charset)
Provides means to useHttpHeaderValue
to specify both theContent-Type
andcharset
for more efficiency.void
setEscalationHandler(HttpEscalationHandler escalationHandler)
Sets theHttpEscalationHandler
for the response.void
setStatus(HttpStatus status)
Specifies theHttpStatus
.void
setVersion(HttpVersion version)
Override theHttpVersion
.
-
-
-
Method Detail
-
getVersion
HttpVersion getVersion()
Obtains theHttpVersion
.- Returns:
HttpVersion
.
-
setVersion
void setVersion(HttpVersion version)
Override the
HttpVersion
.This defaults to value on
HttpRequest
.- Parameters:
version
-HttpVersion
.
-
getStatus
HttpStatus getStatus()
Obtains the
HttpStatus
.This is the current status. The status may changed based on particular HTTP rules (e.g. 200 becoming 204 due to no entity) or there being a failure in processing the message.
- Returns:
- Current
HttpStatus
.
-
setStatus
void setStatus(HttpStatus status)
Specifies the
HttpStatus
.This defaults to
HttpStatus.OK
assuming the request was processed successfully.- Parameters:
status
-HttpStatus
.
-
getHeaders
HttpResponseHeaders getHeaders()
Obtains theHttpResponseHeaders
.- Returns:
HttpResponseHeaders
.
-
getCookies
HttpResponseCookies getCookies()
Obtains theHttpResponseCookies
.- Returns:
HttpResponseCookies
.
-
setContentType
void setContentType(java.lang.String contentType, java.nio.charset.Charset charset) throws java.io.IOException
Specifies the
Content-Type
and optionally theCharset
. Thecharset
parameter will automatically be added to theContent-Type
on using thegetEntityWriter()
.This must be specified before calling
getEntityWriter()
.- Parameters:
contentType
-Content-Type
. May benull
to unset theContent-Type
.charset
-Charset
for theContent-Type
. This may benull
to use the defaultCharset
. Also usenull
forContent-Type
s that do not require character encoding (including the default HTTP content encoding).- Throws:
java.io.IOException
- If attempting to specify after callinggetEntityWriter()
.
-
setContentType
void setContentType(HttpHeaderValue contentTypeAndCharsetValue, java.nio.charset.Charset charset) throws java.io.IOException
Provides means to use
HttpHeaderValue
to specify both theContent-Type
andcharset
for more efficiency.Note that
HttpHeaderValue
will require the inclusion of thecharset
, as thecharset
will not be appended.- Parameters:
contentTypeAndCharsetValue
-HttpHeaderValue
for theContent-Type
andcharset
.charset
-Charset
to configure theServerWriter
.- Throws:
java.io.IOException
- If attempting to specify after callinggetEntityWriter()
.
-
getContentType
java.lang.String getContentType()
Obtains theContent-Type
.- Returns:
Content-Type
. May benull
if noContent-Type
has been specified.
-
getContentCharset
java.nio.charset.Charset getContentCharset()
Obtains the
Charset
for the content.If no
Charset
has been specified, the defaultCharset
will be returned.- Returns:
Charset
.
-
getEntity
ServerOutputStream getEntity() throws java.io.IOException
Obtains the
ServerOutputStream
to write the entity of the response.Only one of
getEntity()
orgetEntityWriter()
may be called.Closing the returned
ServerOutputStream
is similar to callingsend()
.- Returns:
ServerOutputStream
to write the entity of the response.- Throws:
java.io.IOException
- ShouldgetEntityWriter()
already be provided.- See Also:
getEntityWriter()
,send()
-
getEntityWriter
ServerWriter getEntityWriter() throws java.io.IOException
Obtains the
ServerWriter
to write the entity of the response.Only one of
getEntity()
orgetEntityWriter()
may be called.Closing the returned
ServerOutputStream
is similar to callingsend()
.- Returns:
ServerWriter
to write the entity of the response.- Throws:
java.io.IOException
- ShouldgetEntity()
already be provided.- See Also:
getEntity()
,send()
-
getEscalationHandler
HttpEscalationHandler getEscalationHandler()
Obtains theHttpEscalationHandler
.- Returns:
HttpEscalationHandler
ornull
if noHttpEscalationHandler
configured.
-
setEscalationHandler
void setEscalationHandler(HttpEscalationHandler escalationHandler)
Sets theHttpEscalationHandler
for the response.- Parameters:
escalationHandler
-HttpEscalationHandler
for the response.
-
reset
void reset() throws java.io.IOException
Resets theHttpResponse
by clearingHttpHeader
instances and the entity.- Throws:
java.io.IOException
- If committed to send theHttpResponse
.
-
send
void send() throws java.io.IOException
- Throws:
java.io.IOException
- If fails to send thisHttpResponse
.
-
-