Top Description Inners Fields Constructors Methods
org.springframework.web.service.invoker

public Class HttpRequestValues

extends Object
Class Inheritance
Known Direct Subclasses
org.springframework.web.service.invoker.ReactiveHttpRequestValues
Imports
java.net.URI, java.util.Collections, .HashMap, .LinkedHashMap, .List, .Map, org.reactivestreams.Publisher, org.springframework.core.ParameterizedTypeReference, .ResolvableType, org.springframework.http.HttpEntity, .HttpHeaders, .HttpMethod, .MediaType, org.springframework.lang.Nullable, org.springframework.util.Assert, .CollectionUtils, .LinkedMultiValueMap, .MultiValueMap, org.springframework.web.util.UriBuilderFactory, .UriComponentsBuilder, .UriUtils

Container for HTTP request values extracted from an @HttpExchange-annotated method and argument values passed to it. This is then given to HttpExchangeAdapter to adapt to the underlying HTTP client.
Authors
Rossen Stoyanchev, Olga Maciaszek-Sharma
Since
6.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private final Map<String, Object>
private final Object
private final MultiValueMap<String, String>
private static final MultiValueMap<String, String>
private final HttpHeaders
private final HttpMethod
private final URI
private final UriBuilderFactory
private final String
private final Map<String, String>

Constructor Summary

AccessConstructor and Description
protected
HttpRequestValues(HttpMethod httpMethod, URI uri, String uriTemplate, Map<String, String> uriVariables, HttpHeaders headers, MultiValueMap<String, String> cookies, Map<String, Object> attributes, Object bodyValue)

Constructor without UriBuilderFactory.
protected
HttpRequestValues(HttpMethod httpMethod, URI uri, UriBuilderFactory uriBuilderFactory, String uriTemplate, Map<String, String> uriVariables, HttpHeaders headers, MultiValueMap<String, String> cookies, Map<String, Object> attributes, Object bodyValue)

Construct HttpRequestValues.

Method Summary

Modifier and TypeMethod and Description
public static HttpRequestValues.Builder
public Map<String, Object>
getAttributes()

Return the attributes associated with the request, or an empty map.

public Publisher<?>
getBody()

Deprecated for removal since 6.1. in favor of ReactiveHttpRequestValues#getBodyPublisher(); to be removed in 6.2
Return the request body as a Publisher.
public ParameterizedTypeReference<?>
getBodyElementType()

Deprecated for removal since 6.1. in favor of ReactiveHttpRequestValues#getBodyPublisherElementType(); to be removed in 6.2
Return the element type for a Publisher body.
public Object
getBodyValue()

Return the request body as a value to be serialized, if set.

public MultiValueMap<String, String>
getCookies()

Return the cookies for the request, or an empty map.

public HttpHeaders
getHeaders()

Return the headers for the request, if any.

public HttpMethod
getHttpMethod()

Return the HTTP method to use for the request.

public URI
getUri()

Return the URL to use.

public UriBuilderFactory
public String
getUriTemplate()

Return the URL template for the request.

public Map<String, String>
getUriVariables()

Return the URL template variables, or an empty map.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributesback to summary
private final Map<String, Object> attributes
bodyValueback to summary
private final Object bodyValue
Annotations
@Nullable
cookiesback to summary
private final MultiValueMap<String, String> cookies
EMPTY_COOKIES_MAPback to summary
private static final MultiValueMap<String, String> EMPTY_COOKIES_MAP
headersback to summary
private final HttpHeaders headers
httpMethodback to summary
private final HttpMethod httpMethod
Annotations
@Nullable
uriback to summary
private final URI uri
Annotations
@Nullable
uriBuilderFactoryback to summary
private final UriBuilderFactory uriBuilderFactory
Annotations
@Nullable
uriTemplateback to summary
private final String uriTemplate
Annotations
@Nullable
uriVariablesback to summary
private final Map<String, String> uriVariables

Constructor Detail

