@Override public String readAttribute(final HttpServerExchange exchange) { return exchange.getHostAndPort(); }
static void sendRedirect(final HttpServerExchange exchange, final String location) { // TODO - String concatenation to construct URLS is extremely error prone - switch to a URI which will better handle this. String loc = exchange.getRequestScheme() + "://" + exchange.getHostAndPort() + location; exchange.getResponseHeaders().put(Headers.LOCATION, loc); } }
private void sendTo(HttpServerExchange serverExchange, Response response) throws Exception { String responseStr = createMessageStr(response); logger.log(Level.INFO, "Sending message to " + serverExchange.getHostAndPort() + ": " + responseStr); serverExchange.getResponseSender().send(responseStr); serverExchange.endExchange(); }
StringBuilder uri = new StringBuilder(exchange.getRequestScheme()); uri.append("://"); uri.append(exchange.getHostAndPort()); uri.append(encodeUrlPart(exchange.getResolvedPath())); if (exchange.getResolvedPath().endsWith("/")) {
/** * Reconstructs the complete URL as seen by the user. This includes scheme, host name etc, * but does not include query string. * <p> * This is not decoded. */ public String getRequestURL() { if (isHostIncludedInRequestURI()) { return getRequestURI(); } else { return getRequestScheme() + "://" + getHostAndPort() + getRequestURI(); } }
requestHeaders.put(Http2ReceiveListener.METHOD, method.toString()); requestHeaders.put(Http2ReceiveListener.PATH, path.toString()); requestHeaders.put(Http2ReceiveListener.AUTHORITY, exchange.getHostAndPort()); requestHeaders.put(Http2ReceiveListener.SCHEME, exchange.getRequestScheme());
@Override public String readAttribute(final HttpServerExchange exchange) { return exchange.getHostAndPort(); }
@Override public String readAttribute(final HttpServerExchange exchange) { return exchange.getHostAndPort(); }
public String getHostAndPort() { return this.exchange.getHostAndPort(); }
private String createNewLocation(final HttpServerExchange exchange) { return new StringBuilder() .append("https://") .append(exchange.getHostAndPort()) .append(exchange.getRelativePath()) .toString(); } }
static void sendRedirect(final HttpServerExchange exchange, final String location) { // TODO - String concatenation to construct URLS is extremely error prone - switch to a URI which will better handle this. String loc = exchange.getRequestScheme() + "://" + exchange.getHostAndPort() + location; exchange.getResponseHeaders().put(Headers.LOCATION, loc); } }
static void sendRedirect(final HttpServerExchange exchange, final String location) { // TODO - String concatenation to construct URLS is extremely error prone - switch to a URI which will better handle this. String loc = exchange.getRequestScheme() + "://" + exchange.getHostAndPort() + location; exchange.getResponseHeaders().put(Headers.LOCATION, loc); }
static void sendRedirect(final HttpServerExchange exchange, final String location) { // TODO - String concatenation to construct URLS is extremely error prone - switch to a URI which will better handle this. String loc = exchange.getRequestScheme() + "://" + exchange.getHostAndPort() + location; exchange.getResponseHeaders().put(Headers.LOCATION, loc); } }
static void sendRedirect(final HttpServerExchange exchange, final String location) { // TODO - String concatenation to construct URLS is extremely error prone - switch to a URI which will better handle this. String loc = exchange.getRequestScheme() + "://" + exchange.getHostAndPort() + location; exchange.getResponseHeaders().put(Headers.LOCATION, loc); }
/** * Reconstructs the complete URL as seen by the user. This includes scheme, host name etc, * but does not include query string. * <p> * This is not decoded. */ public String getRequestURL() { if (isHostIncludedInRequestURI()) { return getRequestURI(); } else { return getRequestScheme() + "://" + getHostAndPort() + getRequestURI(); } }
/** * Reconstructs the complete URL as seen by the user. This includes scheme, host name etc, * but does not include query string. * <p> * This is not decoded. */ public String getRequestURL() { if (isHostIncludedInRequestURI()) { return getRequestURI(); } else { return getRequestScheme() + "://" + getHostAndPort() + getRequestURI(); } }
@Override public String getURI() { KeycloakUriBuilder uriBuilder = KeycloakUriBuilder.fromUri(exchange.getRequestURI()) .replaceQuery(exchange.getQueryString()); if (!exchange.isHostIncludedInRequestURI()) uriBuilder.scheme(exchange.getRequestScheme()).host(exchange.getHostAndPort()); return uriBuilder.build().toString(); }
@Override public String getURI() { KeycloakUriBuilder uriBuilder = KeycloakUriBuilder.fromUri(exchange.getRequestURI()) .replaceQuery(exchange.getQueryString()); if (!exchange.isHostIncludedInRequestURI()) uriBuilder.scheme(exchange.getRequestScheme()).host(exchange.getHostAndPort()); return uriBuilder.build().toString(); }
@Override public void sendRedirect(final String location) throws IOException { if (responseStarted()) { throw UndertowServletMessages.MESSAGES.responseAlreadyCommited(); } resetBuffer(); setStatus(StatusCodes.FOUND); String realPath; if (isAbsoluteUrl(location)) {//absolute url exchange.getResponseHeaders().put(Headers.LOCATION, location); } else { if (location.startsWith("/")) { realPath = location; } else { String current = exchange.getRelativePath(); int lastSlash = current.lastIndexOf("/"); if (lastSlash != -1) { current = current.substring(0, lastSlash + 1); } realPath = CanonicalPathUtils.canonicalize(servletContext.getContextPath() + current + location); } String loc = exchange.getRequestScheme() + "://" + exchange.getHostAndPort() + realPath; exchange.getResponseHeaders().put(Headers.LOCATION, loc); } responseDone(); }
requestHeaders.put(Http2ReceiveListener.METHOD, method.toString()); requestHeaders.put(Http2ReceiveListener.PATH, path.toString()); requestHeaders.put(Http2ReceiveListener.AUTHORITY, exchange.getHostAndPort()); requestHeaders.put(Http2ReceiveListener.SCHEME, exchange.getRequestScheme());