@Override public Address getInboundAddress() { if (this.address == null) { String requestURI = getRequest().getRequestURI(); Matcher sessionIdMatcher = JSESSIONID_PATTERN.matcher(requestURI); if (sessionIdMatcher.matches()) { requestURI = sessionIdMatcher.replaceFirst(JSESSIONID_REPLACEMENT); } // for forwards the requestURI isn't URL encoded as we expect it // see: https://github.com/ocpsoft/rewrite/issues/165 if (getRequest().getAttribute("javax.servlet.forward.request_uri") != null) { requestURI = Encoder.path(requestURI); } this.address = AddressBuilder.begin() .scheme(getRequest().getScheme()) .domain(getRequest().getServerName()) .port(getRequest().getServerPort()) .path(requestURI) .queryLiteral(getRequest().getQueryString()).buildLiteral(); } return this.address; }
/** * Create a new {@link Address} from the given URL. Improperly formatted or encoded URLs are not parse-able and will * result in an exception. No builder parameterization is possible using this method. * * @see http://en.wikipedia.org/wiki/URI_scheme * @throws IllegalArgumentException when the input URL or URL fragment is not valid. */ public static Address create(String url) throws IllegalArgumentException { try { URI u = new URI(url); String scheme = u.getScheme(); String host = u.getHost(); if (scheme != null && host == null) return AddressBuilder.begin().scheme(u.getScheme()).schemeSpecificPart(u.getRawSchemeSpecificPart()) .buildLiteral(); else return AddressBuilder.begin().scheme(scheme).domain(host).port(u.getPort()) .path(u.getRawPath()).queryLiteral(u.getRawQuery()).anchor(u.getRawFragment()).buildLiteral(); } catch (URISyntaxException e) { throw new IllegalArgumentException( "[" + url + "] is not a valid URL fragment. Consider encoding relevant portions of the URL with [" + Encoder.class + "], or use the provided builder pattern via this class to specify part encoding.", e); } }
@Override public Address getInboundAddress() { if (this.address == null) { String requestURI = getRequest().getRequestURI(); Matcher sessionIdMatcher = JSESSIONID_PATTERN.matcher(requestURI); if (sessionIdMatcher.matches()) { requestURI = sessionIdMatcher.replaceFirst(JSESSIONID_REPLACEMENT); } // for forwards the requestURI isn't URL encoded as we expect it // see: https://github.com/ocpsoft/rewrite/issues/165 if (getRequest().getAttribute("javax.servlet.forward.request_uri") != null) { requestURI = Encoder.path(requestURI); } this.address = AddressBuilder.begin() .scheme(getRequest().getScheme()) .domain(getRequest().getServerName()) .port(getRequest().getServerPort()) .path(requestURI) .queryLiteral(getRequest().getQueryString()).buildLiteral(); } return this.address; }
/** * Create a new {@link Address} from the given URL. Improperly formatted or encoded URLs are not parse-able and will * result in an exception. No builder parameterization is possible using this method. * * @see http://en.wikipedia.org/wiki/URI_scheme * @throws IllegalArgumentException when the input URL or URL fragment is not valid. */ public static Address create(String url) throws IllegalArgumentException { try { URI u = new URI(url); String scheme = u.getScheme(); String host = u.getHost(); if (scheme != null && host == null) return AddressBuilder.begin().scheme(u.getScheme()).schemeSpecificPart(u.getRawSchemeSpecificPart()) .buildLiteral(); else return AddressBuilder.begin().scheme(scheme).domain(host).port(u.getPort()) .path(u.getRawPath()).queryLiteral(u.getRawQuery()).anchor(u.getRawFragment()).buildLiteral(); } catch (URISyntaxException e) { throw new IllegalArgumentException( "[" + url + "] is not a valid URL fragment. Consider encoding relevant portions of the URL with [" + Encoder.class + "], or use the provided builder pattern via this class to specify part encoding.", e); } }
@Override public Address getInboundAddress() { if (this.address == null) { String requestURI = getRequest().getRequestURI(); Matcher sessionIdMatcher = JSESSIONID_PATTERN.matcher(requestURI); if (sessionIdMatcher.matches()) { requestURI = sessionIdMatcher.replaceFirst(JSESSIONID_REPLACEMENT); } // for forwards the requestURI isn't URL encoded as we expect it // see: https://github.com/ocpsoft/rewrite/issues/165 if (getRequest().getAttribute("javax.servlet.forward.request_uri") != null) { requestURI = Encoder.path(requestURI); } this.address = AddressBuilder.begin() .scheme(getRequest().getScheme()) .domain(getRequest().getServerName()) .port(getRequest().getServerPort()) .path(requestURI) .queryLiteral(getRequest().getQueryString()).buildLiteral(); } return this.address; }