HttpRequestValuesback to summary
protected HttpRequestValues(HttpMethod httpMethod, URI uri, String uriTemplate, Map<String, String> uriVariables, HttpHeaders headers, MultiValueMap<String, String> cookies, Map<String, Object> attributes, Object bodyValue)

Constructor without UriBuilderFactory.

Annotations
@Deprecated
since:6.1
forRemoval:true
HttpRequestValuesback to summary
protected HttpRequestValues(HttpMethod httpMethod, URI uri, UriBuilderFactory uriBuilderFactory, String uriTemplate, Map<String, String> uriVariables, HttpHeaders headers, MultiValueMap<String, String> cookies, Map<String, Object> attributes, Object bodyValue)

Construct HttpRequestValues.

Since
6.1

Method Detail

builderback to summary
public static HttpRequestValues.Builder builder()
getAttributesback to summary
public Map<String, Object> getAttributes()

Return the attributes associated with the request, or an empty map.

getBodyback to summary
public Publisher<?> getBody()

Deprecated

for removal since 6.1.

in favor of ReactiveHttpRequestValues#getBodyPublisher(); to be removed in 6.2

Return the request body as a Publisher.

This is mutually exclusive with getBodyValue(). Only one of the two or neither is set.

Annotations
@Deprecated
since:6.1
forRemoval:true
@Nullable
getBodyElementTypeback to summary
public ParameterizedTypeReference<?> getBodyElementType()

Deprecated

for removal since 6.1.

in favor of ReactiveHttpRequestValues#getBodyPublisherElementType(); to be removed in 6.2

Return the element type for a Publisher body.

Annotations
@Deprecated
since:6.1
forRemoval:true
@Nullable
getBodyValueback to summary
public Object getBodyValue()

Return the request body as a value to be serialized, if set.

Annotations
@Nullable
getCookiesback to summary
public MultiValueMap<String, String> getCookies()

Return the cookies for the request, or an empty map.

getHeadersback to summary
public HttpHeaders getHeaders()

Return the headers for the request, if any.

getHttpMethodback to summary
public HttpMethod getHttpMethod()

Return the HTTP method to use for the request.

Annotations
@Nullable
getUriback to summary
public URI getUri()

Return the URL to use.

Typically, this comes from a URI method argument, which provides the caller with the option to override the uriTemplate from class and method HttpExchange annotations.

Annotations
@Nullable
getUriBuilderFactoryback to summary
public UriBuilderFactory getUriBuilderFactory()

Return the UriBuilderFactory to expand the HttpRequestValues#uriTemplate and getUriVariables() with.

The UriBuilderFactory is passed into the HTTP interface method in order to override the UriBuilderFactory (and its baseUrl) used by the underlying client.

Annotations
@Nullable
Since
6.1
getUriTemplateback to summary
public String getUriTemplate()

Return the URL template for the request. This comes from the values in class and method HttpExchange annotations.

Annotations
@Nullable
getUriVariablesback to summary
public Map<String, String> getUriVariables()

Return the URL template variables, or an empty map.

org.springframework.web.service.invoker back to summary

public Class HttpRequestValues.Builder

extends Object
Class Inheritance
  • java.lang.Object
  • org.springframework.web.service.invoker.HttpRequestValues.Builder
Known Direct Subclasses
org.springframework.web.service.invoker.ReactiveHttpRequestValues.Builder

Builder for HttpRequestValues.

Field Summary

Modifier and TypeField and Description
private Map<String, Object>
private Object
private MultiValueMap<String, String>
private HttpHeaders
private HttpMethod
private MultiValueMap<String, Object>
private MultiValueMap<String, String>
private URI
private UriBuilderFactory
private String
private Map<String, String>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public HttpRequestValues.Builder
addAttribute(String
the attribute name
name
,
Object
the attribute value
value
)

Configure an attribute to associate with the request.

public HttpRequestValues.Builder
addCookie(String name, String... values)

Add the given cookie name and values.

public HttpRequestValues.Builder
addHeader(String headerName, String... headerValues)

