public final class MockServerHttpRequest extends AbstractServerHttpRequest
AbstractServerHttpRequest for use in tests without
an actual server. Use the static methods to obtain a builder.| Modifier and Type | Class and Description |
|---|---|
static interface |
MockServerHttpRequest.BaseBuilder<B extends MockServerHttpRequest.BaseBuilder<B>>
Request builder exposing properties not related to the body.
|
static interface |
MockServerHttpRequest.BodyBuilder
A builder that adds a body to the request.
|
ServerHttpRequest.Builder| Modifier and Type | Method and Description |
|---|---|
static MockServerHttpRequest.BaseBuilder<?> |
delete(String urlTemplate,
Object... uriVars)
HTTP DELETE variant.
|
static MockServerHttpRequest.BaseBuilder<?> |
get(String urlTemplate,
Object... uriVars)
Create an HTTP GET builder with the given URI template.
|
reactor.core.publisher.Flux<DataBuffer> |
getBody()
Return the body of the message as a
Publisher. |
InetSocketAddress |
getLocalAddress()
Return the local address the request was accepted on, if available.
|
HttpMethod |
getMethod()
Return the HTTP method of the request.
|
String |
getMethodValue()
Return the HTTP method of the request as a String value.
|
<T> T |
getNativeRequest()
Return the underlying server response.
|
InetSocketAddress |
getRemoteAddress()
Return the remote address where this request is connected to, if available.
|
static MockServerHttpRequest.BaseBuilder<?> |
head(String urlTemplate,
Object... uriVars)
HTTP HEAD variant.
|
protected MultiValueMap<String,HttpCookie> |
initCookies()
Obtain the cookies from the underlying "native" request and adapt those to
an
HttpCookie map. |
protected SslInfo |
initSslInfo()
Obtain SSL session information from the underlying "native" request.
|
static MockServerHttpRequest.BodyBuilder |
method(HttpMethod method,
String uri,
Object... vars)
Alternative to
method(HttpMethod, URI) that accepts a URI template. |
static MockServerHttpRequest.BodyBuilder |
method(HttpMethod method,
URI url)
Create a builder with the given HTTP method and a
URI. |
static MockServerHttpRequest.BodyBuilder |
method(String httpMethod,
String uri,
Object... vars)
Create a builder with a raw HTTP method value value that is outside the
range of
HttpMethod enum values. |
static MockServerHttpRequest.BaseBuilder<?> |
options(String urlTemplate,
Object... uriVars)
HTTP OPTIONS variant.
|
static MockServerHttpRequest.BodyBuilder |
patch(String urlTemplate,
Object... uriVars)
HTTP PATCH variant.
|
static MockServerHttpRequest.BodyBuilder |
post(String urlTemplate,
Object... uriVars)
HTTP POST variant.
|
static MockServerHttpRequest.BodyBuilder |
put(String urlTemplate,
Object... uriVars)
HTTP PUT variant.
|
getCookies, getHeaders, getId, getPath, getQueryParams, getSslInfo, getURI, initId, initQueryParamsclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitmutate@Nullable public HttpMethod getMethod()
HttpRequestnull
if not resolvable (e.g. in case of a non-standard HTTP method)HttpRequest.getMethodValue(),
HttpMethod.resolve(String)public String getMethodValue()
HttpRequestHttpRequest.getMethod()@Nullable public InetSocketAddress getLocalAddress()
ServerHttpRequest@Nullable public InetSocketAddress getRemoteAddress()
ServerHttpRequest@Nullable protected SslInfo initSslInfo()
AbstractServerHttpRequestinitSslInfo in class AbstractServerHttpRequestnull if none availablepublic reactor.core.publisher.Flux<DataBuffer> getBody()
ReactiveHttpInputMessagePublisher.protected MultiValueMap<String,HttpCookie> initCookies()
AbstractServerHttpRequestHttpCookie map. The return value is turned into an immutable
map and cached.
Note that this method is invoked lazily on access to
AbstractServerHttpRequest.getCookies(). Sub-classes should synchronize cookie
initialization if the underlying "native" request does not provide
thread-safe access to cookie data.
initCookies in class AbstractServerHttpRequestpublic <T> T getNativeRequest()
AbstractServerHttpRequestNote: This is exposed mainly for internal framework use such as WebSocket upgrades in the spring-webflux module.
getNativeRequest in class AbstractServerHttpRequestpublic static MockServerHttpRequest.BaseBuilder<?> get(String urlTemplate, Object... uriVars)
queryParam builder methods.urlTemplate - a URL template; the resulting URL will be encodeduriVars - zero or more URI variablespublic static MockServerHttpRequest.BaseBuilder<?> head(String urlTemplate, Object... uriVars)
get(String, Object...) for general info.urlTemplate - a URL template; the resulting URL will be encodeduriVars - zero or more URI variablespublic static MockServerHttpRequest.BodyBuilder post(String urlTemplate, Object... uriVars)
get(String, Object...) for general info.urlTemplate - a URL template; the resulting URL will be encodeduriVars - zero or more URI variablespublic static MockServerHttpRequest.BodyBuilder put(String urlTemplate, Object... uriVars)
get(String, Object...) for general info.
queryParam builder methods.urlTemplate - a URL template; the resulting URL will be encodeduriVars - zero or more URI variablespublic static MockServerHttpRequest.BodyBuilder patch(String urlTemplate, Object... uriVars)
get(String, Object...) for general info.urlTemplate - a URL template; the resulting URL will be encodeduriVars - zero or more URI variablespublic static MockServerHttpRequest.BaseBuilder<?> delete(String urlTemplate, Object... uriVars)
get(String, Object...) for general info.urlTemplate - a URL template; the resulting URL will be encodeduriVars - zero or more URI variablespublic static MockServerHttpRequest.BaseBuilder<?> options(String urlTemplate, Object... uriVars)
get(String, Object...) for general info.urlTemplate - a URL template; the resulting URL will be encodeduriVars - zero or more URI variablespublic static MockServerHttpRequest.BodyBuilder method(HttpMethod method, URI url)
URI.method - the HTTP method (GET, POST, etc)url - the URLpublic static MockServerHttpRequest.BodyBuilder method(HttpMethod method, String uri, Object... vars)
method(HttpMethod, URI) that accepts a URI template.
The given URI may contain query parameters, or those may be added later via
queryParam builder methods.method - the HTTP method (GET, POST, etc)uri - the URI template for the target URLvars - variables to expand into the templatepublic static MockServerHttpRequest.BodyBuilder method(String httpMethod, String uri, Object... vars)
HttpMethod enum values.httpMethod - the HTTP methodValue valueuri - the URI template for target the URLvars - variables to expand into the template