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);
}
}
use of org.springframework.http.server.ServerHttpResponse in project spring-framework by spring-projects.
the class AbstractHttpSockJsSession method writeFrameInternal.
@Override
protected void writeFrameInternal(SockJsFrame frame) throws IOException {
if (isActive()) {
SockJsFrameFormat frameFormat = this.frameFormat;
ServerHttpResponse response = this.response;
if (frameFormat != null && response != null) {
String formattedFrame = frameFormat.format(frame);
if (logger.isTraceEnabled()) {
logger.trace("Writing to HTTP response: " + formattedFrame);
}
response.getBody().write(formattedFrame.getBytes(SockJsFrame.CHARSET));
response.flush();
}
}
}
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);
} catch (HandshakeFailureException ex) {
failure = ex;
} catch (Exception ex) {
failure = new HandshakeFailureException("Uncaught failure for request " + request.getURI(), ex);
} finally {
if (failure != null) {
chain.applyAfterHandshake(request, response, failure);
response.close();
throw failure;
}
response.close();
}
}
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 (Exception ex) {
throw new SockJsException("Uncaught failure in SockJS request, uri=" + request.getURI(), ex);
}
}
Aggregations