@ -262,24 +262,26 @@ final class DefaultWebClientBuilder implements WebClient.Builder {
@@ -262,24 +262,26 @@ final class DefaultWebClientBuilder implements WebClient.Builder {
* Others can be plugged via `ClientHttpConnector`.
@ -23,12 +27,10 @@ The simplest way to create a `WebClient` is through one of the static factory me
@@ -23,12 +27,10 @@ The simplest way to create a `WebClient` is through one of the static factory me
* `WebClient.create()`
* `WebClient.create(String baseUrl)`
The above methods use the Reactor Netty `HttpClient` with default settings and expect
`io.projectreactor.netty:reactor-netty` to be on the classpath.
You can also use `WebClient.builder()` with further options:
* `uriBuilderFactory`: Customized `UriBuilderFactory` to use as a base URL.
* `defaultUriVariables`: default values to use when expanding URI templates.
* `defaultHeader`: Headers for every request.
* `defaultCookie`: Cookies for every request.
* `defaultRequest`: `Consumer` to customize every request.
@ -36,33 +38,25 @@ You can also use `WebClient.builder()` with further options:
@@ -36,33 +38,25 @@ You can also use `WebClient.builder()` with further options:
@ -94,37 +88,29 @@ modified copy without affecting the original instance, as the following example
@@ -94,37 +88,29 @@ modified copy without affecting the original instance, as the following example
[[webflux-client-builder-maxinmemorysize]]
=== MaxInMemorySize
Spring WebFlux configures <<web-reactive.adoc#webflux-codecs-limits,limits>> for buffering
data in-memory in codec to avoid application memory issues. By the default this is
configured to 256KB and if that's not enough for your use case, you'll see the following:
Codecs have <<web-reactive.adoc#webflux-codecs-limits,limits>> for buffering data in
memory to avoid application memory issues. By the default those are set to 256KB.
If that's not enough you'll get the following error:
----
org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer
----
You can configure this limit on all default codecs with the following code sample:
To change the limit for default codecs, use the following:
@ -132,7 +118,7 @@ You can configure this limit on all default codecs with the following code sampl
@@ -132,7 +118,7 @@ You can configure this limit on all default codecs with the following code sampl
[[webflux-client-builder-reactor]]
=== Reactor Netty
To customize Reactor Netty settings, simple provide a pre-configured `HttpClient`:
To customize Reactor Netty settings, provide a pre-configured `HttpClient`:
@ -457,8 +443,30 @@ The following example shows how to customize Apache HttpComponents `HttpClient`
@@ -457,8 +443,30 @@ The following example shows how to customize Apache HttpComponents `HttpClient`
[[webflux-client-retrieve]]
== `retrieve()`
The `retrieve()` method is the easiest way to get a response body and decode it.
The following example shows how to do so:
The `retrieve()` method can be used to declare how to extract the response. For example:
@ -500,11 +508,9 @@ You can also get a stream of objects decoded from the response, as the following
@@ -500,11 +508,9 @@ You can also get a stream of objects decoded from the response, as the following
.bodyToFlow<Quote>()
----
By default, responses with 4xx or 5xx status codes result in an
`WebClientResponseException` or one of its HTTP status specific sub-classes, such as
`WebClientResponseException.BadRequest`, `WebClientResponseException.NotFound`, and others.
You can also use the `onStatus` method to customize the resulting exception,
as the following example shows:
By default, 4xx or 5xx responses result in an `WebClientResponseException`, including
sub-classes for specific HTTP status codes. To customize the handling of error