Top Description Inners Constructors Methods
org.springframework.http.server.reactive

public Class TomcatHttpHandlerAdapter

extends ServletHttpHandlerAdapter
Class Inheritance
Imports
java.io.IOException, java.lang.reflect.Field, java.net.URISyntaxException, java.nio.ByteBuffer, jakarta.servlet.AsyncContext, jakarta.servlet.http.HttpServletRequest, .HttpServletRequestWrapper, .HttpServletResponse, .HttpServletResponseWrapper, org.apache.catalina.connector.CoyoteInputStream, .CoyoteOutputStream, .RequestFacade, .ResponseFacade, org.apache.coyote.Request, .Response, org.springframework.core.io.buffer.DataBuffer, .DataBufferFactory, .DataBufferUtils, org.springframework.http.HttpHeaders, org.springframework.util.Assert, .MultiValueMap, .ReflectionUtils

ServletHttpHandlerAdapter extension that uses Tomcat APIs for reading from the request and writing to the response with ByteBuffer.
Authors
Violeta Georgieva, Brian Clozel, Sam Brannen, Juergen Hoeller
Since
5.0
See Also
org.springframework.web.server.adapter.AbstractReactiveWebInitializer

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected ServletServerHttpRequest
protected ServletServerHttpResponse
Inherited from org.springframework.http.server.reactive.ServletHttpHandlerAdapter:
destroygetBufferSizegetDataBufferFactorygetServletConfiggetServletInfogetServletPathinitservicesetBufferSizesetDataBufferFactory

Constructor Detail

TomcatHttpHandlerAdapterback to summary
public TomcatHttpHandlerAdapter(HttpHandler httpHandler)

Method Detail

createRequestback to summary
protected ServletServerHttpRequest createRequest(HttpServletRequest request, AsyncContext asyncContext) throws IOException, URISyntaxException

Overrides org.springframework.http.server.reactive.ServletHttpHandlerAdapter.createRequest.

Annotations
@Override
createResponseback to summary
protected ServletServerHttpResponse createResponse(HttpServletResponse response, AsyncContext asyncContext, ServletServerHttpRequest request) throws IOException

Overrides org.springframework.http.server.reactive.ServletHttpHandlerAdapter.createResponse.

Annotations
@Override
org.springframework.http.server.reactive back to summary

private final Class TomcatHttpHandlerAdapter.TomcatServerHttpRequest

extends ServletServerHttpRequest
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final int
private static final Field
private final DataBufferFactory
Inherited from org.springframework.http.server.reactive.ServletServerHttpRequest:
EOF_BUFFER

Constructor Summary

AccessConstructor and Description
pack-priv
TomcatServerHttpRequest(HttpServletRequest request, AsyncContext context, String servletPath, DataBufferFactory factory, int bufferSize)

Method Summary

Modifier and TypeMethod and Description
private static MultiValueMap<String, String>
private static RequestFacade
protected DataBuffer
readFromInputStream()

Overrides org.springframework.http.server.reactive.ServletServerHttpRequest.readFromInputStream.

Read from the request body InputStream and return a DataBuffer.
Inherited from org.springframework.http.server.reactive.ServletServerHttpRequest:
getAsyncListenergetBodygetInputStreamgetLocalAddressgetNativeRequestgetRemoteAddressinitCookiesinitSslInfologBytesRead

Field Detail

bufferSizeback to summary
private final int bufferSize
COYOTE_REQUEST_FIELDback to summary
private static final Field COYOTE_REQUEST_FIELD
factoryback to summary
private final DataBufferFactory factory

Constructor Detail

TomcatServerHttpRequestback to summary
pack-priv TomcatServerHttpRequest(HttpServletRequest request, AsyncContext context, String servletPath, DataBufferFactory factory, int bufferSize) throws IOException, URISyntaxException

Method Detail

createTomcatHttpHeadersback to summary
private static MultiValueMap<String, String> createTomcatHttpHeaders(HttpServletRequest request)
getRequestFacadeback to summary
private static RequestFacade getRequestFacade(HttpServletRequest request)
readFromInputStreamback to summary
protected DataBuffer readFromInputStream() throws IOException

Overrides org.springframework.http.server.reactive.ServletServerHttpRequest.readFromInputStream.

Doc from org.springframework.http.server.reactive.ServletServerHttpRequest.readFromInputStream.

Read from the request body InputStream and return a DataBuffer. Invoked only when ServletInputStream#isReady() returns "true".

Returns:DataBuffer

a DataBuffer with data read, or AbstractListenerReadPublisher#EMPTY_BUFFER if 0 bytes were read, or EOF_BUFFER if the input stream returned -1.

Annotations
@Override
org.springframework.http.server.reactive back to summary

private final Class TomcatHttpHandlerAdapter.TomcatServerHttpResponse

extends ServletServerHttpResponse
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final Field

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected void
applyHeaders()

Overrides org.springframework.http.server.reactive.ServletServerHttpResponse.applyHeaders.

Invoked when the response is getting committed allowing subclasses to make apply header values to the underlying response.
private static HttpHeaders
private static ResponseFacade
protected int
writeToOutputStream(DataBuffer dataBuffer)

Overrides org.springframework.http.server.reactive.ServletServerHttpResponse.writeToOutputStream.

Write the DataBuffer to the response body OutputStream.
Inherited from org.springframework.http.server.reactive.ServletServerHttpResponse:
adaptHeadersapplyCookiesapplyStatusCodecreateBodyFlushProcessorgetAsyncListenergetNativeResponsegetOutputStreamgetRawStatusCodegetStatusCode

Field Detail

COYOTE_RESPONSE_FIELDback to summary
private static final Field COYOTE_RESPONSE_FIELD

Constructor Detail

TomcatServerHttpResponseback to summary
pack-priv TomcatServerHttpResponse(HttpServletResponse response, AsyncContext context, DataBufferFactory factory, int bufferSize, ServletServerHttpRequest request) throws IOException

Method Detail

applyHeadersback to summary
protected void applyHeaders()

Overrides org.springframework.http.server.reactive.ServletServerHttpResponse.applyHeaders.

Doc from org.springframework.http.server.reactive.AbstractServerHttpResponse.applyHeaders.

Invoked when the response is getting committed allowing subclasses to make apply header values to the underlying response.

Note that some subclasses use an HttpHeaders instance that wraps an adapter to the native response headers such that changes are propagated to the underlying response on the go. That means this callback might not be used other than for specialized updates such as setting the contentType or characterEncoding fields in a Servlet response.

Annotations
@Override
createTomcatHttpHeadersback to summary
private static HttpHeaders createTomcatHttpHeaders(HttpServletResponse response)
getResponseFacadeback to summary
private static ResponseFacade getResponseFacade(HttpServletResponse response)
writeToOutputStreamback to summary
protected int writeToOutputStream(DataBuffer dataBuffer) throws IOException

Overrides org.springframework.http.server.reactive.ServletServerHttpResponse.writeToOutputStream.

Doc from org.springframework.http.server.reactive.ServletServerHttpResponse.writeToOutputStream.

Write the DataBuffer to the response body OutputStream. Invoked only when ServletOutputStream#isReady() returns "true" and the readable bytes in the DataBuffer is greater than 0.

Returns:int

the number of bytes written

Annotations
@Override