Skip to content

Commit 4a10fa6

Browse files
committed
Expose HttpRequest from ClientResponse
Closes gh-28397
1 parent ef8d1db commit 4a10fa6

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ public interface ClientResponse {
7272
*/
7373
ExchangeStrategies strategies();
7474

75+
/**
76+
* Return the request associated with the response.
77+
* @since 6.1
78+
*/
79+
HttpRequest request();
80+
7581
/**
7682
* Extract the body with the given {@code BodyExtractor}.
7783
* @param extractor the {@code BodyExtractor} that reads from the response

spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ public String logPrefix() {
262262
return this.logPrefix;
263263
}
264264

265-
// Used by DefaultClientResponseBuilder
266-
HttpRequest request() {
265+
@Override
266+
public HttpRequest request() {
267267
return this.requestSupplier.get();
268268
}
269269

spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/ClientResponseWrapper.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
2525

2626
import org.springframework.core.ParameterizedTypeReference;
2727
import org.springframework.http.HttpHeaders;
28+
import org.springframework.http.HttpRequest;
2829
import org.springframework.http.HttpStatusCode;
2930
import org.springframework.http.MediaType;
3031
import org.springframework.http.ResponseCookie;
@@ -68,11 +69,6 @@ public ClientResponse response() {
6869
return this.delegate;
6970
}
7071

71-
@Override
72-
public ExchangeStrategies strategies() {
73-
return this.delegate.strategies();
74-
}
75-
7672
@Override
7773
public HttpStatusCode statusCode() {
7874
return this.delegate.statusCode();
@@ -88,6 +84,16 @@ public MultiValueMap<String, ResponseCookie> cookies() {
8884
return this.delegate.cookies();
8985
}
9086

87+
@Override
88+
public ExchangeStrategies strategies() {
89+
return this.delegate.strategies();
90+
}
91+
92+
@Override
93+
public HttpRequest request() {
94+
return this.delegate.request();
95+
}
96+
9197
@Override
9298
public <T> T body(BodyExtractor<T, ? super ClientHttpResponse> extractor) {
9399
return this.delegate.body(extractor);

0 commit comments

Comments
 (0)