@Override public boolean isActive() { ServerHttpAsyncRequestControl control = this.asyncRequestControl; return (control != null && !control.isCompleted()); }
/** * Parse the path value into a sequence of {@link Separator Separator} and * {@link PathSegment PathSegment} elements. * @param path the encoded, raw URL path value to parse * @return the parsed path */ static PathContainer parsePath(String path) { return DefaultPathContainer.createFromUrlPath(path); }
@Override public void close() { this.delegate.close(); } }
@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); } }
private boolean isResourceNotModified(ServletServerHttpRequest request, ServletServerHttpResponse response) { ServletWebRequest servletWebRequest = new ServletWebRequest(request.getServletRequest(), response.getServletResponse()); HttpHeaders responseHeaders = response.getHeaders(); String etag = responseHeaders.getETag(); long lastModifiedTimestamp = responseHeaders.getLastModified(); if (request.getMethod() == HttpMethod.GET || request.getMethod() == HttpMethod.HEAD) { responseHeaders.remove(HttpHeaders.ETAG); responseHeaders.remove(HttpHeaders.LAST_MODIFIED); } return servletWebRequest.checkNotModified(etag, lastModifiedTimestamp); }
/** * Return the context path of the current web application. This is * useful for building links to other resources within the application. * <p>Delegates to {@link ServerHttpRequest#getPath()}. */ public String getContextPath() { return this.exchange.getRequest().getPath().contextPath().value(); }
@Override public String value() { return this.fullPath.value(); }
@Override public void setStatusCode(HttpStatus status) { this.delegate.setStatusCode(status); }
@Override public void flush() throws IOException { this.delegate.flush(); }
@Override public OutputStream getBody() throws IOException { return this.delegate.getBody(); }
public static PathContainer toPathContainer(String path) { if (path == null) { return null; } return PathContainer.parsePath(path); }
private DefaultRequestPath(RequestPath requestPath, String contextPath) { this.fullPath = requestPath; this.contextPath = initContextPath(this.fullPath, contextPath); this.pathWithinApplication = extractPathWithinApplication(this.fullPath, this.contextPath); }
@Override public List<Element> elements() { return this.fullPath.elements(); }
/** * Extract a sub-path from the given start offset (inclusive) into the * element list and to the end offset (exclusive). * @param startIndex the start element index (inclusive) * @param endIndex the end element index (exclusive) * @return the sub-path */ default PathContainer subPath(int startIndex, int endIndex) { return DefaultPathContainer.subPath(this, startIndex, endIndex); }
@Override public String toString() { return value(); }
@Override public void start() { start(NO_TIMEOUT_VALUE); }
@Override public RequestPath modifyContextPath(String contextPath) { return new DefaultRequestPath(this, contextPath); }
@Override public void close() { writeHeaders(); }
@GetMapping("/test") public String handle(ServerHttpRequest request) { return "Tested in " + request.getPath().contextPath().value(); } }
@Override public String path() { return this.pathContainer.value(); }