Class HttpRequestValues.Builder
java.lang.Object
org.springframework.web.service.invoker.HttpRequestValues.Builder
- Direct Known Subclasses:
ReactiveHttpRequestValues.Builder
- Enclosing class:
- HttpRequestValues
Builder for
HttpRequestValues.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddAttribute(String name, Object value) Configure an attribute to associate with the request.Add the given cookie name and values.Add the given header name and values.addRequestParameter(String name, String... values) Add the given request parameter name and values.addRequestPart(String name, Object part) Add a part for a multipart request.<T,P extends Publisher<T>>
HttpRequestValues.BuilderaddRequestPart(String name, P publisher, ResolvableType type) Deprecated, for removal: This API element is subject to removal in a future version.build()Build theHttpRequestValuesinstance.protected Objectprotected HttpRequestValuescreateRequestValues(HttpMethod httpMethod, URI uri, String uriTemplate, Map<String, String> uriVars, HttpHeaders headers, MultiValueMap<String, String> cookies, Map<String, Object> attributes, Object bodyValue) Deprecated, for removal: This API element is subject to removal in a future version.in favour ofcreateRequestValues(HttpMethod, URI, UriBuilderFactory, String, Map, HttpHeaders, MultiValueMap, Map, Object)to be removed in 6.2.protected HttpRequestValuescreateRequestValues(HttpMethod httpMethod, URI uri, UriBuilderFactory uriBuilderFactory, String uriTemplate, Map<String, String> uriVars, HttpHeaders headers, MultiValueMap<String, String> cookies, Map<String, Object> attributes, Object bodyValue) CreateHttpRequestValuesfrom values passed to theHttpRequestValues.Builder.protected booleanhasBody()protected booleanhasParts()Set the media types for the requestAcceptheader.<T,P extends Publisher<T>>
voidsetBody(P body, ParameterizedTypeReference<T> elementTye) Deprecated, for removal: This API element is subject to removal in a future version.in favor ofReactiveHttpRequestValues.Builder.setBodyPublisher(P, org.springframework.core.ParameterizedTypeReference<T>); to be removed in 6.2voidsetBodyValue(Object bodyValue) Set the request body as an Object to be serialized.setContentType(MediaType contentType) Set the media type for the requestContent-Typeheader.setHttpMethod(HttpMethod httpMethod) Set the HTTP method for the request.Set the URL to use.setUriBuilderFactory(UriBuilderFactory uriBuilderFactory) Set theUriBuilderFactorythat will be used to expand theHttpRequestValues.getUriTemplate().setUriTemplate(String uriTemplate) Set the request URL as a String template.setUriVariable(String name, String value) Add a URI variable name-value pair.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
setHttpMethod
Set the HTTP method for the request. -
setUri
Set the URL to use. When set, this overrides the URI template from theHttpExchangeannotation. -
setUriBuilderFactory
public HttpRequestValues.Builder setUriBuilderFactory(@Nullable UriBuilderFactory uriBuilderFactory) Set theUriBuilderFactorythat will be used to expand theHttpRequestValues.getUriTemplate().- Since:
- 6.1
-
setUriTemplate
Set the request URL as a String template. -
setUriVariable
Add a URI variable name-value pair. -
setAccept
Set the media types for the requestAcceptheader. -
setContentType
Set the media type for the requestContent-Typeheader. -
addHeader
Add the given header name and values. -
addCookie
Add the given cookie name and values. -
addRequestParameter
Add the given request parameter name and values.When
"content-type"is set to"application/x-www-form-urlencoded", request parameters are encoded in the request body. Otherwise, they are added as URL query parameters. -
addRequestPart
Add a part for a multipart request. The part may be:- String -- form field
Resource-- file part- Object -- content to be encoded (e.g. to JSON)
HttpEntity-- part content and headers although generally it's easier to add headers through the returned builder
-
addRequestPart
@Deprecated(since="6.1", forRemoval=true) public <T,P extends Publisher<T>> HttpRequestValues.Builder addRequestPart(String name, P publisher, ResolvableType type) Deprecated, for removal: This API element is subject to removal in a future version.in favor ofReactiveHttpRequestValues.Builder.addRequestPartPublisher(java.lang.String, P, org.springframework.core.ParameterizedTypeReference<T>); to be removed in 6.2Variant ofaddRequestPart(String, Object)that allows the part value to be produced by aPublisher. -
addAttribute
Configure an attribute to associate with the request.- Parameters:
name- the attribute namevalue- the attribute value
-
setBodyValue
Set the request body as an Object to be serialized. -
setBody
@Deprecated(since="6.1", forRemoval=true) public <T,P extends Publisher<T>> void setBody(P body, ParameterizedTypeReference<T> elementTye) Deprecated, for removal: This API element is subject to removal in a future version.in favor ofReactiveHttpRequestValues.Builder.setBodyPublisher(P, org.springframework.core.ParameterizedTypeReference<T>); to be removed in 6.2Set the request body as a Reactive Streams Publisher.This is mutually exclusive with, and resets any previously set body value.
-
build
Build theHttpRequestValuesinstance. -
hasParts
protected boolean hasParts() -
hasBody
protected boolean hasBody() -
buildMultipartBody
-
createRequestValues
@Deprecated(since="6.1", forRemoval=true) protected HttpRequestValues createRequestValues(@Nullable HttpMethod httpMethod, @Nullable URI uri, @Nullable String uriTemplate, Map<String, String> uriVars, HttpHeaders headers, MultiValueMap<String, String> cookies, Map<String, Object> attributes, @Nullable Object bodyValue) Deprecated, for removal: This API element is subject to removal in a future version.in favour ofcreateRequestValues(HttpMethod, URI, UriBuilderFactory, String, Map, HttpHeaders, MultiValueMap, Map, Object)to be removed in 6.2.CreateHttpRequestValuesfrom values passed to theHttpRequestValues.Builder. -
createRequestValues
protected HttpRequestValues createRequestValues(@Nullable HttpMethod httpMethod, @Nullable URI uri, @Nullable UriBuilderFactory uriBuilderFactory, @Nullable String uriTemplate, Map<String, String> uriVars, HttpHeaders headers, MultiValueMap<String, String> cookies, Map<String, Object> attributes, @Nullable Object bodyValue) CreateHttpRequestValuesfrom values passed to theHttpRequestValues.Builder.- Since:
- 6.1
-
ReactiveHttpRequestValues.Builder.addRequestPartPublisher(java.lang.String, P, org.springframework.core.ParameterizedTypeReference<T>); to be removed in 6.2