@Test public void canHandleNettyCookies() { HttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, "http: request.headers().set(HOST, "http: request.headers().set("Cookie", "ABC01=\"1\"; ABC02=1; guid=xxxxx-xxx-xxx-xxx-xxxxxxx"); NettyToStyxRequestDecoder decoder = new NettyToStyxRequestDecoder.Builder() .uniqueIdSupplier(uniqueIdSupplier) .build(); LiveHttpRequest styxRequest = decoder.makeAStyxRequestFrom(request, Flux.empty()) .build(); LiveHttpRequest expected = new LiveHttpRequest.Builder( HttpMethod.GET, "http: .cookies( requestCookie("ABC01", "\"1\""), requestCookie("ABC02", "1"), requestCookie("guid", "xxxxx-xxx-xxx-xxx-xxxxxxx") ) .build(); assertThat(newHashSet(styxRequest.cookies()), is(newHashSet(expected.cookies()))); }
@VisibleForTesting LiveHttpRequest.Builder makeAStyxRequestFrom(HttpRequest request, Publisher<Buffer> 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(content)); stream(request.headers().spliterator(), false) .forEach(entry -> requestBuilder.addHeader(entry.getKey(), entry.getValue())); return requestBuilder; }
NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @VisibleForTesting LiveHttpRequest.Builder makeAStyxRequestFrom(HttpRequest request, Publisher<Buffer> 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(content)); stream(request.headers().spliterator(), false) .forEach(entry -> requestBuilder.addHeader(entry.getKey(), entry.getValue())); return requestBuilder; } }
NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @VisibleForTesting LiveHttpRequest.Builder makeAStyxRequestFrom(HttpRequest request, Publisher<Buffer> 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(content)); stream(request.headers().spliterator(), false) .forEach(entry -> requestBuilder.addHeader(entry.getKey(), entry.getValue())); return requestBuilder; } private  NettyToStyxRequestDecoder(Builder builder); }
NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @VisibleForTesting LiveHttpRequest.Builder makeAStyxRequestFrom(HttpRequest request, Publisher<Buffer> 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(content)); stream(request.headers().spliterator(), false) .forEach(entry -> requestBuilder.addHeader(entry.getKey(), entry.getValue())); return requestBuilder; } private  NettyToStyxRequestDecoder(Builder builder); @Override void channelInactive(ChannelHandlerContext ctx); @Override void exceptionCaught(ChannelHandlerContext ctx, Throwable cause); }
NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @VisibleForTesting LiveHttpRequest.Builder makeAStyxRequestFrom(HttpRequest request, Publisher<Buffer> 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(content)); stream(request.headers().spliterator(), false) .forEach(entry -> requestBuilder.addHeader(entry.getKey(), entry.getValue())); return requestBuilder; } private  NettyToStyxRequestDecoder(Builder builder); @Override void channelInactive(ChannelHandlerContext ctx); @Override void exceptionCaught(ChannelHandlerContext ctx, Throwable cause);  }