Skip to content

Commit 85dd3b7

Browse files
Minor code and doc polishment
1 parent 1bf43f0 commit 85dd3b7

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import reactor.core.publisher.Flux;
3434
import reactor.core.publisher.Mono;
3535

36+
import org.springframework.core.io.buffer.DataBufferFactory;
3637
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
3738
import org.springframework.http.HttpMethod;
3839
import org.springframework.lang.Nullable;
@@ -47,7 +48,7 @@
4748
public class ApacheClientHttpConnector implements ClientHttpConnector {
4849
private final CloseableHttpAsyncClient client;
4950

50-
private final DefaultDataBufferFactory dataBufferFactory;
51+
private final DataBufferFactory dataBufferFactory;
5152

5253
/**
5354
* Default constructor that creates and starts a new instance of {@link CloseableHttpAsyncClient}.

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
import java.nio.ByteBuffer;
2020
import java.util.Arrays;
21-
import java.util.Objects;
2221
import java.util.concurrent.atomic.AtomicBoolean;
2322

23+
import org.apache.hc.client5.http.cookie.Cookie;
2424
import org.apache.hc.client5.http.protocol.HttpClientContext;
2525
import org.apache.hc.core5.http.Header;
2626
import org.apache.hc.core5.http.HttpResponse;
@@ -29,7 +29,7 @@
2929
import reactor.core.publisher.Flux;
3030

3131
import org.springframework.core.io.buffer.DataBuffer;
32-
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
32+
import org.springframework.core.io.buffer.DataBufferFactory;
3333
import org.springframework.http.HttpHeaders;
3434
import org.springframework.http.HttpStatus;
3535
import org.springframework.http.ResponseCookie;
@@ -54,7 +54,7 @@ class ApacheClientHttpResponse implements ClientHttpResponse {
5454

5555
private final AtomicBoolean rejectSubscribers = new AtomicBoolean();
5656

57-
public ApacheClientHttpResponse(DefaultDataBufferFactory dataBufferFactory,
57+
public ApacheClientHttpResponse(DataBufferFactory dataBufferFactory,
5858
Message<HttpResponse, Publisher<ByteBuffer>> message,
5959
HttpClientContext context) {
6060

@@ -87,7 +87,7 @@ public MultiValueMap<String, ResponseCookie> getCookies() {
8787
result.add(cookie.getName(), ResponseCookie.from(cookie.getName(), cookie.getValue())
8888
.domain(cookie.getDomain())
8989
.path(cookie.getPath())
90-
.maxAge(Long.parseLong(Objects.toString(cookie.getAttribute(MAX_AGE_ATTR), "-1")))
90+
.maxAge(getMaxAgeSeconds(cookie))
9191
.secure(cookie.isSecure())
9292
.httpOnly(cookie.containsAttribute("httponly"))
9393
.build()));
@@ -108,4 +108,10 @@ public HttpHeaders getHeaders() {
108108
private void addHeader(HttpHeaders httpHeaders, Header header) {
109109
httpHeaders.add(header.getName(), header.getValue());
110110
}
111+
112+
private long getMaxAgeSeconds(Cookie cookie) {
113+
String maxAgeAttribute = cookie.getAttribute(MAX_AGE_ATTR);
114+
115+
return maxAgeAttribute == null ? -1 : Long.parseLong(maxAgeAttribute);
116+
}
111117
}

src/docs/asciidoc/web/webflux-webclient.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ The following example shows how to customize Apache `HttpClient` settings:
391391
val client = HttpAsyncClients.custom().apply {
392392
setDefaultRequestConfig(...)
393393
}.build()
394-
val connector: ClientHttpConnector = ApacheClientHttpConnector(client)
394+
val connector = ApacheClientHttpConnector(client)
395395
val webClient = WebClient.builder().clientConnector(connector).build()
396396
----
397397

src/docs/asciidoc/web/webflux.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,9 @@ request handling, on top of which concrete programming models such as annotated
312312
controllers and functional endpoints are built.
313313
* For the client side, there is a basic `ClientHttpConnector` contract to perform HTTP
314314
requests with non-blocking I/O and Reactive Streams back pressure, along with adapters for
315-
https://github.com/reactor/reactor-netty[Reactor Netty] and for the reactive
316-
https://github.com/jetty-project/jetty-reactive-httpclient[Jetty HttpClient].
317-
https://hc.apache.org/[Apache HttpComponents].
315+
https://github.com/reactor/reactor-netty[Reactor Netty], reactive
316+
https://github.com/jetty-project/jetty-reactive-httpclient[Jetty HttpClient]
317+
and https://hc.apache.org/[Apache HttpComponents].
318318
The higher level <<web-reactive.adoc#webflux-client, WebClient>> used in applications
319319
builds on this basic contract.
320320
* For client and server, <<webflux-codecs, codecs>> to use to serialize and

0 commit comments

Comments
 (0)