org.springframework.mock.http.server.reactive

Class MockServerHttpRequest

    • Method Detail

      • getMethodValue

        public java.lang.String getMethodValue()
        Description copied from interface: HttpRequest
        Return the HTTP method of the request as a String value.
        Returns:
        the HTTP method as a plain String
        See Also:
        HttpRequest.getMethod()
      • getRemoteAddress

        @Nullable
        public java.net.InetSocketAddress getRemoteAddress()
        Description copied from interface: ServerHttpRequest
        Return the remote address where this request is connected to, if available.
      • getBody

        public reactor.core.publisher.Flux<DataBuffer> getBody()
        Description copied from interface: ReactiveHttpInputMessage
        Return the body of the message as a Publisher.
        Returns:
        the body content publisher
      • getNativeRequest

        public <T> T getNativeRequest()
        Description copied from class: AbstractServerHttpRequest
        Return the underlying server response.

        Note: This is exposed mainly for internal framework use such as WebSocket upgrades in the spring-webflux module.

        Specified by:
        getNativeRequest in class AbstractServerHttpRequest
      • method

        public static MockServerHttpRequest.BodyBuilder method(HttpMethod method,
                                                               java.net.URI url)
        Create a builder with the given HTTP method and a URI.
        Parameters:
        method - the HTTP method (GET, POST, etc)
        url - the URL
        Returns:
        the created builder
      • method

        public static MockServerHttpRequest.BodyBuilder method(HttpMethod method,
                                                               java.lang.String urlTemplate,
                                                               java.lang.Object... vars)
        Alternative to 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.
        Parameters:
        method - the HTTP method (GET, POST, etc)
        urlTemplate - the URL template
        vars - variables to expand into the template
        Returns:
        the created builder
      • get

        public static MockServerHttpRequest.BaseBuilder<?> get(java.lang.String urlTemplate,
                                                               java.lang.Object... uriVars)
        Create an HTTP GET builder with the given URI template. The given URI may contain query parameters, or those may be added later via queryParam builder methods.
        Parameters:
        urlTemplate - a URL template; the resulting URL will be encoded
        uriVars - zero or more URI variables
        Returns:
        the created builder
      • head

        public static MockServerHttpRequest.BaseBuilder<?> head(java.lang.String urlTemplate,
                                                                java.lang.Object... uriVars)
        HTTP HEAD variant. See get(String, Object...) for general info.
        Parameters:
        urlTemplate - a URL template; the resulting URL will be encoded
        uriVars - zero or more URI variables
        Returns:
        the created builder
      • post

        public static MockServerHttpRequest.BodyBuilder post(java.lang.String urlTemplate,
                                                             java.lang.Object... uriVars)
        HTTP POST variant. See get(String, Object...) for general info.
        Parameters:
        urlTemplate - a URL template; the resulting URL will be encoded
        uriVars - zero or more URI variables
        Returns:
        the created builder
      • put

        public static MockServerHttpRequest.BodyBuilder put(java.lang.String urlTemplate,
                                                            java.lang.Object... uriVars)
        HTTP PUT variant. See get(String, Object...) for general info. queryParam builder methods.
        Parameters:
        urlTemplate - a URL template; the resulting URL will be encoded
        uriVars - zero or more URI variables
        Returns:
        the created builder
      • patch

        public static MockServerHttpRequest.BodyBuilder patch(java.lang.String urlTemplate,
                                                              java.lang.Object... uriVars)
        HTTP PATCH variant. See get(String, Object...) for general info.
        Parameters:
        urlTemplate - a URL template; the resulting URL will be encoded
        uriVars - zero or more URI variables
        Returns:
        the created builder
      • delete

        public static MockServerHttpRequest.BaseBuilder<?> delete(java.lang.String urlTemplate,
                                                                  java.lang.Object... uriVars)
        HTTP DELETE variant. See get(String, Object...) for general info.
        Parameters:
        urlTemplate - a URL template; the resulting URL will be encoded
        uriVars - zero or more URI variables
        Returns:
        the created builder
      • options

        public static MockServerHttpRequest.BaseBuilder<?> options(java.lang.String urlTemplate,
                                                                   java.lang.Object... uriVars)
        HTTP OPTIONS variant. See get(String, Object...) for general info.
        Parameters:
        urlTemplate - a URL template; the resulting URL will be encoded
        uriVars - zero or more URI variables
        Returns:
        the created builder