Java Code Examples for io.undertow.server.HttpServerExchange#getRequestURL()
The following examples show how to use
io.undertow.server.HttpServerExchange#getRequestURL() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LearningPushHandler.java From quarkus-http with Apache License 2.0 | 6 votes |
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { String fullPath; String requestPath; if(exchange.getQueryString().isEmpty()) { fullPath = exchange.getRequestURL(); requestPath = exchange.getRequestPath(); } else{ fullPath = exchange.getRequestURL() + "?" + exchange.getQueryString(); requestPath = exchange.getRequestPath() + "?" + exchange.getQueryString(); } doPush(exchange, fullPath); String referrer = exchange.getRequestHeader(HttpHeaderNames.REFERER); if (referrer != null) { String accept = exchange.getRequestHeader(HttpHeaderNames.ACCEPT); if (accept == null || !accept.contains("text/html")) { //if accept contains text/html it generally means the user has clicked //a link to move to a new page, and is not a resource load for the current page //we only care about resources for the current page exchange.addExchangeCompleteListener(new PushCompletionListener(fullPath, requestPath, referrer)); } } next.handleRequest(exchange); }
Example 2
Source File: LearningPushHandler.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { String fullPath; String requestPath; if(exchange.getQueryString().isEmpty()) { fullPath = exchange.getRequestURL(); requestPath = exchange.getRequestPath(); } else{ fullPath = exchange.getRequestURL() + "?" + exchange.getQueryString(); requestPath = exchange.getRequestPath() + "?" + exchange.getQueryString(); } doPush(exchange, fullPath); String referrer = exchange.getRequestHeaders().getFirst(Headers.REFERER); if (referrer != null) { String accept = exchange.getRequestHeaders().getFirst(Headers.ACCEPT); if (accept == null || !accept.contains("text/html")) { //if accept contains text/html it generally means the user has clicked //a link to move to a new page, and is not a resource load for the current page //we only care about resources for the current page exchange.addExchangeCompleteListener(new PushCompletionListener(fullPath, requestPath, referrer)); } } next.handleRequest(exchange); }
Example 3
Source File: UndertowServerHttpRequest.java From spring-analysis-note with MIT License | 5 votes |
private static URI initUri(HttpServerExchange exchange) throws URISyntaxException { Assert.notNull(exchange, "HttpServerExchange is required"); String requestURL = exchange.getRequestURL(); String query = exchange.getQueryString(); String requestUriAndQuery = (StringUtils.hasLength(query) ? requestURL + "?" + query : requestURL); return new URI(requestUriAndQuery); }
Example 4
Source File: UndertowServerHttpRequest.java From java-technology-stack with MIT License | 5 votes |
private static URI initUri(HttpServerExchange exchange) throws URISyntaxException { Assert.notNull(exchange, "HttpServerExchange is required."); String requestURL = exchange.getRequestURL(); String query = exchange.getQueryString(); String requestUriAndQuery = StringUtils.isEmpty(query) ? requestURL : requestURL + "?" + query; return new URI(requestUriAndQuery); }
Example 5
Source File: HttpsRedirect.java From PYX-Reloaded with Apache License 2.0 | 5 votes |
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { URIBuilder builder = new URIBuilder(exchange.getRequestURL()); builder.setScheme("https"); exchange.setStatusCode(StatusCodes.MOVED_PERMANENTLY); exchange.getResponseHeaders().add(Headers.LOCATION, builder.toString()); exchange.endExchange(); }
Example 6
Source File: LimitHandler.java From mangooio with Apache License 2.0 | 5 votes |
/** * Creates a key for used for limit an request containing the * requested url and the source host * * @param exchange The HttpServerExchange * @return The key url + host */ private String getCacheKey(HttpServerExchange exchange) { String host = ""; HeaderMap headerMap = exchange.getRequestHeaders(); if (headerMap != null) { HeaderValues headerValues = headerMap.get(Header.X_FORWARDED_FOR.toHttpString()); if (headerValues != null) { host = headerValues.element(); } } if (StringUtils.isBlank(host)) { InetSocketAddress inetSocketAddress = exchange.getSourceAddress(); if (inetSocketAddress != null) { host = inetSocketAddress.getHostString(); } } if (StringUtils.isNotBlank(host)) { host = host.toLowerCase(Locale.ENGLISH); } String url = exchange.getRequestURL(); if (StringUtils.isNotBlank(url)) { url = url.toLowerCase(Locale.ENGLISH); } return url + host; }
Example 7
Source File: ClientSideCookieEventHandler.java From divolte-collector with Apache License 2.0 | 5 votes |
private static String getFullUrl(final HttpServerExchange exchange) { final String queryString = exchange.getQueryString(); final String requestUrl = exchange.getRequestURL(); return Strings.isNullOrEmpty(queryString) ? requestUrl : requestUrl + '?' + queryString; }
Example 8
Source File: TracingHttpHandlerConfiguration.java From pivotal-bank-demo with Apache License 2.0 | 4 votes |
@Override public String url(HttpServerExchange request) { return request.getRequestURL(); }