ServerHttpResponse.java 2.1 KB
Newer Older
1
/*
2
 * Copyright 2002-2018 the original author or authors.
3 4 5 6 7 8 9 10 11 12 13 14 15 16
 *
 * 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
 *
 *      http://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.
 */

17
package org.springframework.http.server.reactive;
18

A
Arjen Poutsma 已提交
19
import org.springframework.http.HttpStatus;
A
Arjen Poutsma 已提交
20
import org.springframework.http.ReactiveHttpOutputMessage;
21
import org.springframework.http.ResponseCookie;
22
import org.springframework.lang.Nullable;
R
Rossen Stoyanchev 已提交
23
import org.springframework.util.MultiValueMap;
24 25

/**
26
 * Represents a reactive server-side HTTP response.
27
 *
A
Arjen Poutsma 已提交
28
 * @author Arjen Poutsma
29
 * @author Sebastien Deleuze
30
 * @since 5.0
31
 */
32
public interface ServerHttpResponse extends ReactiveHttpOutputMessage {
33

A
Arjen Poutsma 已提交
34 35
	/**
	 * Set the HTTP status code of the response.
S
Sebastien Deleuze 已提交
36
	 * @param status the HTTP status as an {@link HttpStatus} enum value
37 38
	 * @return {@code false} if the status code has not been set because the
	 * HTTP response is already committed, {@code true} if successfully set.
A
Arjen Poutsma 已提交
39
	 */
40
	boolean setStatusCode(@Nullable HttpStatus status);
41

R
Rossen Stoyanchev 已提交
42
	/**
43 44 45 46 47
	 * Return the status code set via {@link #setStatusCode}, or if the status
	 * has not been set, return the default status code from the underlying
	 * server response. The return value may be {@code null} if the status code
	 * value is outside the {@link HttpStatus} enum range, or if the underlying
	 * server response does not have a default value.
R
Rossen Stoyanchev 已提交
48
	 */
49
	@Nullable
50 51
	HttpStatus getStatusCode();

J
Juergen Hoeller 已提交
52 53 54
	/**
	 * Return a mutable map with the cookies to send to the server.
	 */
55
	MultiValueMap<String, ResponseCookie> getCookies();
R
Rossen Stoyanchev 已提交
56

57 58 59 60 61 62 63
	/**
	 * Add the given {@code ResponseCookie}.
	 * @param cookie the cookie to add
	 * @throws IllegalStateException if the response has already been committed
	 */
	void addCookie(ResponseCookie cookie);

64
}