001/*
002 * Copyright 2002-2019 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.http.server;
018
019import java.net.InetSocketAddress;
020import java.security.Principal;
021
022import org.springframework.http.HttpInputMessage;
023import org.springframework.http.HttpRequest;
024
025/**
026 * Represents a server-side HTTP request.
027 *
028 * @author Arjen Poutsma
029 * @author Rossen Stoyanchev
030 * @since 3.0
031 */
032public interface ServerHttpRequest extends HttpRequest, HttpInputMessage {
033
034        /**
035         * Return a {@link java.security.Principal} instance containing the name of the
036         * authenticated user.
037         * <p>If the user has not been authenticated, the method returns <code>null</code>.
038         */
039        Principal getPrincipal();
040
041        /**
042         * Return the address on which the request was received.
043         */
044        InetSocketAddress getLocalAddress();
045
046        /**
047         * Return the address of the remote client.
048         */
049        InetSocketAddress getRemoteAddress();
050
051        /**
052         * Return a control that allows putting the request in asynchronous mode so the
053         * response remains open until closed explicitly from the current or another thread.
054         */
055        ServerHttpAsyncRequestControl getAsyncRequestControl(ServerHttpResponse response);
056
057}