use of com.hotels.styx.api.Url in project styx by ExpediaGroup.
the class UrlDecoderTest method decodesOriginForm.
@Test
public void decodesOriginForm() {
DefaultFullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, "/foo");
request.headers().add(HOST, "example.com");
Url url = UrlDecoder.decodeUrl(x -> x, request);
assertThat(url.authority(), is(Optional.empty()));
assertThat(url.path(), is("/foo"));
assertThat(url.encodedUrl(), is("/foo"));
assertThat(url.isAbsolute(), is(false));
assertThat(url.isRelative(), is(true));
assertThat(url.host(), is(Optional.empty()));
assertThat(url.queryParams(), is(emptyMap()));
assertThat(url.scheme(), is(""));
}
use of com.hotels.styx.api.Url in project styx by ExpediaGroup.
the class UrlDecoderTest method decodesAbsoluteForm.
@Test
public void decodesAbsoluteForm() {
DefaultFullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, "http://example.com/foo");
Url url = UrlDecoder.decodeUrl(x -> x, request);
assertThat(url.authority().isPresent(), is(true));
assertThat(url.path(), is("/foo"));
assertThat(url.encodedUrl(), is("http://example.com/foo"));
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"));
}
use of com.hotels.styx.api.Url in project styx by ExpediaGroup.
the class NettyToStyxRequestDecoder method makeAStyxRequestFrom.
@VisibleForTesting
LiveHttpRequest.Builder makeAStyxRequestFrom(HttpRequest request, Observable<ByteBuf> content) {
Url url = UrlDecoder.decodeUrl(unwiseCharEncoder, request);
LiveHttpRequest.Builder requestBuilder = new LiveHttpRequest.Builder().method(toStyxMethod(request.method())).url(url).version(toStyxVersion(request.protocolVersion())).id(uniqueIdSupplier.get()).body(new ByteStream(toPublisher(content.map(Buffers::fromByteBuf))));
stream(request.headers().spliterator(), false).forEach(entry -> requestBuilder.addHeader(entry.getKey(), entry.getValue()));
return requestBuilder;
}
Aggregations