Search in sources :

Example 6 with ServerHttpResponse

use of org.springframework.http.server.ServerHttpResponse in project spring-boot by spring-projects.

the class HttpRestartServerHandlerTests method handleDelegatesToServer.

@Test
public void handleDelegatesToServer() throws Exception {
    HttpRestartServer server = mock(HttpRestartServer.class);
    HttpRestartServerHandler handler = new HttpRestartServerHandler(server);
    ServerHttpRequest request = mock(ServerHttpRequest.class);
    ServerHttpResponse response = mock(ServerHttpResponse.class);
    handler.handle(request, response);
    verify(server).handle(request, response);
}
Also used : ServerHttpRequest(org.springframework.http.server.ServerHttpRequest) ServerHttpResponse(org.springframework.http.server.ServerHttpResponse) Test(org.junit.Test)

Example 7 with ServerHttpResponse

use of org.springframework.http.server.ServerHttpResponse in project spring-boot by spring-projects.

the class DispatcherFilter method doFilter.

private void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
    ServerHttpRequest serverRequest = new ServletServerHttpRequest(request);
    ServerHttpResponse serverResponse = new ServletServerHttpResponse(response);
    if (!this.dispatcher.handle(serverRequest, serverResponse)) {
        chain.doFilter(request, response);
    }
}
Also used : ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) ServerHttpRequest(org.springframework.http.server.ServerHttpRequest) ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) ServletServerHttpResponse(org.springframework.http.server.ServletServerHttpResponse) ServerHttpResponse(org.springframework.http.server.ServerHttpResponse) ServletServerHttpResponse(org.springframework.http.server.ServletServerHttpResponse)

Example 8 with ServerHttpResponse

use of org.springframework.http.server.ServerHttpResponse 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;
        }
    }
}
Also used : ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) HashMap(java.util.HashMap) ServerHttpRequest(org.springframework.http.server.ServerHttpRequest) ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) HandshakeFailureException(org.springframework.web.socket.server.HandshakeFailureException) ServletServerHttpResponse(org.springframework.http.server.ServletServerHttpResponse) ServerHttpResponse(org.springframework.http.server.ServerHttpResponse) ServletServerHttpResponse(org.springframework.http.server.ServletServerHttpResponse)

Example 9 with ServerHttpResponse

use of org.springframework.http.server.ServerHttpResponse 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);
    }
}
Also used : ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) SockJsException(org.springframework.web.socket.sockjs.SockJsException) ServerHttpRequest(org.springframework.http.server.ServerHttpRequest) ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) ServletServerHttpResponse(org.springframework.http.server.ServletServerHttpResponse) ServerHttpResponse(org.springframework.http.server.ServerHttpResponse) ServletServerHttpResponse(org.springframework.http.server.ServletServerHttpResponse)

Aggregations

ServerHttpResponse (org.springframework.http.server.ServerHttpResponse)9 ServletServerHttpResponse (org.springframework.http.server.ServletServerHttpResponse)7 ServerHttpRequest (org.springframework.http.server.ServerHttpRequest)6 ServletServerHttpRequest (org.springframework.http.server.ServletServerHttpRequest)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)3 Test (org.junit.Test)3 ResponseEntity (org.springframework.http.ResponseEntity)3 ServletRequest (javax.servlet.ServletRequest)2 HashMap (java.util.HashMap)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpHeaders (org.springframework.http.HttpHeaders)1 HttpInputMessage (org.springframework.http.HttpInputMessage)1 HttpOutputMessage (org.springframework.http.HttpOutputMessage)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1 DeferredResult (org.springframework.web.context.request.async.DeferredResult)1 HandshakeFailureException (org.springframework.web.socket.server.HandshakeFailureException)1 SockJsException (org.springframework.web.socket.sockjs.SockJsException)1