Add the given header name and values.

public HttpRequestValues.Builder
addRequestParameter(String name, String... values)

Add the given request parameter name and values.

public HttpRequestValues.Builder
addRequestPart(String name, Object part)

Add a part for a multipart request.

public <T, P extends Publisher<T>> HttpRequestValues.Builder
addRequestPart(String name, P publisher, ResolvableType type)

Deprecated for removal since 6.1. in favor of ReactiveHttpRequestValues.Builder#addRequestPartPublisher; to be removed in 6.2
Variant of addRequestPart(String, Object) that allows the part value to be produced by a Publisher.
private String
appendQueryParams(String uriTemplate, Map<String, String> uriVars, MultiValueMap<String, String> requestParams)

public HttpRequestValues
build()

Build the HttpRequestValues instance.

protected Object
protected HttpRequestValues
createRequestValues(HttpMethod httpMethod, URI uri, String uriTemplate, Map<String, String> uriVars, HttpHeaders headers, MultiValueMap<String, String> cookies, Map<String, Object> attributes, Object bodyValue)

Create HttpRequestValues from values passed to the Builder.
protected HttpRequestValues
createRequestValues(HttpMethod httpMethod, URI uri, UriBuilderFactory uriBuilderFactory, String uriTemplate, Map<String, String> uriVars, HttpHeaders headers, MultiValueMap<String, String> cookies, Map<String, Object> attributes, Object bodyValue)

Create HttpRequestValues from values passed to the Builder.

protected boolean
private boolean
protected boolean
private HttpHeaders
public HttpRequestValues.Builder
setAccept(List<MediaType> acceptableMediaTypes)

Set the media types for the request Accept header.

public <T, P extends Publisher<T>> void
setBody(P body, ParameterizedTypeReference<T> elementTye)

Deprecated for removal since 6.1. in favor of ReactiveHttpRequestValues.Builder#setBodyPublisher; to be removed in 6.2
Set the request body as a Reactive Streams Publisher.
public void
setBodyValue(Object bodyValue)

Set the request body as an Object to be serialized.

public HttpRequestValues.Builder
setContentType(MediaType contentType)

Set the media type for the request Content-Type header.

public HttpRequestValues.Builder
setHttpMethod(HttpMethod httpMethod)

Set the HTTP method for the request.

public HttpRequestValues.Builder
setUri(URI uri)

Set the URL to use.

public HttpRequestValues.Builder
setUriBuilderFactory(UriBuilderFactory uriBuilderFactory)

Set the UriBuilderFactory that will be used to expand the getUriTemplate().

public HttpRequestValues.Builder
setUriTemplate(String uriTemplate)

Set the request URL as a String template.

public HttpRequestValues.Builder
setUriVariable(String name, String value)

Add a URI variable name-value pair.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributesback to summary
private Map<String, Object> attributes
Annotations
@Nullable
bodyValueback to summary
private Object bodyValue
Annotations
@Nullable
cookiesback to summary
private MultiValueMap<String, String> cookies
Annotations
@Nullable
headersback to summary
private HttpHeaders headers
Annotations
@Nullable
httpMethodback to summary
private HttpMethod httpMethod
Annotations
@Nullable
partsback to summary
private MultiValueMap<String, Object> parts
Annotations
@Nullable
requestParamsback to summary
private MultiValueMap<String, String> requestParams
Annotations
@Nullable
uriback to summary
private URI uri
Annotations
@Nullable
uriBuilderFactoryback to summary
private UriBuilderFactory uriBuilderFactory
Annotations
@Nullable
uriTemplateback to summary
private String uriTemplate
Annotations
@Nullable
uriVarsback to summary
private Map<String, String> uriVars
Annotations
@Nullable

Constructor Detail

Builderback to summary
public Builder()

Method Detail

addAttributeback to summary
public HttpRequestValues.Builder addAttribute(String name, Object value)

Configure an attribute to associate with the request.

Parameters
name:String

the attribute name

