private void handleFullUrl(ParseState state, HttpServerExchange exchange, int canonicalPathStart, boolean urlDecodeRequired, String path) { String thePath = decode(path.substring(canonicalPathStart), urlDecodeRequired, state, allowEncodedSlash, false); exchange.setRequestPath(thePath); exchange.setRelativePath(thePath); exchange.setRequestURI(path, true); }
private void beginPathParameters(ParseState state, HttpServerExchange exchange, StringBuilder stringBuilder, int parseState, int canonicalPathStart, boolean urlDecodeRequired) { final String path = stringBuilder.toString(); if(parseState == SECOND_SLASH) { exchange.setRequestPath("/"); exchange.setRelativePath("/"); exchange.setRequestURI(path); } else if (parseState < HOST_DONE) { String decodedPath = decode(path, urlDecodeRequired, state, allowEncodedSlash, false); exchange.setRequestPath(decodedPath); exchange.setRelativePath(decodedPath); exchange.setRequestURI(path); } else { String thePath = path.substring(canonicalPathStart); exchange.setRequestPath(thePath); exchange.setRelativePath(thePath); exchange.setRequestURI(path, true); } state.state = ParseState.PATH_PARAMETERS; state.stringBuilder.setLength(0); state.parseState = 0; state.pos = 0; state.urlDecodeRequired = false; }
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { exchange.setRelativePath(CanonicalPathUtils.canonicalize(exchange.getRelativePath())); next.handleRequest(exchange); }
@Override public void writeAttribute(final HttpServerExchange exchange, final String newValue) throws ReadOnlyAttributeException { int pos = newValue.indexOf('?'); exchange.setResolvedPath(""); if (pos == -1) { exchange.setRelativePath(newValue); exchange.setRequestURI(newValue); exchange.setRequestPath(newValue); } else { final String path = newValue.substring(0, pos); exchange.setRequestPath(path); exchange.setRelativePath(path); exchange.setRequestURI(newValue); final String newQueryString = newValue.substring(pos); exchange.setQueryString(newQueryString); exchange.getQueryParameters().putAll(QueryParameterUtils.parseQueryString(newQueryString.substring(1), QueryParameterUtils.getQueryParamEncoding(exchange))); } }
@Override public void writeAttribute(final HttpServerExchange exchange, final String newValue) throws ReadOnlyAttributeException { int pos = newValue.indexOf('?'); if (pos == -1) { exchange.setRelativePath(newValue); exchange.setRequestURI(newValue); exchange.setRequestPath(newValue); exchange.setResolvedPath(""); } else { final String path = newValue.substring(0, pos); exchange.setRelativePath(path); exchange.setRequestURI(path); exchange.setRequestPath(path); exchange.setResolvedPath(""); final String newQueryString = newValue.substring(pos); exchange.setQueryString(newQueryString); exchange.getQueryParameters().putAll(QueryParameterUtils.parseQueryString(newQueryString.substring(1), QueryParameterUtils.getQueryParamEncoding(exchange))); } }
private void beginQueryParameters(ByteBuffer buffer, ParseState state, HttpServerExchange exchange, StringBuilder stringBuilder, int parseState, int canonicalPathStart, boolean urlDecodeRequired) throws BadRequestException { final String path = stringBuilder.toString(); if (parseState == SECOND_SLASH) { exchange.setRequestPath("/"); exchange.setRelativePath("/"); exchange.setRequestURI(path); } else if (parseState < HOST_DONE) { String decodedPath = decode(path, urlDecodeRequired, state, allowEncodedSlash, false); exchange.setRequestPath(decodedPath); exchange.setRelativePath(decodedPath); exchange.setRequestURI(path, false); } else { handleFullUrl(state, exchange, canonicalPathStart, urlDecodeRequired, path); } state.state = ParseState.QUERY_PARAMETERS; state.stringBuilder.setLength(0); state.parseState = 0; state.pos = 0; state.urlDecodeRequired = false; handleQueryParameters(buffer, state, exchange); }
int pos = newValue.indexOf('?'); if (pos == -1) { exchange.setRelativePath(newValue); String requestURI = exchange.getResolvedPath() + newValue; if(requestURI.contains("%")) { } else { final String path = newValue.substring(0, pos); exchange.setRelativePath(path); String requestURI = exchange.getResolvedPath() + path; if(requestURI.contains("%")) {
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { boolean handlingRequired = File.separatorChar != '/'; if (handlingRequired) { exchange.setRequestPath(canonicalize(exchange.getRequestPath().replace(File.separatorChar, '/'))); exchange.setRelativePath(canonicalize(exchange.getRelativePath().replace(File.separatorChar, '/'))); exchange.setResolvedPath(canonicalize(exchange.getResolvedPath().replace(File.separatorChar, '/'))); } next.handleRequest(exchange); }
exchange.setRelativePath(part); exchange.setRequestURI(encodedPart); final String qs = encodedPath.substring(i + 1); exchange.setRelativePath(part); for(int j = i; j < encodedPath.length(); ++j) { if (encodedPath.charAt(j) == '?') { exchange.setRelativePath(part); exchange.setRequestURI(encodedPath);
final boolean decodeSlash = exchange.getConnection().getUndertowOptions().get(UndertowOptions.ALLOW_ENCODED_SLASH, false); exchange.setRequestPath(URLUtils.decode(exchange.getRequestPath(), charset, decodeSlash, false, sb)); exchange.setRelativePath(URLUtils.decode(exchange.getRelativePath(), charset, decodeSlash, false, sb)); exchange.setResolvedPath(URLUtils.decode(exchange.getResolvedPath(), charset, decodeSlash, false, sb)); if (!exchange.getQueryString().isEmpty()) {
if(parseState == SECOND_SLASH) { exchange.setRequestPath("/"); exchange.setRelativePath("/"); exchange.setRequestURI(path); } else if (parseState < HOST_DONE) { String decodedPath = decode(path, urlDecodeRequired, state, allowEncodedSlash, false); exchange.setRequestPath(decodedPath); exchange.setRelativePath(decodedPath); exchange.setRequestURI(path); } else {
exchange.setRelativePath(res); } else { final String url = result.value.substring(0, colon); exchange.setRelativePath(res); try { URLUtils.parsePathParams(result.value.substring(colon + 1), exchange, encoding, doDecode && result.containsUrlCharacters, maxParameters);
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { PathMatcher.PathMatch<HttpHandler> match = null; boolean hit = false; if(cache != null) { match = cache.get(exchange.getRelativePath()); hit = true; } if(match == null) { match = pathMatcher.match(exchange.getRelativePath()); } if (match.getValue() == null) { ResponseCodeHandler.HANDLE_404.handleRequest(exchange); return; } if(hit) { cache.add(exchange.getRelativePath(), match); } exchange.setRelativePath(match.getRemaining()); if(exchange.getResolvedPath().isEmpty()) { //first path handler, we can just use the matched part exchange.setResolvedPath(match.getMatched()); } else { //already something in the resolved path exchange.setResolvedPath(exchange.getResolvedPath() + match.getMatched()); } match.getValue().handleRequest(exchange); }
exchange.setRequestURI(exchange.getRequestURI(), exchange.isHostIncludedInRequestURI()); exchange.setRequestPath(exchange.getRequestPath()); exchange.setRelativePath(exchange.getRelativePath()); newExchange.setPersistent(true);
exchange.setRequestURI(exchange.getRequestURI(), exchange.isHostIncludedInRequestURI()); exchange.setRequestPath(exchange.getRequestPath()); exchange.setRelativePath(exchange.getRelativePath()); newExchange.getRequestHeaders().put(Headers.CONNECTION, Headers.KEEP_ALIVE.toString()); newExchange.getRequestHeaders().put(Headers.CONTENT_LENGTH, 0);
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { final String relativePath = exchange.getAttachment(RELATIVE_PATH); exchange.setRelativePath( relativePath ); next.handleRequest( exchange ); } }
private void handleFullUrl(ParseState state, HttpServerExchange exchange, int canonicalPathStart, boolean urlDecodeRequired, String path) { String thePath = decode(path.substring(canonicalPathStart), urlDecodeRequired, state, allowEncodedSlash, false); exchange.setRequestPath(thePath); exchange.setRelativePath(thePath); exchange.setRequestURI(path, true); }
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { exchange.setRelativePath(CanonicalPathUtils.canonicalize(exchange.getRelativePath())); next.handleRequest(exchange); }
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { exchange.setRelativePath(CanonicalPathUtils.canonicalize(exchange.getRelativePath())); next.handleRequest(exchange); }
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { boolean handlingRequired = File.separatorChar != '/'; if (handlingRequired) { exchange.setRequestPath(canonicalize(exchange.getRequestPath().replace(File.separatorChar, '/'))); exchange.setRelativePath(canonicalize(exchange.getRelativePath().replace(File.separatorChar, '/'))); exchange.setResolvedPath(canonicalize(exchange.getResolvedPath().replace(File.separatorChar, '/'))); } next.handleRequest(exchange); }