Class ServletContextResponse
- All Implemented Interfaces:
ServletContextHandler.ServletResponseInfo, Content.Sink, Response
ServletApiResponse.
Non servlet related state, is used indirectly via ServletChannel.getResponse()
which may be a wrapper of this response.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enumprotected static enumNested classes/interfaces inherited from interface Response
Response.Wrapper -
Constructor Summary
ConstructorsConstructorDescriptionServletContextResponse(ServletChannel servletChannel, ServletContextRequest request, Response response) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidcompleteOutput(Callback callback) getCharacterEncoding(boolean setContentType) longprotected MimeTypes.TypeGet the raw value of the Character Encoding field.protected ServletContextRequeststatic ServletContextResponsegetServletContextResponse(jakarta.servlet.ServletResponse response) voidincluded()booleanisAllContentWritten(long written) booleanisContentIncomplete(long written) booleanbooleanbooleanprotected ServletApiResponsevoidreset()Resets this response, clearing the HTTP status code, HTTP headers and HTTP trailers.voidvoidvoidsetCharacterEncoding(String encoding, ServletContextResponse.EncodingFrom from) Update the Content-Type, MimeType, and headers from the provided Character Encoding and EncodingFrom.voidsetContentLength(int len) voidsetContentLength(long len) voidvoidsetOutputType(ServletContextResponse.OutputType outputType) voidsetTrailers(Supplier<Map<String, String>> trailers) voidsetWriter(ResponseWriter writer) voidwrite(boolean last, ByteBuffer content, Callback callback) Writes the givenByteBuffer, notifying theCallbackwhen the write is complete.Methods inherited from class Response.Wrapper
getRequest, getStatus, getTrailersSupplier, getWrapped, hasLastWrite, isCommitted, isCompletedSuccessfully, setStatus, setTrailersSupplier, writeInterim
-
Constructor Details
-
ServletContextResponse
public ServletContextResponse(ServletChannel servletChannel, ServletContextRequest request, Response response)
-
-
Method Details
-
getServletContextResponse
public static ServletContextResponse getServletContextResponse(jakarta.servlet.ServletResponse response) -
getResponse
- Specified by:
getResponsein interfaceServletContextHandler.ServletResponseInfo
-
getWriter
- Specified by:
getWriterin interfaceServletContextHandler.ServletResponseInfo
-
setWriter
- Specified by:
setWriterin interfaceServletContextHandler.ServletResponseInfo
-
getLocale
- Specified by:
getLocalein interfaceServletContextHandler.ServletResponseInfo
-
setLocale
- Specified by:
setLocalein interfaceServletContextHandler.ServletResponseInfo
-
getEncodingFrom
- Specified by:
getEncodingFromin interfaceServletContextHandler.ServletResponseInfo
-
getMimeType
-
getTrailers
- Specified by:
getTrailersin interfaceServletContextHandler.ServletResponseInfo
-
setTrailers
- Specified by:
setTrailersin interfaceServletContextHandler.ServletResponseInfo
-
getCharacterEncoding
- Specified by:
getCharacterEncodingin interfaceServletContextHandler.ServletResponseInfo
-
setOutputType
- Specified by:
setOutputTypein interfaceServletContextHandler.ServletResponseInfo
-
getContentType
- Specified by:
getContentTypein interfaceServletContextHandler.ServletResponseInfo
-
getOutputType
- Specified by:
getOutputTypein interfaceServletContextHandler.ServletResponseInfo
-
getServletContextRequest
-
newServletApiResponse
-
getHttpOutput
-
getServletRequestState
-
getServletApiResponse
-
resetForForward
public void resetForForward() -
included
public void included() -
completeOutput
-
isAllContentWritten
public boolean isAllContentWritten(long written) -
isContentIncomplete
public boolean isContentIncomplete(long written) -
setContentLength
public void setContentLength(int len) -
getHeaders
- Specified by:
getHeadersin interfaceResponse- Overrides:
getHeadersin classResponse.Wrapper- Returns:
- the response HTTP headers
-
setContentLength
public void setContentLength(long len) -
getContentLength
public long getContentLength() -
write
Description copied from interface:ResponseWrites the given
ByteBuffer, notifying theCallbackwhen the write is complete.Implementations guarantee that calls to this method are safely reentrant so that stack overflows are avoided in the case of mutual recursion between the execution of the
Callbackand a call to this method.The invocation of the passed
Callbackis serialized with previous calls of this method, so that it is not invoked until any invocation of the callback of a previous call to this method has returned.Thus a
Callbackshould not block waiting for a callback of a future call to this method.- Specified by:
writein interfaceContent.Sink- Specified by:
writein interfaceResponse- Overrides:
writein classContextResponse- Parameters:
last- whether the ByteBuffer is the last to writecontent- the ByteBuffer to writecallback- the callback to notify when the write operation is complete
-
closeOutput
- Throws:
IOException
-
reset
public void reset()Description copied from interface:ResponseResets this response, clearing the HTTP status code, HTTP headers and HTTP trailers.
- Specified by:
resetin interfaceResponse- Overrides:
resetin classResponse.Wrapper
-
resetContent
public void resetContent() -
getRawCharacterEncoding
Get the raw value of the Character Encoding field.This is only the value as set, not from any other discovered source (eg: mimetypes, Content-Type, ServletContext, etc)
- Returns:
- the raw character encoding
-
getCharacterEncoding
- Specified by:
getCharacterEncodingin interfaceServletContextHandler.ServletResponseInfo
-
setCharacterEncoding
Update the Content-Type, MimeType, and headers from the provided Character Encoding and EncodingFrom.- Specified by:
setCharacterEncodingin interfaceServletContextHandler.ServletResponseInfo- Parameters:
encoding- the character encodingfrom- where encoding came from
-
isWriting
public boolean isWriting()- Specified by:
isWritingin interfaceServletContextHandler.ServletResponseInfo
-
isStreaming
public boolean isStreaming() -
isWritingOrStreaming
public boolean isWritingOrStreaming()
-