Class ProcessAwareHttpResponse<B>
- All Implemented Interfaces:
HttpExternalResponse,HttpResponse,CloseHandler
- Author:
- Daniel Sagenschneider
-
Constructor Summary
ConstructorsConstructorDescriptionProcessAwareHttpResponse(ProcessAwareServerHttpConnectionManagedObject<B> serverHttpConnection, HttpVersion version, ManagedObjectContext managedObjectContext) Instantiate. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Handles the close.voidFlags thatHttpResponseis externally sent.voidflushResponseToHttpResponseWriter(Throwable escalation) Flushes theHttpResponseto theHttpResponseWriter.Obtains 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.booleanisClosed()Indicates if closed.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.
-
Constructor Details
-
ProcessAwareHttpResponse
public ProcessAwareHttpResponse(ProcessAwareServerHttpConnectionManagedObject<B> serverHttpConnection, HttpVersion version, ManagedObjectContext managedObjectContext) Instantiate.- Parameters:
serverHttpConnection-ServerHttpConnection.version-HttpVersion.managedObjectContext-ManagedObjectContext.
-
-
Method Details
-
flushResponseToHttpResponseWriter
Flushes theHttpResponseto theHttpResponseWriter.- Parameters:
escalation- Possible escalation in servicing. Will benullif successful.- Throws:
IOException- If fails to flushHttpResponseto theHttpResponseWriter.
-
getVersion
Description copied from interface:HttpResponseObtains theHttpVersion.- Specified by:
getVersionin interfaceHttpResponse- Returns:
HttpVersion.
-
setVersion
Description copied from interface:HttpResponseOverride the
HttpVersion.This defaults to value on
HttpRequest.- Specified by:
setVersionin interfaceHttpResponse- Parameters:
version-HttpVersion.
-
getStatus
Description copied from interface:HttpResponseObtains 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.
- Specified by:
getStatusin interfaceHttpResponse- Returns:
- Current
HttpStatus.
-
setStatus
Description copied from interface:HttpResponseSpecifies the
HttpStatus.This defaults to
HttpStatus.OKassuming the request was processed successfully.- Specified by:
setStatusin interfaceHttpResponse- Parameters:
status-HttpStatus.
-
getHeaders
Description copied from interface:HttpResponseObtains theHttpResponseHeaders.- Specified by:
getHeadersin interfaceHttpResponse- Returns:
HttpResponseHeaders.
-
getCookies
Description copied from interface:HttpResponseObtains theHttpResponseCookies.- Specified by:
getCookiesin interfaceHttpResponse- Returns:
HttpResponseCookies.
-
setContentType
Description copied from interface:HttpResponseSpecifies the
Content-Typeand optionally theCharset. Thecharsetparameter will automatically be added to theContent-Typeon using theHttpResponse.getEntityWriter().This must be specified before calling
HttpResponse.getEntityWriter().- Specified by:
setContentTypein interfaceHttpResponse- 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 callingHttpResponse.getEntityWriter().
-
setContentType
public void setContentType(HttpHeaderValue contentTypeAndCharsetValue, Charset charset) throws IOException Description copied from interface:HttpResponseProvides means to use
HttpHeaderValueto specify both theContent-Typeandcharsetfor more efficiency.Note that
HttpHeaderValuewill require the inclusion of thecharset, as thecharsetwill not be appended.- Specified by:
setContentTypein interfaceHttpResponse- Parameters:
contentTypeAndCharsetValue-HttpHeaderValuefor theContent-Typeandcharset.charset-Charsetto configure theServerWriter.- Throws:
IOException- If attempting to specify after callingHttpResponse.getEntityWriter().
-
getContentType
Description copied from interface:HttpResponseObtains theContent-Type.- Specified by:
getContentTypein interfaceHttpResponse- Returns:
Content-Type. May benullif noContent-Typehas been specified.
-
getContentCharset
Description copied from interface:HttpResponseObtains the
Charsetfor the content.If no
Charsethas been specified, the defaultCharsetwill be returned.- Specified by:
getContentCharsetin interfaceHttpResponse- Returns:
Charset.
-
getEntity
Description copied from interface:HttpResponseObtains the
ServerOutputStreamto write the entity of the response.Only one of
HttpResponse.getEntity()orHttpResponse.getEntityWriter()may be called.Closing the returned
ServerOutputStreamis similar to callingHttpResponse.send().- Specified by:
getEntityin interfaceHttpResponse- Returns:
ServerOutputStreamto write the entity of the response.- Throws:
IOException- ShouldHttpResponse.getEntityWriter()already be provided.- See Also:
-
getEntityWriter
Description copied from interface:HttpResponseObtains the
ServerWriterto write the entity of the response.Only one of
HttpResponse.getEntity()orHttpResponse.getEntityWriter()may be called.Closing the returned
ServerOutputStreamis similar to callingHttpResponse.send().- Specified by:
getEntityWriterin interfaceHttpResponse- Returns:
ServerWriterto write the entity of the response.- Throws:
IOException- ShouldHttpResponse.getEntity()already be provided.- See Also:
-
getEscalationHandler
Description copied from interface:HttpResponseObtains theHttpEscalationHandler.- Specified by:
getEscalationHandlerin interfaceHttpResponse- Returns:
HttpEscalationHandlerornullif noHttpEscalationHandlerconfigured.
-
setEscalationHandler
Description copied from interface:HttpResponseSets theHttpEscalationHandlerfor the response.- Specified by:
setEscalationHandlerin interfaceHttpResponse- Parameters:
escalationHandler-HttpEscalationHandlerfor the response.
-
reset
Description copied from interface:HttpResponseResets theHttpResponseby clearingHttpHeaderinstances and the entity.- Specified by:
resetin interfaceHttpResponse- Throws:
IOException- If committed to send theHttpResponse.
-
send
Description copied from interface:HttpResponse- Specified by:
sendin interfaceHttpResponse- Throws:
IOException- If fails to send thisHttpResponse.
-
externalSend
public void externalSend()Description copied from interface:HttpExternalResponseFlags thatHttpResponseis externally sent.- Specified by:
externalSendin interfaceHttpExternalResponse
-
isClosed
public boolean isClosed()Description copied from interface:CloseHandlerIndicates if closed.- Specified by:
isClosedin interfaceCloseHandler- Returns:
trueif closed.
-
close
Description copied from interface:CloseHandlerHandles the close.- Specified by:
closein interfaceCloseHandler- Throws:
IOException- If fails to close.
-