value:Object

the attribute value

addCookieback to summary
public HttpRequestValues.Builder addCookie(String name, String... values)

Add the given cookie name and values.

addHeaderback to summary
public HttpRequestValues.Builder addHeader(String headerName, String... headerValues)

Add the given header name and values.

addRequestParameterback to summary
public HttpRequestValues.Builder addRequestParameter(String name, String... values)

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.

addRequestPartback to summary
public HttpRequestValues.Builder addRequestPart(String name, Object part)

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
addRequestPartback to summary
public <T, P extends Publisher<T>> HttpRequestValues.Builder addRequestPart(String name, P publisher, ResolvableType type)

Deprecated

for removal since 6.1.

in favor of ReactiveHttpRequestValues.Builder#addRequestPartPublisher; to be removed in 6.2

Variant of addRequestPart(String, Object) that allows the part value to be produced by a Publisher.

Annotations
@Deprecated
since:6.1
forRemoval:true
appendQueryParamsback to summary
private String appendQueryParams(String uriTemplate, Map<String, String> uriVars, MultiValueMap<String, String> requestParams)
buildback to summary
public HttpRequestValues build()

Build the HttpRequestValues instance.

buildMultipartBodyback to summary
protected Object buildMultipartBody()
createRequestValuesback to summary
protected HttpRequestValues createRequestValues(HttpMethod httpMethod, URI uri, String uriTemplate, Map<String, String> uriVars, HttpHeaders headers, MultiValueMap<String, String> cookies, Map<String, Object> attributes, Object bodyValue)

Create HttpRequestValues from values passed to the Builder.

Annotations
@Deprecated
since:6.1
forRemoval:true
createRequestValuesback to summary
protected HttpRequestValues createRequestValues(HttpMethod httpMethod, URI uri, UriBuilderFactory uriBuilderFactory, String uriTemplate, Map<String, String> uriVars, HttpHeaders headers, MultiValueMap<String, String> cookies, Map<String, Object> attributes, Object bodyValue)

Create HttpRequestValues from values passed to the Builder.

Since
6.1
hasBodyback to summary
protected boolean hasBody()
hasFormDataContentTypeback to summary
private boolean hasFormDataContentType()
hasPartsback to summary
protected boolean hasParts()
initHeadersback to summary
private HttpHeaders initHeaders()
setAcceptback to summary
public HttpRequestValues.Builder setAccept(List<MediaType> acceptableMediaTypes)

Set the media types for the request Accept header.

setBodyback to summary
public <T, P extends Publisher<T>> void setBody(P body, ParameterizedTypeReference<T> elementTye)

Deprecated

for removal since 6.1.

in favor of ReactiveHttpRequestValues.Builder#setBodyPublisher; to be removed in 6.2

Set the request body as a Reactive Streams Publisher.

This is mutually exclusive with, and resets any previously set body value.

Annotations
@Deprecated
since:6.1
forRemoval:true
setBodyValueback to summary
public void setBodyValue(Object bodyValue)

Set the request body as an Object to be serialized.

setContentTypeback to summary
public HttpRequestValues.Builder setContentType(MediaType contentType)

Set the media type for the request Content-Type header.

setHttpMethodback to summary
public HttpRequestValues.Builder setHttpMethod(HttpMethod httpMethod)

Set the HTTP method for the request.

setUriback to summary
public HttpRequestValues.Builder setUri(URI uri)

Set the URL to use. When set, this overrides the URI template from the HttpExchange annotation.

setUriBuilderFactoryback to summary
public HttpRequestValues.Builder setUriBuilderFactory(UriBuilderFactory uriBuilderFactory)

Set the UriBuilderFactory that will be used to expand the getUriTemplate().

Since
6.1
setUriTemplateback to summary
public HttpRequestValues.Builder setUriTemplate(String uriTemplate)

Set the request URL as a String template.

setUriVariableback to summary
public HttpRequestValues.Builder setUriVariable(String name, String value)

Add a URI variable name-value pair.