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
Modifier and TypeClassDescriptionprotected static enum
protected static enum
Nested classes/interfaces inherited from interface org.eclipse.jetty.server.Response
Response.Wrapper
-
Constructor Summary
ConstructorDescriptionServletContextResponse
(ServletChannel servletChannel, ServletContextRequest request, Response response) -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
completeOutput
(Callback callback) getCharacterEncoding
(boolean setContentType) long
protected MimeTypes.Type
Get the raw value of the Character Encoding field.protected ServletContextRequest
static ServletContextResponse
getServletContextResponse
(jakarta.servlet.ServletResponse response) void
included()
boolean
isAllContentWritten
(long written) boolean
isContentIncomplete
(long written) boolean
boolean
boolean
protected ServletApiResponse
void
reset()
Resets this response, clearing the HTTP status code, HTTP headers and HTTP trailers.void
void
void
setCharacterEncoding
(String encoding, ServletContextResponse.EncodingFrom from) Update the Content-Type, MimeType, and headers from the provided Character Encoding and EncodingFrom.void
setContentLength
(int len) void
setContentLength
(long len) void
void
setOutputType
(ServletContextResponse.OutputType outputType) void
setTrailers
(Supplier<Map<String, String>> trailers) void
setWriter
(ResponseWriter writer) void
write
(boolean last, ByteBuffer content, Callback callback) Writes the givenByteBuffer
, notifying theCallback
when the write is complete.Methods inherited from class org.eclipse.jetty.server.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:
getResponse
in interfaceServletContextHandler.ServletResponseInfo
-
getWriter
- Specified by:
getWriter
in interfaceServletContextHandler.ServletResponseInfo
-
setWriter
- Specified by:
setWriter
in interfaceServletContextHandler.ServletResponseInfo
-
getLocale
- Specified by:
getLocale
in interfaceServletContextHandler.ServletResponseInfo
-
setLocale
- Specified by:
setLocale
in interfaceServletContextHandler.ServletResponseInfo
-
getEncodingFrom
- Specified by:
getEncodingFrom
in interfaceServletContextHandler.ServletResponseInfo
-
getMimeType
-
getTrailers
- Specified by:
getTrailers
in interfaceServletContextHandler.ServletResponseInfo
-
setTrailers
- Specified by:
setTrailers
in interfaceServletContextHandler.ServletResponseInfo
-
getCharacterEncoding
- Specified by:
getCharacterEncoding
in interfaceServletContextHandler.ServletResponseInfo
-
setOutputType
- Specified by:
setOutputType
in interfaceServletContextHandler.ServletResponseInfo
-
getContentType
- Specified by:
getContentType
in interfaceServletContextHandler.ServletResponseInfo
-
getOutputType
- Specified by:
getOutputType
in 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:
getHeaders
in interfaceResponse
- Overrides:
getHeaders
in classResponse.Wrapper
- Returns:
- the response HTTP headers
-
setContentLength
public void setContentLength(long len) -
getContentLength
public long getContentLength() -
write
Description copied from interface:Response
Writes the given
ByteBuffer
, notifying theCallback
when 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
Callback
and a call to this method.The invocation of the passed
Callback
is 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
Callback
should not block waiting for a callback of a future call to this method.- Specified by:
write
in interfaceContent.Sink
- Specified by:
write
in interfaceResponse
- Overrides:
write
in 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:Response
Resets this response, clearing the HTTP status code, HTTP headers and HTTP trailers.
- Specified by:
reset
in interfaceResponse
- Overrides:
reset
in 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:
getCharacterEncoding
in interfaceServletContextHandler.ServletResponseInfo
-
setCharacterEncoding
Update the Content-Type, MimeType, and headers from the provided Character Encoding and EncodingFrom.- Specified by:
setCharacterEncoding
in interfaceServletContextHandler.ServletResponseInfo
- Parameters:
encoding
- the character encodingfrom
- where encoding came from
-
isWriting
public boolean isWriting()- Specified by:
isWriting
in interfaceServletContextHandler.ServletResponseInfo
-
isStreaming
public boolean isStreaming() -
isWritingOrStreaming
public boolean isWritingOrStreaming()
-