Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.reactive.function.server;
import java.net.InetSocketAddress;
import java.net.URI;
import java.nio.charset.Charset;
import java.security.Principal;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.OptionalLong;
import java.util.function.Consumer;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.HttpCookie;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpRange;
import org.springframework.http.MediaType;
import org.springframework.http.codec.HttpMessageReader;
import org.springframework.http.codec.json.Jackson2CodecSupport;
import org.springframework.http.codec.multipart.Part;
import org.springframework.http.server.PathContainer;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.lang.Nullable;
import org.springframework.util.CollectionUtils;
import org.springframework.util.MultiValueMap;
import org.springframework.web.reactive.function.BodyExtractor;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebSession;
import org.springframework.web.util.UriBuilder;
/**
* Represents a server-side HTTP request, as handled by a {@code HandlerFunction}.
*
*
Access to headers and body is offered by {@link Headers} and
* {@link #body(BodyExtractor)}, respectively.
*
* @author Arjen Poutsma
* @author Sebastien Deleuze
* @since 5.0
*/
public interface ServerRequest {
/**
* Get the HTTP method.
* @return the HTTP method as an HttpMethod enum value, or {@code null}
* if not resolvable (e.g. in case of a non-standard HTTP method)
*/
@Nullable
default HttpMethod method() {
return HttpMethod.resolve(methodName());
}
/**
* Get the name of the HTTP method.
* @return the HTTP method as a String
*/
String methodName();
/**
* Get the request URI.
*/
URI uri();
/**
* Get a {@code UriBuilderComponents} from the URI associated with this
* {@code ServerRequest}.
*
Note: as of 5.1 this method ignores {@code "Forwarded"}
* and {@code "X-Forwarded-*"} headers that specify the
* client-originated address. Consider using the {@code ForwardedHeaderFilter}
* to extract and use, or to discard such headers.
* @return a URI builder
*/
UriBuilder uriBuilder();
/**
* Get the request path.
*/
default String path() {
return uri().getRawPath();
}
/**
* Get the request path as a {@code PathContainer}.
*/
default PathContainer pathContainer() {
return PathContainer.parsePath(path());
}
/**
* Get the headers of this request.
*/
Headers headers();
/**
* Get the cookies of this request.
*/
MultiValueMap cookies();
/**
* Get the remote address to which this request is connected, if available.
* @since 5.1
*/
Optional remoteAddress();
/**
* Get the readers used to convert the body of this request.
* @since 5.1
*/
List> messageReaders();
/**
* Extract the body with the given {@code BodyExtractor}.
* @param extractor the {@code BodyExtractor} that reads from the request
* @param the type of the body returned
* @return the extracted body
* @see #body(BodyExtractor, Map)
*/
T body(BodyExtractor extractor);
/**
* Extract the body with the given {@code BodyExtractor} and hints.
* @param extractor the {@code BodyExtractor} that reads from the request
* @param hints the map of hints like {@link Jackson2CodecSupport#JSON_VIEW_HINT}
* to use to customize body extraction
* @param the type of the body returned
* @return the extracted body
*/
T body(BodyExtractor extractor, Map hints);
/**
* Extract the body to a {@code Mono}.
* @param elementClass the class of element in the {@code Mono}
* @param the element type
* @return the body as a mono
*/
Mono bodyToMono(Class elementClass);
/**
* Extract the body to a {@code Mono}.
* @param typeReference a type reference describing the expected response request type
* @param the element type
* @return a mono containing the body of the given type {@code T}
*/
Mono bodyToMono(ParameterizedTypeReference typeReference);
/**
* Extract the body to a {@code Flux}.
* @param elementClass the class of element in the {@code Flux}
* @param the element type
* @return the body as a flux
*/
Flux bodyToFlux(Class elementClass);
/**
* Extract the body to a {@code Flux}.
* @param typeReference a type reference describing the expected request body type
* @param the element type
* @return a flux containing the body of the given type {@code T}
*/
Flux bodyToFlux(ParameterizedTypeReference typeReference);
/**
* Get the request attribute value if present.
* @param name the attribute name
* @return the attribute value
*/
default Optional