@Test public void decodesAbsoluteForm() { DefaultFullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, "http: Url url = UrlDecoder.decodeUrl(x -> x, request); assertThat(url.authority().isPresent(), is(true)); assertThat(url.path(), is("/foo")); assertThat(url.encodedUri(), is("http: assertThat(url.isAbsolute(), is(true)); assertThat(url.isRelative(), is(false)); assertThat(url.host(), is(Optional.of("example.com"))); assertThat(url.queryParams(), is(emptyMap())); assertThat(url.scheme(), is("http")); }
static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragment()) .build(); } else { return url(unwiseCharEncoder.encode(request.uri())).build(); } }
UrlDecoder { static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragment()) .build(); } else { return url(unwiseCharEncoder.encode(request.uri())).build(); } } }
UrlDecoder { static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragment()) .build(); } else { return url(unwiseCharEncoder.encode(request.uri())).build(); } } private  UrlDecoder(); }
UrlDecoder { static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragment()) .build(); } else { return url(unwiseCharEncoder.encode(request.uri())).build(); } } private  UrlDecoder();  }
UrlDecoder { static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragment()) .build(); } else { return url(unwiseCharEncoder.encode(request.uri())).build(); } } private  UrlDecoder();   }