Interface HttpResponse
-
- All Known Subinterfaces:
MockHttpResponseBuilder
- All Known Implementing Classes:
ProcessAwareHttpResponse
public interface HttpResponseHttpResponsefor theServerHttpConnection.- Author:
- Daniel Sagenschneider
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.nio.charset.CharsetgetContentCharset()Obtains theCharsetfor the content.java.lang.StringgetContentType()Obtains theContent-Type.HttpResponseCookiesgetCookies()Obtains theHttpResponseCookies.ServerOutputStreamgetEntity()Obtains theServerOutputStreamto write the entity of the response.ServerWritergetEntityWriter()Obtains theServerWriterto write the entity of the response.HttpEscalationHandlergetEscalationHandler()Obtains theHttpEscalationHandler.HttpResponseHeadersgetHeaders()Obtains theHttpResponseHeaders.HttpStatusgetStatus()Obtains theHttpStatus.HttpVersiongetVersion()Obtains theHttpVersion.voidreset()Resets theHttpResponseby clearingHttpHeaderinstances and the entity.voidsend()Sends thisHttpResponse.voidsetContentType(java.lang.String contentType, java.nio.charset.Charset charset)Specifies theContent-Typeand optionally theCharset.voidsetContentType(HttpHeaderValue contentTypeAndCharsetValue, java.nio.charset.Charset charset)Provides means to useHttpHeaderValueto specify both theContent-Typeandcharsetfor more efficiency.voidsetEscalationHandler(HttpEscalationHandler escalationHandler)Sets theHttpEscalationHandlerfor the response.voidsetStatus(HttpStatus status)Specifies theHttpStatus.voidsetVersion(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.OKassuming 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.IOExceptionSpecifies the
Content-Typeand optionally theCharset. Thecharsetparameter will automatically be added to theContent-Typeon using thegetEntityWriter().This must be specified before calling
getEntityWriter().- Parameters:
contentType-Content-Type. May benullto unset theContent-Type.charset-Charsetfor theContent-Type. This may benullto use the defaultCharset. Also usenullforContent-Types 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
HttpHeaderValueto specify both theContent-Typeandcharsetfor more efficiency.Note that
HttpHeaderValuewill require the inclusion of thecharset, as thecharsetwill not be appended.- Parameters:
contentTypeAndCharsetValue-HttpHeaderValuefor theContent-Typeandcharset.charset-Charsetto configure theServerWriter.- Throws:
java.io.IOException- If attempting to specify after callinggetEntityWriter().
-
getContentType
java.lang.String getContentType()
Obtains theContent-Type.- Returns:
Content-Type. May benullif noContent-Typehas been specified.
-
getContentCharset
java.nio.charset.Charset getContentCharset()
Obtains the
Charsetfor the content.If no
Charsethas been specified, the defaultCharsetwill be returned.- Returns:
Charset.
-
getEntity
ServerOutputStream getEntity() throws java.io.IOException
Obtains the
ServerOutputStreamto write the entity of the response.Only one of
getEntity()orgetEntityWriter()may be called.Closing the returned
ServerOutputStreamis similar to callingsend().- Returns:
ServerOutputStreamto 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
ServerWriterto write the entity of the response.Only one of
getEntity()orgetEntityWriter()may be called.Closing the returned
ServerOutputStreamis similar to callingsend().- Returns:
ServerWriterto write the entity of the response.- Throws:
java.io.IOException- ShouldgetEntity()already be provided.- See Also:
getEntity(),send()
-
getEscalationHandler
HttpEscalationHandler getEscalationHandler()
Obtains theHttpEscalationHandler.- Returns:
HttpEscalationHandlerornullif noHttpEscalationHandlerconfigured.
-
setEscalationHandler
void setEscalationHandler(HttpEscalationHandler escalationHandler)
Sets theHttpEscalationHandlerfor the response.- Parameters:
escalationHandler-HttpEscalationHandlerfor the response.
-
reset
void reset() throws java.io.IOExceptionResets theHttpResponseby clearingHttpHeaderinstances 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.
-
-