类 DefaultWebClient.DefaultRequestBodyUriSpec
- 所有已实现的接口:
WebClient.RequestBodySpec,WebClient.RequestBodyUriSpec,WebClient.RequestHeadersSpec<WebClient.RequestBodySpec>,WebClient.RequestHeadersUriSpec<WebClient.RequestBodySpec>,WebClient.UriSpec<WebClient.RequestBodySpec>
- 封闭类:
- DefaultWebClient
-
字段概要
字段修饰符和类型字段说明private Function<reactor.util.context.Context,reactor.util.context.Context> private HttpHeadersprivate final HttpMethodprivate Consumer<ClientHttpRequest>private BodyInserter<?,? super ClientHttpRequest> private URI -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明Set the list of acceptable media types, as specified by theAcceptheader.acceptCharset(Charset... acceptableCharsets) Set the list of acceptable charsets, as specified by theAccept-Charsetheader.Set the attribute with the given name to the given value.attributes(Consumer<Map<String, Object>> attributesConsumer) Provides access to every attribute declared so far with the possibility to add, replace, or remove values.body(BodyInserter<?, ? super ClientHttpRequest> inserter) Set the body of the request using the given body inserter.Variant ofWebClient.RequestBodySpec.body(Publisher, ParameterizedTypeReference)that allows using any producer that can be resolved toPublisherviaReactiveAdapterRegistry.Variant ofWebClient.RequestBodySpec.body(Publisher, Class)that allows using any producer that can be resolved toPublisherviaReactiveAdapterRegistry.<T,P extends org.reactivestreams.Publisher<T>>
WebClient.RequestHeadersSpec<?>body(P publisher, cn.taketoday.core.ParameterizedTypeReference<T> elementTypeRef) Variant ofWebClient.RequestBodySpec.body(Publisher, Class)that allows providing element type information with generics.<T,P extends org.reactivestreams.Publisher<T>>
WebClient.RequestHeadersSpec<?>Shortcut forWebClient.RequestBodySpec.body(BodyInserter)with a Publisher inserter.Shortcut forWebClient.RequestBodySpec.body(BodyInserter)with a value inserter.contentLength(long contentLength) Set the length of the body in bytes, as specified by theContent-Lengthheader.contentType(MediaType contentType) Set the media type of the body, as specified by theContent-Typeheader.Provide a function to populate the ReactorContext.Add a cookie with the given name and value.Provides access to every cookie declared so far with the possibility to add, replace, or remove values.private HttpRequestreactor.core.publisher.Mono<ClientResponse>exchange()Perform the HTTP request and return aClientResponsewith the response status and headers.<V> reactor.core.publisher.Flux<V>exchangeToFlux(Function<ClientResponse, ? extends reactor.core.publisher.Flux<V>> responseHandler) An alternative toWebClient.RequestHeadersSpec.retrieve()that provides more control via access to theClientResponse.<V> reactor.core.publisher.Mono<V>exchangeToMono(Function<ClientResponse, ? extends reactor.core.publisher.Mono<V>> responseHandler) An alternative toWebClient.RequestHeadersSpec.retrieve()that provides more control via access to theClientResponse.private HttpHeadersAdd the given, single header value under the given name.headers(Consumer<HttpHeaders> headersConsumer) Provides access to every header declared so far with the possibility to add, replace, or remove values.httpRequest(Consumer<ClientHttpRequest> requestConsumer) Callback for access to theClientHttpRequestthat in turn provides access to the native request of the underlying HTTP library.ifModifiedSince(ZonedDateTime ifModifiedSince) Set the value of theIf-Modified-Sinceheader.ifNoneMatch(String... ifNoneMatches) Set the values of theIf-None-Matchheader.private voidinitCookies(cn.taketoday.util.MultiValueMap<String, String> out) private voidinitHeaders(HttpHeaders out) private ClientRequest.Builderprivate URIinitUri()retrieve()Proceed to declare how to extract the response.Specify the URI for the request using a URI template and URI variables.uri(String uriTemplate, Function<UriBuilder, URI> uriFunction) Specify the URI starting with a URI template and finishing off with aUriBuildercreated from the template.Specify the URI for the request using a URI template and URI variables.Specify the URI using an absolute, fully constructedURI.uri(Function<UriBuilder, URI> uriFunction) Specify the URI by through aUriBuilder.
-
字段详细资料
-
httpMethod
-
uri
-
headers
-
cookies
-
inserter
-
attributes
-
contextModifier
@Nullable private Function<reactor.util.context.Context,reactor.util.context.Context> contextModifier -
httpRequestConsumer
-
-
构造器详细资料
-
DefaultRequestBodyUriSpec
DefaultRequestBodyUriSpec(HttpMethod httpMethod)
-
-
方法详细资料
-
uri
从接口复制的说明:WebClient.UriSpecSpecify the URI for the request using a URI template and URI variables. If aUriBuilderFactorywas configured for the client (e.g. with a base URI) it will be used to expand the URI template.- 指定者:
uri在接口中WebClient.UriSpec<WebClient.RequestBodySpec>
-
uri
从接口复制的说明:WebClient.UriSpecSpecify the URI for the request using a URI template and URI variables. If aUriBuilderFactorywas configured for the client (e.g. with a base URI) it will be used to expand the URI template.- 指定者:
uri在接口中WebClient.UriSpec<WebClient.RequestBodySpec>
-
uri
从接口复制的说明:WebClient.UriSpecSpecify the URI starting with a URI template and finishing off with aUriBuildercreated from the template.- 指定者:
uri在接口中WebClient.UriSpec<WebClient.RequestBodySpec>
-
uri
从接口复制的说明:WebClient.UriSpecSpecify the URI by through aUriBuilder. -
uri
从接口复制的说明:WebClient.UriSpecSpecify the URI using an absolute, fully constructedURI.- 指定者:
uri在接口中WebClient.UriSpec<WebClient.RequestBodySpec>
-
getHeaders
-
getCookies
-
header
从接口复制的说明:WebClient.RequestHeadersSpecAdd the given, single header value under the given name.- 指定者:
header在接口中WebClient.RequestHeadersSpec<WebClient.RequestBodySpec>- 参数:
headerName- the header nameheaderValues- the header value(s)- 返回:
- this builder
-
headers
从接口复制的说明:WebClient.RequestHeadersSpecProvides access to every header declared so far with the possibility to add, replace, or remove values.- 指定者:
headers在接口中WebClient.RequestHeadersSpec<WebClient.RequestBodySpec>- 参数:
headersConsumer- the consumer to provide access to- 返回:
- this builder
-
accept
从接口复制的说明:WebClient.RequestHeadersSpecSet the list of acceptable media types, as specified by theAcceptheader.- 指定者:
accept在接口中WebClient.RequestHeadersSpec<WebClient.RequestBodySpec>- 参数:
acceptableMediaTypes- the acceptable media types- 返回:
- this builder
-
acceptCharset
从接口复制的说明:WebClient.RequestHeadersSpecSet the list of acceptable charsets, as specified by theAccept-Charsetheader.- 指定者:
acceptCharset在接口中WebClient.RequestHeadersSpec<WebClient.RequestBodySpec>- 参数:
acceptableCharsets- the acceptable charsets- 返回:
- this builder
-
contentType
从接口复制的说明:WebClient.RequestBodySpecSet the media type of the body, as specified by theContent-Typeheader.- 指定者:
contentType在接口中WebClient.RequestBodySpec- 参数:
contentType- the content type- 返回:
- this builder
- 另请参阅:
-
contentLength
从接口复制的说明:WebClient.RequestBodySpecSet the length of the body in bytes, as specified by theContent-Lengthheader.- 指定者:
contentLength在接口中WebClient.RequestBodySpec- 参数:
contentLength- the content length- 返回:
- this builder
- 另请参阅:
-
cookie
从接口复制的说明:WebClient.RequestHeadersSpecAdd a cookie with the given name and value.- 指定者:
cookie在接口中WebClient.RequestHeadersSpec<WebClient.RequestBodySpec>- 参数:
name- the cookie namevalue- the cookie value- 返回:
- this builder
-
cookies
public DefaultWebClient.DefaultRequestBodyUriSpec cookies(Consumer<cn.taketoday.util.MultiValueMap<String, String>> cookiesConsumer) 从接口复制的说明:WebClient.RequestHeadersSpecProvides access to every cookie declared so far with the possibility to add, replace, or remove values.- 指定者:
cookies在接口中WebClient.RequestHeadersSpec<WebClient.RequestBodySpec>- 参数:
cookiesConsumer- the consumer to provide access to- 返回:
- this builder
-
ifModifiedSince
从接口复制的说明:WebClient.RequestHeadersSpecSet the value of theIf-Modified-Sinceheader.The date should be specified as the number of milliseconds since January 1, 1970 GMT.
- 指定者:
ifModifiedSince在接口中WebClient.RequestHeadersSpec<WebClient.RequestBodySpec>- 参数:
ifModifiedSince- the new value of the header- 返回:
- this builder
-
ifNoneMatch
从接口复制的说明:WebClient.RequestHeadersSpecSet the values of theIf-None-Matchheader.- 指定者:
ifNoneMatch在接口中WebClient.RequestHeadersSpec<WebClient.RequestBodySpec>- 参数:
ifNoneMatches- the new value of the header- 返回:
- this builder
-
attribute
从接口复制的说明:WebClient.RequestHeadersSpecSet the attribute with the given name to the given value.- 指定者:
attribute在接口中WebClient.RequestHeadersSpec<WebClient.RequestBodySpec>- 参数:
name- the name of the attribute to addvalue- the value of the attribute to add- 返回:
- this builder
-
attributes
从接口复制的说明:WebClient.RequestHeadersSpecProvides access to every attribute declared so far with the possibility to add, replace, or remove values.- 指定者:
attributes在接口中WebClient.RequestHeadersSpec<WebClient.RequestBodySpec>- 参数:
attributesConsumer- the consumer to provide access to- 返回:
- this builder
-
context
public WebClient.RequestBodySpec context(Function<reactor.util.context.Context, reactor.util.context.Context> contextModifier) 从接口复制的说明:WebClient.RequestHeadersSpecProvide a function to populate the ReactorContext.- 指定者:
context在接口中WebClient.RequestHeadersSpec<WebClient.RequestBodySpec>- 参数:
contextModifier- the function to modify the context with
-
httpRequest
从接口复制的说明:WebClient.RequestHeadersSpecCallback for access to theClientHttpRequestthat in turn provides access to the native request of the underlying HTTP library. This could be useful for setting advanced, per-request options that exposed by the underlying library.- 指定者:
httpRequest在接口中WebClient.RequestHeadersSpec<WebClient.RequestBodySpec>- 参数:
requestConsumer- a consumer to access theClientHttpRequestwith- 返回:
ResponseSpecto specify how to decode the body
-
bodyValue
从接口复制的说明:WebClient.RequestBodySpecShortcut forWebClient.RequestBodySpec.body(BodyInserter)with a value inserter. For example:Person person = ... ; Mono<Void> result = client.post() .uri("/persons/{id}", id) .contentType(MediaType.APPLICATION_JSON) .bodyValue(person) .retrieve() .bodyToMono(Void.class);For multipart requests consider providing
MultiValueMapprepared withMultipartBodyBuilder.- 指定者:
bodyValue在接口中WebClient.RequestBodySpec- 参数:
body- the value to write to the request body- 返回:
- this builder
-
body
public <T,P extends org.reactivestreams.Publisher<T>> WebClient.RequestHeadersSpec<?> body(P publisher, cn.taketoday.core.ParameterizedTypeReference<T> elementTypeRef) 从接口复制的说明:WebClient.RequestBodySpecVariant ofWebClient.RequestBodySpec.body(Publisher, Class)that allows providing element type information with generics.- 指定者:
body在接口中WebClient.RequestBodySpec- 类型参数:
T- the type of the elements contained in the publisherP- the type of thePublisher- 参数:
publisher- thePublisherto write to the requestelementTypeRef- the type of elements published- 返回:
- this builder
-
body
public <T,P extends org.reactivestreams.Publisher<T>> WebClient.RequestHeadersSpec<?> body(P publisher, Class<T> elementClass) 从接口复制的说明:WebClient.RequestBodySpecShortcut forWebClient.RequestBodySpec.body(BodyInserter)with a Publisher inserter. For example:Mono<Person> personMono = ... ; Mono<Void> result = client.post() .uri("/persons/{id}", id) .contentType(MediaType.APPLICATION_JSON) .body(personMono, Person.class) .retrieve() .bodyToMono(Void.class);- 指定者:
body在接口中WebClient.RequestBodySpec- 类型参数:
T- the type of the elements contained in the publisherP- the type of thePublisher- 参数:
publisher- thePublisherto write to the requestelementClass- the type of elements published- 返回:
- this builder
-
body
从接口复制的说明:WebClient.RequestBodySpecVariant ofWebClient.RequestBodySpec.body(Publisher, Class)that allows using any producer that can be resolved toPublisherviaReactiveAdapterRegistry.- 指定者:
body在接口中WebClient.RequestBodySpec- 参数:
producer- the producer to write to the requestelementClass- the type of elements produced- 返回:
- this builder
-
body
public WebClient.RequestHeadersSpec<?> body(Object producer, cn.taketoday.core.ParameterizedTypeReference<?> elementTypeRef) 从接口复制的说明:WebClient.RequestBodySpecVariant ofWebClient.RequestBodySpec.body(Publisher, ParameterizedTypeReference)that allows using any producer that can be resolved toPublisherviaReactiveAdapterRegistry.- 指定者:
body在接口中WebClient.RequestBodySpec- 参数:
producer- the producer to write to the requestelementTypeRef- the type of elements produced- 返回:
- this builder
-
body
从接口复制的说明:WebClient.RequestBodySpecSet the body of the request using the given body inserter. SeeBodyInsertersfor built-inBodyInserterimplementations.- 指定者:
body在接口中WebClient.RequestBodySpec- 参数:
inserter- the body inserter to use for the request body- 返回:
- this builder
- 另请参阅:
-
retrieve
从接口复制的说明:WebClient.RequestHeadersSpecProceed to declare how to extract the response. For example to extract aResponseEntitywith status, headers, and body:Mono<ResponseEntity<Person>> entityMono = client.get() .uri("/persons/1") .accept(MediaType.APPLICATION_JSON) .retrieve() .toEntity(Person.class);Or if interested only in the body:
Mono<Person> entityMono = client.get() .uri("/persons/1") .accept(MediaType.APPLICATION_JSON) .retrieve() .bodyToMono(Person.class);By default, 4xx and 5xx responses result in a
WebClientResponseException. To customize error handling, useonStatushandlers. -
createRequest
-
exchangeToMono
public <V> reactor.core.publisher.Mono<V> exchangeToMono(Function<ClientResponse, ? extends reactor.core.publisher.Mono<V>> responseHandler) 从接口复制的说明:WebClient.RequestHeadersSpecAn alternative toWebClient.RequestHeadersSpec.retrieve()that provides more control via access to theClientResponse. This can be useful for advanced scenarios, for example to decode the response differently depending on the response status:Mono<Person> entityMono = client.get() .uri("/persons/1") .accept(MediaType.APPLICATION_JSON) .exchangeToMono(response -> { if (response.statusCode().equals(HttpStatus.OK)) { return response.bodyToMono(Person.class); } else { return response.createError(); } });Note: After the returned
Monocompletes, the response body is automatically released if it hasn't been consumed. If the response content is needed, the provided function must declare how to decode it.- 指定者:
exchangeToMono在接口中WebClient.RequestHeadersSpec<WebClient.RequestBodySpec>- 类型参数:
V- the type of Object the response will be transformed to- 参数:
responseHandler- the function to handle the response with- 返回:
- a
Monoproduced from the response
-
exchangeToFlux
public <V> reactor.core.publisher.Flux<V> exchangeToFlux(Function<ClientResponse, ? extends reactor.core.publisher.Flux<V>> responseHandler) 从接口复制的说明:WebClient.RequestHeadersSpecAn alternative toWebClient.RequestHeadersSpec.retrieve()that provides more control via access to theClientResponse. This can be useful for advanced scenarios, for example to decode the response differently depending on the response status:Flux<Person> entityMono = client.get() .uri("/persons") .accept(MediaType.APPLICATION_JSON) .exchangeToFlux(response -> { if (response.statusCode().equals(HttpStatus.OK)) { return response.bodyToFlux(Person.class); } else { return response.createError().flux(); } });Note: After the returned
Fluxcompletes, the response body is automatically released if it hasn't been consumed. If the response content is needed, the provided function must declare how to decode it.- 指定者:
exchangeToFlux在接口中WebClient.RequestHeadersSpec<WebClient.RequestBodySpec>- 类型参数:
V- the type of Objects the response will be transformed to- 参数:
responseHandler- the function to handle the response with- 返回:
- a
Fluxof Objects produced from the response
-
exchange
从接口复制的说明:WebClient.RequestHeadersSpecPerform the HTTP request and return aClientResponsewith the response status and headers. You can then use methods of the response to consume the body:Mono<Person> mono = client.get() .uri("/persons/1") .accept(MediaType.APPLICATION_JSON) .exchange() .flatMap(response -> response.bodyToMono(Person.class)); Flux<Person> flux = client.get() .uri("/persons") .accept(MediaType.APPLICATION_STREAM_JSON) .exchange() .flatMapMany(response -> response.bodyToFlux(Person.class));NOTE: Unlike
WebClient.RequestHeadersSpec.retrieve(), when usingexchange(), it is the responsibility of the application to consume any response content regardless of the scenario (success, error, unexpected data, etc). Not doing so can cause a memory leak. SeeClientResponsefor a list of all the available options for consuming the body. Generally prefer usingWebClient.RequestHeadersSpec.retrieve()unless you have a good reason to useexchange()which does allow to check the response status and headers before deciding how or if to consume the response.Possibility to leak memory and/or connections; please use
WebClient.RequestHeadersSpec.exchangeToMono(Function),WebClient.RequestHeadersSpec.exchangeToFlux(Function); consider also usingWebClient.RequestHeadersSpec.retrieve()which provides access to the response status and headers viaResponseEntityalong with error status handling.- 指定者:
exchange在接口中WebClient.RequestHeadersSpec<WebClient.RequestBodySpec>- 返回:
- a
Monofor the response - 另请参阅:
-
initRequestBuilder
-
initUri
-
initHeaders
-
initCookies
-