class DefaultServerRequestBuilder extends java.lang.Object implements ServerRequest.Builder
ServerRequest.Builder
implementation.Modifier and Type | Class and Description |
---|---|
private static class |
DefaultServerRequestBuilder.BodyInputStream |
private static class |
DefaultServerRequestBuilder.BuiltServerRequest |
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,java.lang.Object> |
attributes |
private byte[] |
body |
private MultiValueMap<java.lang.String,Cookie> |
cookies |
private HttpHeaders |
headers |
private java.util.List<HttpMessageConverter<?>> |
messageConverters |
private java.lang.String |
methodName |
private HttpServletRequest |
servletRequest |
private java.net.URI |
uri |
Constructor and Description |
---|
DefaultServerRequestBuilder(ServerRequest other) |
Modifier and Type | Method and Description |
---|---|
ServerRequest.Builder |
attribute(java.lang.String name,
java.lang.Object value)
Add an attribute with the given name and value.
|
ServerRequest.Builder |
attributes(java.util.function.Consumer<java.util.Map<java.lang.String,java.lang.Object>> attributesConsumer)
Manipulate this request's attributes with the given consumer.
|
ServerRequest.Builder |
body(byte[] body)
Set the body of the request.
|
ServerRequest.Builder |
body(java.lang.String body)
Set the body of the request to the UTF-8 encoded bytes of the given string.
|
ServerRequest |
build()
Build the request.
|
ServerRequest.Builder |
cookie(java.lang.String name,
java.lang.String... values)
Add a cookie with the given name and value(s).
|
ServerRequest.Builder |
cookies(java.util.function.Consumer<MultiValueMap<java.lang.String,Cookie>> cookiesConsumer)
Manipulate this request's cookies with the given consumer.
|
ServerRequest.Builder |
header(java.lang.String headerName,
java.lang.String... headerValues)
Add the given header value(s) under the given name.
|
ServerRequest.Builder |
headers(java.util.function.Consumer<HttpHeaders> headersConsumer)
Manipulate this request's headers with the given consumer.
|
ServerRequest.Builder |
method(HttpMethod method)
Set the method of the request.
|
ServerRequest.Builder |
uri(java.net.URI uri)
Set the URI of the request.
|
private final java.util.List<HttpMessageConverter<?>> messageConverters
private HttpServletRequest servletRequest
private java.lang.String methodName
private java.net.URI uri
private final HttpHeaders headers
private final MultiValueMap<java.lang.String,Cookie> cookies
private final java.util.Map<java.lang.String,java.lang.Object> attributes
private byte[] body
public DefaultServerRequestBuilder(ServerRequest other)
public ServerRequest.Builder method(HttpMethod method)
ServerRequest.Builder
method
in interface ServerRequest.Builder
method
- the new methodpublic ServerRequest.Builder uri(java.net.URI uri)
ServerRequest.Builder
uri
in interface ServerRequest.Builder
uri
- the new URIpublic ServerRequest.Builder header(java.lang.String headerName, java.lang.String... headerValues)
ServerRequest.Builder
header
in interface ServerRequest.Builder
headerName
- the header nameheaderValues
- the header value(s)HttpHeaders.add(String, String)
public ServerRequest.Builder headers(java.util.function.Consumer<HttpHeaders> headersConsumer)
ServerRequest.Builder
The headers provided to the consumer are "live", so that the consumer can be used to
overwrite existing header values,
remove values, or use any of the other
HttpHeaders
methods.
headers
in interface ServerRequest.Builder
headersConsumer
- a function that consumes the HttpHeaders
public ServerRequest.Builder cookie(java.lang.String name, java.lang.String... values)
ServerRequest.Builder
cookie
in interface ServerRequest.Builder
name
- the cookie namevalues
- the cookie value(s)public ServerRequest.Builder cookies(java.util.function.Consumer<MultiValueMap<java.lang.String,Cookie>> cookiesConsumer)
ServerRequest.Builder
The map provided to the consumer is "live", so that the consumer can be used to
overwrite existing cookies,
remove cookies, or use any of the other
MultiValueMap
methods.
cookies
in interface ServerRequest.Builder
cookiesConsumer
- a function that consumes the cookies mappublic ServerRequest.Builder body(byte[] body)
ServerRequest.Builder
Calling this methods will release the existing body of the builder.
body
in interface ServerRequest.Builder
body
- the new bodypublic ServerRequest.Builder body(java.lang.String body)
ServerRequest.Builder
Calling this methods will release the existing body of the builder.
body
in interface ServerRequest.Builder
body
- the new bodypublic ServerRequest.Builder attribute(java.lang.String name, java.lang.Object value)
ServerRequest.Builder
attribute
in interface ServerRequest.Builder
name
- the attribute namevalue
- the attribute valuepublic ServerRequest.Builder attributes(java.util.function.Consumer<java.util.Map<java.lang.String,java.lang.Object>> attributesConsumer)
ServerRequest.Builder
The map provided to the consumer is "live", so that the consumer can be used
to overwrite existing attributes,
remove attributes, or use any of the other
Map
methods.
attributes
in interface ServerRequest.Builder
attributesConsumer
- a function that consumes the attributes mappublic ServerRequest build()
ServerRequest.Builder
build
in interface ServerRequest.Builder