use of org.springframework.http.server.ServletServerHttpRequest in project spring-framework by spring-projects.
the class WebSocketHttpRequestHandler method handleRequest.
@Override
public void handleRequest(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws ServletException, IOException {
ServerHttpRequest request = new ServletServerHttpRequest(servletRequest);
ServerHttpResponse response = new ServletServerHttpResponse(servletResponse);
HandshakeInterceptorChain chain = new HandshakeInterceptorChain(this.interceptors, this.wsHandler);
HandshakeFailureException failure = null;
try {
if (logger.isDebugEnabled()) {
logger.debug(servletRequest.getMethod() + " " + servletRequest.getRequestURI());
}
Map<String, Object> attributes = new HashMap<>();
if (!chain.applyBeforeHandshake(request, response, attributes)) {
return;
}
this.handshakeHandler.doHandshake(request, response, this.wsHandler, attributes);
chain.applyAfterHandshake(request, response, null);
response.close();
} catch (HandshakeFailureException ex) {
failure = ex;
} catch (Throwable ex) {
failure = new HandshakeFailureException("Uncaught failure for request " + request.getURI(), ex);
} finally {
if (failure != null) {
chain.applyAfterHandshake(request, response, failure);
throw failure;
}
}
}
use of org.springframework.http.server.ServletServerHttpRequest in project spring-framework by spring-projects.
the class AbstractStandardUpgradeStrategy method getSupportedExtensions.
@Override
public List<WebSocketExtension> getSupportedExtensions(ServerHttpRequest request) {
if (this.extensions == null) {
HttpServletRequest servletRequest = ((ServletServerHttpRequest) request).getServletRequest();
this.extensions = getInstalledExtensions(getContainer(servletRequest));
}
return this.extensions;
}
use of org.springframework.http.server.ServletServerHttpRequest in project spring-framework by spring-projects.
the class AbstractHttpSockJsSession method disableShallowEtagHeaderFilter.
private void disableShallowEtagHeaderFilter(ServerHttpRequest request) {
if (request instanceof ServletServerHttpRequest) {
ServletRequest servletRequest = ((ServletServerHttpRequest) request).getServletRequest();
ShallowEtagHeaderFilter.disableContentCaching(servletRequest);
}
}
use of org.springframework.http.server.ServletServerHttpRequest in project spring-framework by spring-projects.
the class SockJsHttpRequestHandler method handleRequest.
@Override
public void handleRequest(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws ServletException, IOException {
ServerHttpRequest request = new ServletServerHttpRequest(servletRequest);
ServerHttpResponse response = new ServletServerHttpResponse(servletResponse);
try {
this.sockJsService.handleRequest(request, response, getSockJsPath(servletRequest), this.webSocketHandler);
} catch (Throwable ex) {
throw new SockJsException("Uncaught failure in SockJS request, uri=" + request.getURI(), ex);
}
}
use of org.springframework.http.server.ServletServerHttpRequest in project spring-boot by spring-projects.
the class HttpRestartServerTests method sendClassLoaderFiles.
@Test
public void sendClassLoaderFiles() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
ClassLoaderFiles files = new ClassLoaderFiles();
files.addFile("name", new ClassLoaderFile(Kind.ADDED, new byte[0]));
byte[] bytes = serialize(files);
request.setContent(bytes);
this.server.handle(new ServletServerHttpRequest(request), new ServletServerHttpResponse(response));
verify(this.delegate).updateAndRestart(this.filesCaptor.capture());
assertThat(this.filesCaptor.getValue().getFile("name")).isNotNull();
assertThat(response.getStatus()).isEqualTo(200);
}
Aggregations