类 AbstractServerHttpResponse
- java.lang.Object
- org.springframework.http.server.reactive.AbstractServerHttpResponse
public abstract class AbstractServerHttpResponse extends Object implements ServerHttpResponse
Base class forServerHttpResponse
implementations.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev, Juergen Hoeller, Sebastien Deleuze, Brian Clozel
构造器概要
构造器 构造器 说明 AbstractServerHttpResponse(DataBufferFactory dataBufferFactory)
AbstractServerHttpResponse(DataBufferFactory dataBufferFactory, HttpHeaders headers)
方法概要
所有方法 实例方法 抽象方法 具体方法 已过时的方法 修饰符和类型 方法 说明 void
addCookie(ResponseCookie cookie)
Add the givenResponseCookie
.protected abstract void
applyCookies()
Add cookies fromgetHeaders()
to the underlying response.protected abstract void
applyHeaders()
Invoked when the response is getting committed allowing sub-classes to make apply header values to the underlying response.protected abstract void
applyStatusCode()
Write the status code to the underlying response.void
beforeCommit(Supplier<? extends reactor.core.publisher.Mono<Void>> action)
Register an action to apply just before the HttpOutputMessage is committed.DataBufferFactory
bufferFactory()
Return aDataBufferFactory
that can be used to create the body.protected reactor.core.publisher.Mono<Void>
doCommit()
A variant ofdoCommit(Supplier)
for a response without no body.protected reactor.core.publisher.Mono<Void>
doCommit(Supplier<? extends reactor.core.publisher.Mono<Void>> writeAction)
ApplybeforeCommit
actions, apply the response status and headers/cookies, and write the response body.MultiValueMap<String,ResponseCookie>
getCookies()
Return a mutable map with the cookies to send to the server.HttpHeaders
getHeaders()
Return the headers of this message.abstract <T> T
getNativeResponse()
Return the underlying server response.Integer
getRawStatusCode()
Return the status code that has been set, or otherwise fall back on the status of the response from the underlying server.HttpStatus
getStatusCode()
Return the status code that has been set, or otherwise fall back on the status of the response from the underlying server.Integer
getStatusCodeValue()
已过时。as of 5.2.4 in favor ofServerHttpResponse.getRawStatusCode()
.boolean
isCommitted()
Whether the HttpOutputMessage is committed.reactor.core.publisher.Mono<Void>
setComplete()
Indicate that message handling is complete, allowing for any cleanup or end-of-processing tasks to be performed such as applying header changes made viaHttpMessage.getHeaders()
to the underlying HTTP message (if not applied already).boolean
setRawStatusCode(Integer statusCode)
Set the HTTP status code to the given value (potentially non-standard and not resolvable through theHttpStatus
enum) as an integer.boolean
setStatusCode(HttpStatus status)
Set the HTTP status code of the response.void
setStatusCodeValue(Integer statusCode)
已过时。as of 5.2.4 in favor ofServerHttpResponse.setRawStatusCode(Integer)
.reactor.core.publisher.Mono<Void>
writeAndFlushWith(org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends DataBuffer>> body)
Use the givenPublisher
ofPublishers
to write the body of the HttpOutputMessage to the underlying HTTP layer, flushing after eachPublisher<DataBuffer>
.protected abstract reactor.core.publisher.Mono<Void>
writeAndFlushWithInternal(org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends DataBuffer>> body)
Write to the underlying the response, and flush after eachPublisher<DataBuffer>
.reactor.core.publisher.Mono<Void>
writeWith(org.reactivestreams.Publisher<? extends DataBuffer> body)
Use the givenPublisher
to write the body of the message to the underlying HTTP layer.protected abstract reactor.core.publisher.Mono<Void>
writeWithInternal(org.reactivestreams.Publisher<? extends DataBuffer> body)
Write to the underlying the response.
构造器详细资料
AbstractServerHttpResponse
public AbstractServerHttpResponse(DataBufferFactory dataBufferFactory)
AbstractServerHttpResponse
public AbstractServerHttpResponse(DataBufferFactory dataBufferFactory, HttpHeaders headers)
方法详细资料
bufferFactory
public final DataBufferFactory bufferFactory()
从接口复制的说明:ReactiveHttpOutputMessage
Return aDataBufferFactory
that can be used to create the body.- 指定者:
bufferFactory
在接口中ReactiveHttpOutputMessage
- 返回:
- a buffer factory
- 另请参阅:
ReactiveHttpOutputMessage.writeWith(Publisher)
setStatusCode
public boolean setStatusCode(@Nullable HttpStatus status)
从接口复制的说明:ServerHttpResponse
Set the HTTP status code of the response.- 指定者:
setStatusCode
在接口中ServerHttpResponse
- 参数:
status
- the HTTP status as anHttpStatus
enum value- 返回:
false
if the status code change wasn't processed because the HTTP response is committed,true
if successfully set.
getStatusCode
@Nullable public HttpStatus getStatusCode()
从接口复制的说明:ServerHttpResponse
Return the status code that has been set, or otherwise fall back on the status of the response from the underlying server. The return value may benull
if the status code value is outside theHttpStatus
enum range, or if there is no default value from the underlying server.- 指定者:
getStatusCode
在接口中ServerHttpResponse
setRawStatusCode
public boolean setRawStatusCode(@Nullable Integer statusCode)
从接口复制的说明:ServerHttpResponse
Set the HTTP status code to the given value (potentially non-standard and not resolvable through theHttpStatus
enum) as an integer.- 指定者:
setRawStatusCode
在接口中ServerHttpResponse
- 参数:
statusCode
- the status code value- 返回:
false
if the status code change wasn't processed because the HTTP response is committed,true
if successfully set.
getRawStatusCode
@Nullable public Integer getRawStatusCode()
从接口复制的说明:ServerHttpResponse
Return the status code that has been set, or otherwise fall back on the status of the response from the underlying server. The return value may benull
if there is no default value from the underlying server.- 指定者:
getRawStatusCode
在接口中ServerHttpResponse
setStatusCodeValue
@Deprecated public void setStatusCodeValue(@Nullable Integer statusCode)
已过时。as of 5.2.4 in favor ofServerHttpResponse.setRawStatusCode(Integer)
.Set the HTTP status code of the response.- 参数:
statusCode
- the HTTP status as an integer value- 从以下版本开始:
- 5.0.1
getStatusCodeValue
@Nullable @Deprecated public Integer getStatusCodeValue()
已过时。as of 5.2.4 in favor ofServerHttpResponse.getRawStatusCode()
.Return the HTTP status code of the response.- 返回:
- the HTTP status as an integer value
- 从以下版本开始:
- 5.0.1
getHeaders
public HttpHeaders getHeaders()
从接口复制的说明:HttpMessage
Return the headers of this message.- 指定者:
getHeaders
在接口中HttpMessage
- 返回:
- a corresponding HttpHeaders object (never
null
)
getCookies
public MultiValueMap<String,ResponseCookie> getCookies()
从接口复制的说明:ServerHttpResponse
Return a mutable map with the cookies to send to the server.- 指定者:
getCookies
在接口中ServerHttpResponse
addCookie
public void addCookie(ResponseCookie cookie)
从接口复制的说明:ServerHttpResponse
Add the givenResponseCookie
.- 指定者:
addCookie
在接口中ServerHttpResponse
- 参数:
cookie
- the cookie to add
getNativeResponse
public abstract <T> T getNativeResponse()
Return the underlying server response.Note: This is exposed mainly for internal framework use such as WebSocket upgrades in the spring-webflux module.
beforeCommit
public void beforeCommit(Supplier<? extends reactor.core.publisher.Mono<Void>> action)
从接口复制的说明:ReactiveHttpOutputMessage
Register an action to apply just before the HttpOutputMessage is committed.Note: the supplied action must be properly deferred, e.g. via
Mono.defer(java.util.function.Supplier<? extends reactor.core.publisher.Mono<? extends T>>)
orMono.fromRunnable(java.lang.Runnable)
, to ensure it's executed in the right order, relative to other actions.- 指定者:
beforeCommit
在接口中ReactiveHttpOutputMessage
- 参数:
action
- the action to apply
isCommitted
public boolean isCommitted()
从接口复制的说明:ReactiveHttpOutputMessage
Whether the HttpOutputMessage is committed.- 指定者:
isCommitted
在接口中ReactiveHttpOutputMessage
writeWith
public final reactor.core.publisher.Mono<Void> writeWith(org.reactivestreams.Publisher<? extends DataBuffer> body)
从接口复制的说明:ReactiveHttpOutputMessage
Use the givenPublisher
to write the body of the message to the underlying HTTP layer.- 指定者:
writeWith
在接口中ReactiveHttpOutputMessage
- 参数:
body
- the body content publisher- 返回:
- a
Mono
that indicates completion or error
writeAndFlushWith
public final reactor.core.publisher.Mono<Void> writeAndFlushWith(org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends DataBuffer>> body)
从接口复制的说明:ReactiveHttpOutputMessage
Use the givenPublisher
ofPublishers
to write the body of the HttpOutputMessage to the underlying HTTP layer, flushing after eachPublisher<DataBuffer>
.- 指定者:
writeAndFlushWith
在接口中ReactiveHttpOutputMessage
- 参数:
body
- the body content publisher- 返回:
- a
Mono
that indicates completion or error
setComplete
public reactor.core.publisher.Mono<Void> setComplete()
从接口复制的说明:ReactiveHttpOutputMessage
Indicate that message handling is complete, allowing for any cleanup or end-of-processing tasks to be performed such as applying header changes made viaHttpMessage.getHeaders()
to the underlying HTTP message (if not applied already).This method should be automatically invoked at the end of message processing so typically applications should not have to invoke it. If invoked multiple times it should have no side effects.
- 指定者:
setComplete
在接口中ReactiveHttpOutputMessage
- 返回:
- a
Mono
that indicates completion or error
doCommit
protected reactor.core.publisher.Mono<Void> doCommit()
A variant ofdoCommit(Supplier)
for a response without no body.- 返回:
- a completion publisher
doCommit
protected reactor.core.publisher.Mono<Void> doCommit(@Nullable Supplier<? extends reactor.core.publisher.Mono<Void>> writeAction)
ApplybeforeCommit
actions, apply the response status and headers/cookies, and write the response body.- 参数:
writeAction
- the action to write the response body (may benull
)- 返回:
- a completion publisher
writeWithInternal
protected abstract reactor.core.publisher.Mono<Void> writeWithInternal(org.reactivestreams.Publisher<? extends DataBuffer> body)
Write to the underlying the response.- 参数:
body
- the publisher to write with
writeAndFlushWithInternal
protected abstract reactor.core.publisher.Mono<Void> writeAndFlushWithInternal(org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends DataBuffer>> body)
Write to the underlying the response, and flush after eachPublisher<DataBuffer>
.- 参数:
body
- the publisher to write and flush with
applyStatusCode
protected abstract void applyStatusCode()
Write the status code to the underlying response. This method is called once only.
applyHeaders
protected abstract void applyHeaders()
Invoked when the response is getting committed allowing sub-classes to make apply header values to the underlying response.Note that most sub-classes use an
HttpHeaders
instance that wraps an adapter to the native response headers such that changes are propagated to the underlying response on the go. That means this callback is typically not used other than for specialized updates such as setting the contentType or characterEncoding fields in a Servlet response.
applyCookies
protected abstract void applyCookies()
Add cookies fromgetHeaders()
to the underlying response. This method is called once only.