类 AbstractServerHttpResponse
- 所有已实现的接口:
HttpMessage,ReactiveHttpOutputMessage,ServerHttpResponse
- 直接已知子类:
AbstractListenerServerHttpResponse,ReactorNetty2ServerHttpResponse,ReactorServerHttpResponse
ServerHttpResponse implementations.- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev, Juergen Hoeller, Sebastien Deleuze, Brian Clozel
-
嵌套类概要
嵌套类修饰符和类型类说明private static enumCOMMITTING -> COMMITTED is the period after doCommit is called but before the response status and headers have been applied to the underlying response during which time pre-commit actions can still make changes to the response status and headers. -
字段概要
字段修饰符和类型字段说明private final cn.taketoday.util.MultiValueMap<String,ResponseCookie> private final cn.taketoday.core.io.buffer.DataBufferFactoryprivate final HttpHeadersprivate HttpHeadersprivate final AtomicReference<AbstractServerHttpResponse.State>private Integer -
构造器概要
构造器构造器说明AbstractServerHttpResponse(cn.taketoday.core.io.buffer.DataBufferFactory dataBufferFactory) AbstractServerHttpResponse(cn.taketoday.core.io.buffer.DataBufferFactory dataBufferFactory, HttpHeaders headers) -
方法概要
修饰符和类型方法说明voidaddCookie(ResponseCookie cookie) Add the givenResponseCookie.protected abstract voidAdd cookies fromgetHeaders()to the underlying response.protected abstract voidInvoked when the response is getting committed allowing sub-classes to make apply header values to the underlying response.protected abstract voidWrite the status code to the underlying response.voidbeforeCommit(Supplier<? extends reactor.core.publisher.Mono<Void>> action) Register an action to apply just before the HttpOutputMessage is committed.final cn.taketoday.core.io.buffer.DataBufferFactoryReturn aDataBufferFactorythat 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>ApplybeforeCommitactions, apply the response status and headers/cookies, and write the response body.cn.taketoday.util.MultiValueMap<String,ResponseCookie> Return a mutable map with the cookies to send to the server.Return the headers of this message.abstract <T> TReturn the underlying server response.Return the status code that has been set, or otherwise fall back on the status of the response from the underlying server.Return the status code that has been set, or otherwise fall back on the status of the response from the underlying server.booleanWhether the HttpOutputMessage is committed.reactor.core.publisher.Mono<Void>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).booleansetRawStatusCode(Integer statusCode) Set the HTTP status code to the given value (potentially non-standard and not resolvable through theHttpStatusenum) as an integer.booleansetStatusCode(HttpStatus status) Set the HTTP status code of the response.protected voidtouchDataBuffer(cn.taketoday.core.io.buffer.DataBuffer buffer) Allow sub-classes to associate a hint with the data buffer if it is a pooled buffer and supports leak tracking.final reactor.core.publisher.Mono<Void>writeAndFlushWith(org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends cn.taketoday.core.io.buffer.DataBuffer>> body) Use the givenPublisherofPublishersto 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 cn.taketoday.core.io.buffer.DataBuffer>> body) Write to the underlying the response, and flush after eachPublisher<DataBuffer>.final reactor.core.publisher.Mono<Void>writeWith(org.reactivestreams.Publisher<? extends cn.taketoday.core.io.buffer.DataBuffer> body) Use the givenPublisherto write the body of the message to the underlying HTTP layer.protected abstract reactor.core.publisher.Mono<Void>writeWithInternal(org.reactivestreams.Publisher<? extends cn.taketoday.core.io.buffer.DataBuffer> body) Write to the underlying the response.
-
字段详细资料
-
statusCode
-
readOnlyHeaders
-
headers
-
dataBufferFactory
private final cn.taketoday.core.io.buffer.DataBufferFactory dataBufferFactory -
cookies
-
state
-
commitActions
-
-
构造器详细资料
-
AbstractServerHttpResponse
public AbstractServerHttpResponse(cn.taketoday.core.io.buffer.DataBufferFactory dataBufferFactory) -
AbstractServerHttpResponse
public AbstractServerHttpResponse(cn.taketoday.core.io.buffer.DataBufferFactory dataBufferFactory, HttpHeaders headers)
-
-
方法详细资料
-
bufferFactory
public final cn.taketoday.core.io.buffer.DataBufferFactory bufferFactory()从接口复制的说明:ReactiveHttpOutputMessageReturn aDataBufferFactorythat can be used to create the body.- 指定者:
bufferFactory在接口中ReactiveHttpOutputMessage- 返回:
- a buffer factory
- 另请参阅:
-
setStatusCode
从接口复制的说明:ServerHttpResponseSet the HTTP status code of the response.- 指定者:
setStatusCode在接口中ServerHttpResponse- 参数:
status- the HTTP status as anHttpStatusenum value- 返回:
falseif the status code change wasn't processed because the HTTP response is committed,trueif successfully set.
-
getStatusCode
从接口复制的说明:ServerHttpResponseReturn 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 benullif the status code value is outside theHttpStatusenum range, or if there is no default value from the underlying server.- 指定者:
getStatusCode在接口中ServerHttpResponse
-
setRawStatusCode
从接口复制的说明:ServerHttpResponseSet the HTTP status code to the given value (potentially non-standard and not resolvable through theHttpStatusenum) as an integer.- 指定者:
setRawStatusCode在接口中ServerHttpResponse- 参数:
statusCode- the status code value- 返回:
falseif the status code change wasn't processed because the HTTP response is committed,trueif successfully set.
-
getRawStatusCode
从接口复制的说明:ServerHttpResponseReturn 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 benullif there is no default value from the underlying server.- 指定者:
getRawStatusCode在接口中ServerHttpResponse
-
getHeaders
从接口复制的说明:HttpMessageReturn the headers of this message.- 指定者:
getHeaders在接口中HttpMessage- 返回:
- a corresponding HttpHeaders object (never
null)
-
getCookies
从接口复制的说明:ServerHttpResponseReturn a mutable map with the cookies to send to the server.- 指定者:
getCookies在接口中ServerHttpResponse
-
addCookie
从接口复制的说明:ServerHttpResponseAdd the givenResponseCookie.- 指定者:
addCookie在接口中ServerHttpResponse- 参数:
cookie- the cookie to add
-
getNativeResponse
public abstract <T> T getNativeResponse()Return the underlying server response. -
beforeCommit
从接口复制的说明:ReactiveHttpOutputMessageRegister 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()从接口复制的说明:ReactiveHttpOutputMessageWhether the HttpOutputMessage is committed.- 指定者:
isCommitted在接口中ReactiveHttpOutputMessage
-
writeWith
public final reactor.core.publisher.Mono<Void> writeWith(org.reactivestreams.Publisher<? extends cn.taketoday.core.io.buffer.DataBuffer> body) 从接口复制的说明:ReactiveHttpOutputMessageUse the givenPublisherto write the body of the message to the underlying HTTP layer.- 指定者:
writeWith在接口中ReactiveHttpOutputMessage- 参数:
body- the body content publisher- 返回:
- a
Monothat indicates completion or error
-
writeAndFlushWith
public final reactor.core.publisher.Mono<Void> writeAndFlushWith(org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends cn.taketoday.core.io.buffer.DataBuffer>> body) 从接口复制的说明:ReactiveHttpOutputMessageUse the givenPublisherofPublishersto write the body of the HttpOutputMessage to the underlying HTTP layer, flushing after eachPublisher<DataBuffer>.- 指定者:
writeAndFlushWith在接口中ReactiveHttpOutputMessage- 参数:
body- the body content publisher- 返回:
- a
Monothat indicates completion or error
-
setComplete
从接口复制的说明:ReactiveHttpOutputMessageIndicate 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
Monothat indicates completion or error
-
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) ApplybeforeCommitactions, 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 cn.taketoday.core.io.buffer.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 cn.taketoday.core.io.buffer.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
HttpHeadersinstance 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. -
touchDataBuffer
protected void touchDataBuffer(cn.taketoday.core.io.buffer.DataBuffer buffer) Allow sub-classes to associate a hint with the data buffer if it is a pooled buffer and supports leak tracking.- 参数:
buffer- the buffer to attach a hint to
-