io.netty.handler.codec.http.cookie.ClientCookieDecoder Java Examples
The following examples show how to use
io.netty.handler.codec.http.cookie.ClientCookieDecoder.
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: NettyConnector.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Override public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception { FullHttpResponse response = (FullHttpResponse) msg; if (httpRequiresSessionId && !active) { final List<String> setCookieHeaderValues = response.headers().getAll(HttpHeaderNames.SET_COOKIE); for (String setCookieHeaderValue : setCookieHeaderValues) { final Cookie cookie = ClientCookieDecoder.LAX.decode(setCookieHeaderValue); if ("JSESSIONID".equals(cookie.name())) { this.cookie = setCookieHeaderValue; break; } } active = true; handShakeFuture.run(); } waitingGet = false; ctx.fireChannelRead(response.content()); }
Example #2
Source File: HttpClientOperationsTest.java From reactor-netty with Apache License 2.0 | 6 votes |
@Test public void addNamedEncoderReplaysLastHttp() { ByteBuf buf = Unpooled.copiedBuffer("{\"foo\":1}", CharsetUtil.UTF_8); EmbeddedChannel channel = new EmbeddedChannel(); new HttpClientOperations(() -> channel, ConnectionObserver.emptyListener(), ClientCookieEncoder.STRICT, ClientCookieDecoder.STRICT) .addHandler("json", new JsonObjectDecoder()); channel.writeInbound(new DefaultLastHttpContent(buf)); MatcherAssert.assertThat(channel.pipeline().names().iterator().next(), is("json$extractor")); Object content = channel.readInbound(); MatcherAssert.assertThat(content, instanceOf(ByteBuf.class)); ((ByteBuf) content).release(); content = channel.readInbound(); MatcherAssert.assertThat(content, instanceOf(LastHttpContent.class)); ((LastHttpContent) content).release(); MatcherAssert.assertThat(channel.readInbound(), nullValue()); }
Example #3
Source File: HttpClientOperationsTest.java From reactor-netty with Apache License 2.0 | 6 votes |
@Test public void addEncoderReplaysLastHttp() { ByteBuf buf = Unpooled.copiedBuffer("{\"foo\":1}", CharsetUtil.UTF_8); EmbeddedChannel channel = new EmbeddedChannel(); new HttpClientOperations(() -> channel, ConnectionObserver.emptyListener(), ClientCookieEncoder.STRICT, ClientCookieDecoder.STRICT) .addHandler(new JsonObjectDecoder()); channel.writeInbound(new DefaultLastHttpContent(buf)); MatcherAssert.assertThat(channel.pipeline().names().iterator().next(), is("JsonObjectDecoder$extractor")); Object content = channel.readInbound(); MatcherAssert.assertThat(content, instanceOf(ByteBuf.class)); ((ByteBuf) content).release(); content = channel.readInbound(); MatcherAssert.assertThat(content, instanceOf(LastHttpContent.class)); ((LastHttpContent) content).release(); MatcherAssert.assertThat(channel.readInbound(), nullValue()); }
Example #4
Source File: HttpClientOperationsTest.java From reactor-netty with Apache License 2.0 | 6 votes |
@Test public void addNamedDecoderReplaysLastHttp() { ByteBuf buf = Unpooled.copiedBuffer("{\"foo\":1}", CharsetUtil.UTF_8); EmbeddedChannel channel = new EmbeddedChannel(); new HttpClientOperations(() -> channel, ConnectionObserver.emptyListener(), ClientCookieEncoder.STRICT, ClientCookieDecoder.STRICT) .addHandler("json", new JsonObjectDecoder()); channel.writeInbound(new DefaultLastHttpContent(buf)); MatcherAssert.assertThat(channel.pipeline().names().iterator().next(), is("json$extractor")); Object content = channel.readInbound(); MatcherAssert.assertThat(content, instanceOf(ByteBuf.class)); ((ByteBuf) content).release(); content = channel.readInbound(); MatcherAssert.assertThat(content, instanceOf(LastHttpContent.class)); ((LastHttpContent) content).release(); MatcherAssert.assertThat(channel.readInbound(), nullValue()); }
Example #5
Source File: HttpClientOperationsTest.java From reactor-netty with Apache License 2.0 | 6 votes |
@Test public void addDecoderReplaysLastHttp() { ByteBuf buf = Unpooled.copiedBuffer("{\"foo\":1}", CharsetUtil.UTF_8); EmbeddedChannel channel = new EmbeddedChannel(); new HttpClientOperations(() -> channel, ConnectionObserver.emptyListener(), ClientCookieEncoder.STRICT, ClientCookieDecoder.STRICT) .addHandler(new JsonObjectDecoder()); channel.writeInbound(new DefaultLastHttpContent(buf)); MatcherAssert.assertThat(channel.pipeline().names().iterator().next(), is("JsonObjectDecoder$extractor")); Object content = channel.readInbound(); MatcherAssert.assertThat(content, instanceOf(ByteBuf.class)); ((ByteBuf) content).release(); content = channel.readInbound(); MatcherAssert.assertThat(content, instanceOf(LastHttpContent.class)); ((LastHttpContent) content).release(); MatcherAssert.assertThat(channel.readInbound(), nullValue()); }
Example #6
Source File: HttpClientConfig.java From reactor-netty with Apache License 2.0 | 5 votes |
HttpClientConfig(ConnectionProvider connectionProvider, Map<ChannelOption<?>, ?> options, Supplier<? extends SocketAddress> remoteAddress) { super(connectionProvider, options, remoteAddress); this.acceptGzip = false; this.cookieDecoder = ClientCookieDecoder.STRICT; this.cookieEncoder = ClientCookieEncoder.STRICT; this.decoder = new HttpResponseDecoderSpec(); this.headers = new DefaultHttpHeaders(); this.method = HttpMethod.GET; this.protocols = new HttpProtocol[]{HttpProtocol.HTTP11}; this._protocols = h11; this.retryDisabled = false; }
Example #7
Source File: SessionAwareInterceptor.java From vertx-web with Apache License 2.0 | 5 votes |
private void processRedirectResponse(HttpContext<?> context) { // Now the context contains the redirect request in clientRequest() and the original request in request() List<String> cookieHeaders = context.clientResponse().cookies(); if (cookieHeaders == null) { return; } WebClientSessionAware webclient = (WebClientSessionAware) ((HttpRequestImpl)context.request()).client; HttpRequestImpl<?> originalRequest = (HttpRequestImpl<?>) context.request(); CookieStore cookieStore = webclient.cookieStore(); String domain = URI.create(context.clientResponse().request().absoluteURI()).getHost(); if (domain.equals(originalRequest.host()) && originalRequest.virtualHost != null) { domain = originalRequest.virtualHost; } final String finalDomain = domain; cookieHeaders.forEach(header -> { Cookie cookie = ClientCookieDecoder.STRICT.decode(header); if (cookie != null) { if (cookie.domain() == null) { // Set the domain if missing, because we need to send cookies // only to the domains we received them from. cookie.setDomain(finalDomain); } cookieStore.put(cookie); } }); }
Example #8
Source File: ArmeriaClientHttpResponse.java From armeria with Apache License 2.0 | 5 votes |
private MultiValueMap<String, ResponseCookie> initCookies() { final MultiValueMap<String, ResponseCookie> cookies = new LinkedMultiValueMap<>(); headers.getAll(HttpHeaderNames.SET_COOKIE) .stream() .map(ClientCookieDecoder.LAX::decode) .forEach(c -> cookies.add(c.name(), ResponseCookie.from(c.name(), c.value()) .maxAge(c.maxAge()) .domain(c.domain()) .path(c.path()) .secure(c.isSecure()) .httpOnly(c.isHttpOnly()) .build())); return cookies; }
Example #9
Source File: HarCaptureFilter.java From AndroidHttpCapture with MIT License | 5 votes |
protected void captureResponseCookies(HttpResponse httpResponse) { List<String> setCookieHeaders = httpResponse.headers().getAll(HttpHeaders.Names.SET_COOKIE); if (setCookieHeaders == null) { return; } for (String setCookieHeader : setCookieHeaders) { Cookie cookie = ClientCookieDecoder.LAX.decode(setCookieHeader); if (cookie == null) { return; } HarCookie harCookie = new HarCookie(); harCookie.setName(cookie.name()); harCookie.setValue(cookie.value()); // comment is no longer supported in the netty ClientCookieDecoder harCookie.setDomain(cookie.domain()); harCookie.setHttpOnly(cookie.isHttpOnly()); harCookie.setPath(cookie.path()); harCookie.setSecure(cookie.isSecure()); if (cookie.maxAge() > 0) { // use a Calendar with the current timestamp + maxAge seconds. the locale of the calendar is irrelevant, // since we are dealing with timestamps. Calendar expires = Calendar.getInstance(); // zero out the milliseconds, since maxAge is in seconds expires.set(Calendar.MILLISECOND, 0); // we can't use Calendar.add, since that only takes ints. TimeUnit.convert handles second->millisecond // overflow reasonably well by returning the result as Long.MAX_VALUE. expires.setTimeInMillis(expires.getTimeInMillis() + TimeUnit.MILLISECONDS.convert(cookie.maxAge(), TimeUnit.SECONDS)); harCookie.setExpires(expires.getTime()); } harEntry.getResponse().getCookies().add(harCookie); } }
Example #10
Source File: HttpClientOperationsTest.java From reactor-netty with Apache License 2.0 | 5 votes |
private void doTestStatus(HttpResponseStatus status) { EmbeddedChannel channel = new EmbeddedChannel(); HttpClientOperations ops = new HttpClientOperations(() -> channel, ConnectionObserver.emptyListener(), ClientCookieEncoder.STRICT, ClientCookieDecoder.STRICT); ops.setNettyResponse(new DefaultFullHttpResponse(HTTP_1_1, status, Unpooled.EMPTY_BUFFER)); assertEquals(status.reasonPhrase(), ops.status().reasonPhrase()); }
Example #11
Source File: HttpClientOperationsTest.java From reactor-netty with Apache License 2.0 | 5 votes |
@Test public void testConstructorWithProvidedReplacement() { EmbeddedChannel channel = new EmbeddedChannel(); channel.pipeline().addFirst(NettyPipeline.SslHandler, new ChannelHandlerAdapter() { }); HttpClientOperations ops1 = new HttpClientOperations(() -> channel, ConnectionObserver.emptyListener(), ClientCookieEncoder.STRICT, ClientCookieDecoder.STRICT); ops1.followRedirectPredicate((req, res) -> true); ops1.started = true; ops1.retrying = true; ops1.redirecting = new RedirectClientException(new DefaultHttpHeaders().add(HttpHeaderNames.LOCATION, "/")); HttpClientOperations ops2 = new HttpClientOperations(ops1); assertSame(ops1.channel(), ops2.channel()); assertSame(ops1.started, ops2.started); assertSame(ops1.retrying, ops2.retrying); assertSame(ops1.redirecting, ops2.redirecting); assertSame(ops1.redirectedFrom, ops2.redirectedFrom); assertSame(ops1.isSecure, ops2.isSecure); assertSame(ops1.nettyRequest, ops2.nettyRequest); assertSame(ops1.responseState, ops2.responseState); assertSame(ops1.followRedirectPredicate, ops2.followRedirectPredicate); assertSame(ops1.requestHeaders, ops2.requestHeaders); }
Example #12
Source File: HttpClientOperations.java From reactor-netty with Apache License 2.0 | 5 votes |
HttpClientOperations(Connection c, ConnectionObserver listener, ClientCookieEncoder encoder, ClientCookieDecoder decoder) { super(c, listener); this.isSecure = c.channel() .pipeline() .get(NettyPipeline.SslHandler) != null; this.nettyRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/"); this.requestHeaders = nettyRequest.headers(); this.cookieDecoder = decoder; this.cookieEncoder = encoder; }
Example #13
Source File: QueryCatalog.java From schedge with MIT License | 5 votes |
private static Future<HttpContext> getContextAsync() { logger.debug("Getting CSRF token..."); Request request = new RequestBuilder().setUri(ROOT_URI).setMethod("GET").build(); return GetClient.getClient() .executeRequest(request) .toCompletableFuture() .handleAsync((resp, throwable) -> { if (resp == null) { logger.error(throwable.getMessage()); return null; } List<Cookie> cookies = resp.getHeaders() .getAll("Set-Cookie") .stream() .map(cookie -> ClientCookieDecoder.STRICT.decode(cookie)) .collect(Collectors.toList()); Cookie csrfCookie = cookies.stream() .filter(cookie -> cookie.name().equals("CSRFCookie")) .findAny() .orElse(null); if (csrfCookie == null) { logger.error("Couldn't find cookie with name=CSRFCookie"); return null; } logger.debug("Retrieved CSRF token `{}`", csrfCookie.value()); return new HttpContext(csrfCookie.value(), cookies); }); }
Example #14
Source File: HarCaptureFilter.java From Dream-Catcher with MIT License | 5 votes |
protected void captureResponseCookies(HttpResponse httpResponse) { Log.e("InnerHandle", "captureResponseCookies " + harEntry.getId()); List<String> setCookieHeaders = httpResponse.headers().getAll(HttpHeaders.Names.SET_COOKIE); if (setCookieHeaders == null) { return; } for (String setCookieHeader : setCookieHeaders) { Cookie cookie = ClientCookieDecoder.LAX.decode(setCookieHeader); if (cookie == null) { return; } HarCookie harCookie = new HarCookie(); harCookie.setName(cookie.name()); harCookie.setValue(cookie.value()); // comment is no longer supported in the netty ClientCookieDecoder harCookie.setDomain(cookie.domain()); harCookie.setHttpOnly(cookie.isHttpOnly()); harCookie.setPath(cookie.path()); harCookie.setSecure(cookie.isSecure()); if (cookie.maxAge() > 0) { // use a Calendar with the current timestamp + maxAge seconds. the locale of the calendar is irrelevant, // since we are dealing with timestamps. Calendar expires = Calendar.getInstance(); // zero out the milliseconds, since maxAge is in seconds expires.set(Calendar.MILLISECOND, 0); // we can't use Calendar.add, since that only takes ints. TimeUnit.convert handles second->millisecond // overflow reasonably well by returning the result as Long.MAX_VALUE. expires.setTimeInMillis(expires.getTimeInMillis() + TimeUnit.MILLISECONDS.convert(cookie.maxAge(), TimeUnit.SECONDS)); harCookie.setExpires(expires.getTime()); } harResponse.getResponse().getCookies().add(harCookie); harResponse.addHeader(harCookie.getName(), harCookie.getValue()); } }
Example #15
Source File: CookieUtils.java From vertx-vaadin with MIT License | 5 votes |
static Cookie fromVertxCookie(io.vertx.core.http.Cookie cookie) { io.netty.handler.codec.http.cookie.Cookie decoded = ClientCookieDecoder.STRICT.decode(cookie.encode()); Cookie out = new Cookie(decoded.name(), decoded.value()); Optional.ofNullable(decoded.domain()).ifPresent(out::setDomain); out.setPath(decoded.path()); out.setHttpOnly(decoded.isHttpOnly()); out.setSecure(decoded.isSecure()); if (decoded.maxAge() != Long.MIN_VALUE) { out.setMaxAge((int) decoded.maxAge()); } // TODO extract other values return out; }
Example #16
Source File: Context.java From schedge with MIT License | 5 votes |
public static Future<HttpContext> getContextAsync(Term term) { Request request = new RequestBuilder() .setUri(Uri.create(ROOT_URI + term.getId())) .setMethod("GET") .build(); return GetClient.getClient() .executeRequest(request) .toCompletableFuture() .handleAsync((resp, throwable) -> { if (resp == null) { return null; } List<Cookie> cookies = resp.getHeaders() .getAll("Set-Cookie") .stream() .map(cookie -> ClientCookieDecoder.STRICT.decode(cookie)) .collect(Collectors.toList()); Cookie csrfCookie = cookies.stream() .filter(cookie -> cookie.name().equals("CSRFCookie")) .findAny() .orElse(null); if (csrfCookie == null) { return null; } return new HttpContext(csrfCookie.value(), cookies); }); }
Example #17
Source File: HarCaptureFilter.java From browserup-proxy with Apache License 2.0 | 5 votes |
protected void captureResponseCookies(HttpResponse httpResponse) { List<String> setCookieHeaders = httpResponse.headers().getAll(HttpHeaderNames.SET_COOKIE); if (setCookieHeaders == null) { return; } for (String setCookieHeader : setCookieHeaders) { Cookie cookie = ClientCookieDecoder.LAX.decode(setCookieHeader); if (cookie == null) { return; } HarCookie harCookie = new HarCookie(); harCookie.setName(cookie.name()); harCookie.setValue(cookie.value()); // comment is no longer supported in the netty ClientCookieDecoder harCookie.setDomain(cookie.domain()); harCookie.setHttpOnly(cookie.isHttpOnly()); harCookie.setPath(cookie.path()); harCookie.setSecure(cookie.isSecure()); if (cookie.maxAge() > 0) { // use a Calendar with the current timestamp + maxAge seconds. the locale of the calendar is irrelevant, // since we are dealing with timestamps. Calendar expires = Calendar.getInstance(); // zero out the milliseconds, since maxAge is in seconds expires.set(Calendar.MILLISECOND, 0); // we can't use Calendar.add, since that only takes ints. TimeUnit.convert handles second->millisecond // overflow reasonably well by returning the result as Long.MAX_VALUE. expires.setTimeInMillis(expires.getTimeInMillis() + MILLISECONDS.convert(cookie.maxAge(), SECONDS)); harCookie.setExpires(expires.getTime()); } harEntry.getResponse().getCookies().add(harCookie); } }
Example #18
Source File: HarCaptureFilter.java From CapturePacket with MIT License | 5 votes |
protected void captureResponseCookies(HttpResponse httpResponse) { List<String> setCookieHeaders = httpResponse.headers().getAll(HttpHeaders.Names.SET_COOKIE); if (setCookieHeaders == null) { return; } for (String setCookieHeader : setCookieHeaders) { Cookie cookie = ClientCookieDecoder.LAX.decode(setCookieHeader); if (cookie == null) { return; } HarCookie harCookie = new HarCookie(); harCookie.setName(cookie.name()); harCookie.setValue(cookie.value()); // comment is no longer supported in the netty ClientCookieDecoder harCookie.setDomain(cookie.domain()); harCookie.setHttpOnly(cookie.isHttpOnly()); harCookie.setPath(cookie.path()); harCookie.setSecure(cookie.isSecure()); if (cookie.maxAge() > 0) { // use a Calendar with the current timestamp + maxAge seconds. the locale of the calendar is irrelevant, // since we are dealing with timestamps. Calendar expires = Calendar.getInstance(); // zero out the milliseconds, since maxAge is in seconds expires.set(Calendar.MILLISECOND, 0); // we can't use Calendar.add, since that only takes ints. TimeUnit.convert handles second->millisecond // overflow reasonably well by returning the result as Long.MAX_VALUE. expires.setTimeInMillis(expires.getTimeInMillis() + TimeUnit.MILLISECONDS.convert(cookie.maxAge(), TimeUnit.SECONDS)); harCookie.setExpires(expires.getTime()); } harEntry.getResponse().getCookies().add(harCookie); } }
Example #19
Source File: BasicAuthLoginRequestHandlerTest.java From timely with Apache License 2.0 | 5 votes |
@Test public void testBasicAuthentication() throws Exception { Configuration config = TestConfiguration.createMinimalConfigurationForTest(); // @formatter:off String form = "{\n" + " \"username\": \"test\",\n" + " \"password\": \"test1\"\n" + "}"; // @formatter:on DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/login"); request.content().writeBytes(form.getBytes()); TestHttpQueryDecoder decoder = new TestHttpQueryDecoder(config); decoder.decode(null, request, results); Assert.assertEquals(1, results.size()); Object result = results.iterator().next(); Assert.assertEquals(BasicAuthLoginRequest.class, result.getClass()); BasicAuthLoginRequestHandler handler = new BasicAuthLoginRequestHandler(config.getSecurity(), config.getHttp()); CaptureChannelHandlerContext ctx = new CaptureChannelHandlerContext(); handler.channelRead(ctx, result); Assert.assertNotNull(ctx.msg); Assert.assertTrue(ctx.msg instanceof DefaultFullHttpResponse); DefaultFullHttpResponse response = (DefaultFullHttpResponse) ctx.msg; Assert.assertEquals(HttpResponseStatus.OK, response.status()); Assert.assertTrue(response.headers().contains(HttpHeaderNames.CONTENT_TYPE)); Assert.assertEquals(Constants.JSON_TYPE, response.headers().get(HttpHeaderNames.CONTENT_TYPE)); Assert.assertTrue(response.headers().contains(HttpHeaderNames.SET_COOKIE)); Cookie c = ClientCookieDecoder.STRICT.decode(response.headers().get(HttpHeaderNames.SET_COOKIE)); Assert.assertEquals(TestConfiguration.TIMELY_HTTP_ADDRESS_DEFAULT, c.domain()); Assert.assertEquals(86400, c.maxAge()); Assert.assertTrue(c.isHttpOnly()); Assert.assertTrue(c.isSecure()); Assert.assertEquals(Constants.COOKIE_NAME, c.name()); UUID.fromString(c.value()); }
Example #20
Source File: CookieUtils.java From vertx-vaadin with MIT License | 5 votes |
static Cookie fromVertxCookie(io.vertx.ext.web.Cookie cookie) { io.netty.handler.codec.http.cookie.Cookie decoded = ClientCookieDecoder.STRICT.decode(cookie.encode()); Cookie out = new Cookie(decoded.name(), decoded.value()); Optional.ofNullable(decoded.domain()).ifPresent(out::setDomain); out.setPath(decoded.path()); out.setHttpOnly(decoded.isHttpOnly()); out.setSecure(decoded.isSecure()); if (decoded.maxAge() != Long.MIN_VALUE) { out.setMaxAge((int) decoded.maxAge()); } // TODO extract other values return out; }
Example #21
Source File: StyxToNettyResponseTranslatorTest.java From styx with Apache License 2.0 | 5 votes |
@Test public void shouldCreateNettyResponseWithCookieWithAttributes() { ResponseCookie cookie = responseCookie("cookie-test", "cookie-value") .domain("cookie-domain") .path("cookie-path") .maxAge(1234) .httpOnly(true) .secure(true) .build(); LiveHttpResponse styxResponse = new LiveHttpResponse.Builder(OK) .cookies(cookie) .build(); io.netty.handler.codec.http.HttpResponse nettyResponse = translator.toNettyResponse(styxResponse); String setCookie = nettyResponse.headers().get(SET_COOKIE); Cookie nettyCookie = ClientCookieDecoder.LAX.decode(setCookie); assertThat(nettyCookie.name(), is("cookie-test")); assertThat(nettyCookie.value(), is("cookie-value")); assertThat(nettyCookie.domain(), is("cookie-domain")); assertThat(nettyCookie.maxAge(), is(1234L)); assertThat(nettyCookie.isHttpOnly(), is(true)); assertThat(nettyCookie.isSecure(), is(true)); }
Example #22
Source File: BasicAuthLoginRequestHandlerTest.java From qonduit with Apache License 2.0 | 5 votes |
@Test public void testBasicAuthentication() throws Exception { Configuration config = TestConfiguration.createMinimalConfigurationForTest(); BasicAuthLogin auth = new BasicAuthLogin(); auth.setUsername("test"); auth.setPassword("test1"); DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/login"); request.content().writeBytes(JsonSerializer.getObjectMapper().writeValueAsBytes(auth)); TestHttpQueryDecoder decoder = new TestHttpQueryDecoder(config); decoder.decode(null, request, results); Assert.assertEquals(1, results.size()); Object result = results.iterator().next(); Assert.assertEquals(BasicAuthLoginRequest.class, result.getClass()); BasicAuthLoginRequestHandler handler = new BasicAuthLoginRequestHandler(config); CaptureChannelHandlerContext ctx = new CaptureChannelHandlerContext(); handler.channelRead(ctx, result); Assert.assertNotNull(ctx.msg); Assert.assertTrue(ctx.msg instanceof DefaultFullHttpResponse); DefaultFullHttpResponse response = (DefaultFullHttpResponse) ctx.msg; Assert.assertEquals(HttpResponseStatus.OK, response.status()); Assert.assertTrue(response.headers().contains(HttpHeaderNames.CONTENT_TYPE)); Assert.assertEquals(Constants.JSON_TYPE, response.headers().get(HttpHeaderNames.CONTENT_TYPE)); Assert.assertTrue(response.headers().contains(HttpHeaderNames.SET_COOKIE)); Cookie c = ClientCookieDecoder.STRICT.decode(response.headers().get(HttpHeaderNames.SET_COOKIE)); Assert.assertEquals(TestConfiguration.HTTP_ADDRESS_DEFAULT, c.domain()); Assert.assertEquals(86400, c.maxAge()); Assert.assertTrue(c.isHttpOnly()); Assert.assertTrue(c.isSecure()); Assert.assertEquals(Constants.COOKIE_NAME, c.name()); UUID.fromString(c.value()); }
Example #23
Source File: HttpClientOperations.java From reactor-netty with Apache License 2.0 | 4 votes |
ResponseState(HttpResponse response, HttpHeaders headers, ClientCookieDecoder decoder) { this.response = response; this.headers = headers; this.cookieHolder = Cookies.newClientResponseHolder(headers, decoder); }
Example #24
Source File: ClientCookieDecoderBenchmark.java From netty-4.1.22 with Apache License 2.0 | 4 votes |
@Benchmark public Cookie decodeCookieWithRfc1123ExpiresField() { return ClientCookieDecoder.STRICT.decode(COOKIE_STRING); }
Example #25
Source File: TestShiroAuthenticator.java From arcusplatform with Apache License 2.0 | 4 votes |
protected void assertCookieCleared(FullHttpResponse response) { Cookie cookie = ClientCookieDecoder.STRICT.decode(response.headers().get("Set-Cookie")); assertEquals("", cookie.value()); }
Example #26
Source File: TestShiroAuthenticator.java From arcusplatform with Apache License 2.0 | 4 votes |
protected void assertCookieSet(FullHttpResponse response) { Cookie cookie = ClientCookieDecoder.STRICT.decode(response.headers().get("Set-Cookie")); assertEquals("session-id", cookie.value()); }
Example #27
Source File: TestShiroAuthenticatorWithCheckIp.java From arcusplatform with Apache License 2.0 | 4 votes |
protected void assertCookieCleared(FullHttpResponse response) { Cookie cookie = ClientCookieDecoder.STRICT.decode(response.headers().get("Set-Cookie")); assertEquals("", cookie.value()); }
Example #28
Source File: TestShiroAuthenticatorWithCheckIp.java From arcusplatform with Apache License 2.0 | 4 votes |
protected void assertCookieSet(FullHttpResponse response) { Cookie cookie = ClientCookieDecoder.STRICT.decode(response.headers().get("Set-Cookie")); assertEquals("session-id", cookie.value()); }
Example #29
Source File: HttpClient.java From reactor-netty with Apache License 2.0 | 3 votes |
/** * Configure the * {@link ClientCookieEncoder} and {@link ClientCookieDecoder} * * @param encoder the preferred ClientCookieEncoder * @param decoder the preferred ClientCookieDecoder * * @return a new {@link HttpClient} */ public final HttpClient cookieCodec(ClientCookieEncoder encoder, ClientCookieDecoder decoder) { Objects.requireNonNull(encoder, "encoder"); Objects.requireNonNull(decoder, "decoder"); HttpClient dup = duplicate(); dup.configuration().cookieEncoder = encoder; dup.configuration().cookieDecoder = decoder; return dup; }
Example #30
Source File: HttpClient.java From reactor-netty with Apache License 2.0 | 3 votes |
/** * Configure the * {@link ClientCookieEncoder}, {@link ClientCookieDecoder} will be * chosen based on the encoder * * @param encoder the preferred ClientCookieEncoder * * @return a new {@link HttpClient} */ public final HttpClient cookieCodec(ClientCookieEncoder encoder) { Objects.requireNonNull(encoder, "encoder"); ClientCookieDecoder decoder = encoder == ClientCookieEncoder.LAX ? ClientCookieDecoder.LAX : ClientCookieDecoder.STRICT; return cookieCodec(encoder, decoder); }