Interface HttpResponse
- All Known Subinterfaces:
MockHttpResponseBuilder
- All Known Implementing Classes:
ProcessAwareHttpResponse
HttpResponse for the ServerHttpConnection.- Author:
- Daniel Sagenschneider
-
Method Summary
Modifier and TypeMethodDescriptionObtains theCharsetfor the content.Obtains theContent-Type.Obtains theHttpResponseCookies.Obtains theServerOutputStreamto write the entity of the response.Obtains theServerWriterto write the entity of the response.Obtains theHttpEscalationHandler.Obtains theHttpResponseHeaders.Obtains theHttpStatus.Obtains theHttpVersion.voidreset()Resets theHttpResponseby clearingHttpHeaderinstances and the entity.voidsend()Sends thisHttpResponse.voidsetContentType(String contentType, Charset charset) Specifies theContent-Typeand optionally theCharset.voidsetContentType(HttpHeaderValue contentTypeAndCharsetValue, 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 Details
-
getVersion
HttpVersion getVersion()Obtains theHttpVersion.- Returns:
HttpVersion.
-
setVersion
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
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
Specifies 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:
IOException- If attempting to specify after callinggetEntityWriter().
-
setContentType
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:
IOException- If attempting to specify after callinggetEntityWriter().
-
getContentType
String getContentType()Obtains theContent-Type.- Returns:
Content-Type. May benullif noContent-Typehas been specified.
-
getContentCharset
Charset getContentCharset()Obtains the
Charsetfor the content.If no
Charsethas been specified, the defaultCharsetwill be returned.- Returns:
Charset.
-
getEntity
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:
IOException- ShouldgetEntityWriter()already be provided.- See Also:
-
getEntityWriter
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:
IOException- ShouldgetEntity()already be provided.- See Also:
-
getEscalationHandler
HttpEscalationHandler getEscalationHandler()Obtains theHttpEscalationHandler.- Returns:
HttpEscalationHandlerornullif noHttpEscalationHandlerconfigured.
-
setEscalationHandler
Sets theHttpEscalationHandlerfor the response.- Parameters:
escalationHandler-HttpEscalationHandlerfor the response.
-
reset
Resets theHttpResponseby clearingHttpHeaderinstances and the entity.- Throws:
IOException- If committed to send theHttpResponse.
-
send
- Throws:
IOException- If fails to send thisHttpResponse.
-