Skip to content

Commit

Permalink
Merge #3039 into 1.1.16
Browse files Browse the repository at this point in the history
  • Loading branch information
violetagg committed Jan 24, 2024
2 parents a143f32 + f211a3e commit 6acd157
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2023 VMware, Inc. or its affiliates, All Rights Reserved.
* Copyright (c) 2011-2024 VMware, Inc. or its affiliates, All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -595,10 +595,6 @@ protected void afterMarkSentHeaders() {

@Override
protected void beforeMarkSentHeaders() {
if (!cookieList.isEmpty()) {
requestHeaders.add(HttpHeaderNames.COOKIE, cookieEncoder.encode(cookieList));
}

if (redirectedFrom.length > 0) {
if (redirectRequestConsumer != null) {
redirectRequestConsumer.accept(this);
Expand All @@ -608,6 +604,10 @@ protected void beforeMarkSentHeaders() {
previousRequestHeaders = null;
}
}

if (!cookieList.isEmpty()) {
requestHeaders.add(HttpHeaderNames.COOKIE, cookieEncoder.encode(cookieList));
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2023 VMware, Inc. or its affiliates, All Rights Reserved.
* Copyright (c) 2017-2024 VMware, Inc. or its affiliates, All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,6 +34,7 @@
import io.netty.handler.codec.http.HttpContent;
import io.netty.handler.codec.http.HttpHeaderNames;
import io.netty.handler.codec.http.HttpMethod;
import io.netty.handler.codec.http.cookie.DefaultCookie;
import io.netty.handler.ssl.SslHandler;
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
import io.netty.handler.ssl.util.SelfSignedCertificate;
Expand Down Expand Up @@ -759,4 +760,29 @@ void testIssue2670() {
.expectComplete()
.verify(Duration.ofSeconds(5));
}

@Test
@SuppressWarnings("CollectionUndefinedEquality")
void testIssue3035() {
disposableServer =
createServer()
.route(r -> r.get("/1", (req, res) -> res.sendRedirect("/2"))
.get("/2", (req, res) ->
req.cookies().containsKey("testCookie") ?
res.status(200).sendString(Mono.just("OK")) :
res.status(400).sendString(Mono.just("KO"))))
.bindNow();

createClient(disposableServer::address)
.followRedirect(
(req, res) -> res.status().code() == 302,
(headers, redirect) -> redirect.addCookie(new DefaultCookie("testCookie", "testCookie")))
.get()
.uri("/1")
.responseSingle((res, bytes) -> bytes.asString().zipWith(Mono.just(res.status().code())))
.as(StepVerifier::create)
.expectNextMatches(tuple -> "OK".equals(tuple.getT1()) && tuple.getT2() == 200)
.expectComplete()
.verify(Duration.ofSeconds(5));
}
}

0 comments on commit 6acd157

Please sign in to comment.