Restore Jetty 10 compatibility in JettyClientHttpResponse
Closes gh-32337
This commit is contained in:
@@ -21,7 +21,6 @@ import java.util.List;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.eclipse.jetty.http.HttpField;
|
|
||||||
import org.eclipse.jetty.reactive.client.ReactiveResponse;
|
import org.eclipse.jetty.reactive.client.ReactiveResponse;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
|
|
||||||
@@ -55,23 +54,29 @@ class JettyClientHttpResponse extends AbstractClientHttpResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static HttpHeaders adaptHeaders(ReactiveResponse response) {
|
private static HttpHeaders adaptHeaders(ReactiveResponse response) {
|
||||||
MultiValueMap<String, String> headers = new JettyHeadersAdapter(response.getHeaders());
|
MultiValueMap<String, String> headers = (Jetty10HttpFieldsHelper.jetty10Present() ?
|
||||||
|
Jetty10HttpFieldsHelper.getHttpHeaders(response.getResponse()) :
|
||||||
|
new JettyHeadersAdapter(response.getHeaders()));
|
||||||
return HttpHeaders.readOnlyHttpHeaders(headers);
|
return HttpHeaders.readOnlyHttpHeaders(headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MultiValueMap<String, ResponseCookie> adaptCookies(ReactiveResponse response) {
|
private static MultiValueMap<String, ResponseCookie> adaptCookies(ReactiveResponse response) {
|
||||||
MultiValueMap<String, ResponseCookie> result = new LinkedMultiValueMap<>();
|
MultiValueMap<String, ResponseCookie> result = new LinkedMultiValueMap<>();
|
||||||
List<HttpField> cookieHeaders = response.getHeaders().getFields(HttpHeaders.SET_COOKIE);
|
MultiValueMap<String, String> headers = adaptHeaders(response);
|
||||||
cookieHeaders.forEach(header ->
|
List<String> cookieHeader = headers.get(HttpHeaders.SET_COOKIE);
|
||||||
HttpCookie.parse(header.getValue()).forEach(cookie -> result.add(cookie.getName(),
|
if (!CollectionUtils.isEmpty(cookieHeader)) {
|
||||||
|
cookieHeader.forEach(header ->
|
||||||
|
HttpCookie.parse(header).forEach(cookie -> result.add(cookie.getName(),
|
||||||
ResponseCookie.fromClientResponse(cookie.getName(), cookie.getValue())
|
ResponseCookie.fromClientResponse(cookie.getName(), cookie.getValue())
|
||||||
.domain(cookie.getDomain())
|
.domain(cookie.getDomain())
|
||||||
.path(cookie.getPath())
|
.path(cookie.getPath())
|
||||||
.maxAge(cookie.getMaxAge())
|
.maxAge(cookie.getMaxAge())
|
||||||
.secure(cookie.getSecure())
|
.secure(cookie.getSecure())
|
||||||
.httpOnly(cookie.isHttpOnly())
|
.httpOnly(cookie.isHttpOnly())
|
||||||
.sameSite(parseSameSite(header.getValue()))
|
.sameSite(parseSameSite(header))
|
||||||
.build()))
|
.build()))
|
||||||
);
|
);
|
||||||
|
}
|
||||||
return CollectionUtils.unmodifiableMultiValueMap(result);
|
return CollectionUtils.unmodifiableMultiValueMap(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user