use of org.springframework.http.server.ServerHttpRequest 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.ServerHttpRequest 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.ServerHttpRequest in project spring-boot by spring-projects.
the class HttpTunnelServerTests method httpConnectionAsync.
@Test
public void httpConnectionAsync() throws Exception {
ServerHttpAsyncRequestControl async = mock(ServerHttpAsyncRequestControl.class);
ServerHttpRequest request = mock(ServerHttpRequest.class);
given(request.getAsyncRequestControl(this.response)).willReturn(async);
HttpConnection connection = new HttpConnection(request, this.response);
connection.waitForResponse();
verify(async).start();
connection.respond(HttpStatus.NO_CONTENT);
verify(async).complete();
}
use of org.springframework.http.server.ServerHttpRequest in project spring-boot by spring-projects.
the class UrlHandlerMapperTests method ignoresDifferentUrl.
@Test
public void ignoresDifferentUrl() throws Exception {
UrlHandlerMapper mapper = new UrlHandlerMapper("/tunnel", this.handler);
HttpServletRequest servletRequest = new MockHttpServletRequest("GET", "/tunnel/other");
ServerHttpRequest request = new ServletServerHttpRequest(servletRequest);
assertThat(mapper.getHandler(request)).isNull();
}
Aggregations