Skip to content

Commit e44f84e

Browse files
committed
Restore Jetty 10 compatibility in JettyClientHttpResponse
Closes gh-32337
1 parent 464fa7e commit e44f84e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

spring-web/src/main/java/org/springframework/http/client/reactive/JettyClientHttpResponse.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.util.regex.Matcher;
2222
import java.util.regex.Pattern;
2323

24-
import org.eclipse.jetty.http.HttpField;
2524
import org.eclipse.jetty.reactive.client.ReactiveResponse;
2625
import reactor.core.publisher.Flux;
2726

@@ -55,23 +54,29 @@ public JettyClientHttpResponse(ReactiveResponse reactiveResponse, Flux<DataBuffe
5554
}
5655

5756
private static HttpHeaders adaptHeaders(ReactiveResponse response) {
58-
MultiValueMap<String, String> headers = new JettyHeadersAdapter(response.getHeaders());
57+
MultiValueMap<String, String> headers = (Jetty10HttpFieldsHelper.jetty10Present() ?
58+
Jetty10HttpFieldsHelper.getHttpHeaders(response.getResponse()) :
59+
new JettyHeadersAdapter(response.getHeaders()));
5960
return HttpHeaders.readOnlyHttpHeaders(headers);
6061
}
62+
6163
private static MultiValueMap<String, ResponseCookie> adaptCookies(ReactiveResponse response) {
6264
MultiValueMap<String, ResponseCookie> result = new LinkedMultiValueMap<>();
63-
List<HttpField> cookieHeaders = response.getHeaders().getFields(HttpHeaders.SET_COOKIE);
64-
cookieHeaders.forEach(header ->
65-
HttpCookie.parse(header.getValue()).forEach(cookie -> result.add(cookie.getName(),
65+
MultiValueMap<String, String> headers = adaptHeaders(response);
66+
List<String> cookieHeader = headers.get(HttpHeaders.SET_COOKIE);
67+
if (!CollectionUtils.isEmpty(cookieHeader)) {
68+
cookieHeader.forEach(header ->
69+
HttpCookie.parse(header).forEach(cookie -> result.add(cookie.getName(),
6670
ResponseCookie.fromClientResponse(cookie.getName(), cookie.getValue())
6771
.domain(cookie.getDomain())
6872
.path(cookie.getPath())
6973
.maxAge(cookie.getMaxAge())
7074
.secure(cookie.getSecure())
7175
.httpOnly(cookie.isHttpOnly())
72-
.sameSite(parseSameSite(header.getValue()))
76+
.sameSite(parseSameSite(header))
7377
.build()))
7478
);
79+
}
7580
return CollectionUtils.unmodifiableMultiValueMap(result);
7681
}
7782

0 commit comments

Comments
 (0)