类 AbstractServerHttpResponse

java.lang.Object
cn.taketoday.http.server.reactive.AbstractServerHttpResponse
所有已实现的接口:
HttpMessage, ReactiveHttpOutputMessage, ServerHttpResponse
直接已知子类:
AbstractListenerServerHttpResponse, ReactorNetty2ServerHttpResponse, ReactorServerHttpResponse

public abstract class AbstractServerHttpResponse extends Object implements ServerHttpResponse
Base class for ServerHttpResponse implementations.
从以下版本开始:
4.0
作者:
Rossen Stoyanchev, Juergen Hoeller, Sebastien Deleuze, Brian Clozel
  • 嵌套类概要

    嵌套类
    修饰符和类型
    说明
    private static enum 
    COMMITTING -> 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 ArrayList<Supplier<? extends reactor.core.publisher.Mono<Void>>>
     
    private final cn.taketoday.util.MultiValueMap<String,ResponseCookie>
     
    private final cn.taketoday.core.io.buffer.DataBufferFactory
     
    private final HttpHeaders
     
    private HttpHeaders
     
     
    private Integer
     
  • 构造器概要

    构造器
    构造器
    说明
    AbstractServerHttpResponse(cn.taketoday.core.io.buffer.DataBufferFactory dataBufferFactory)
     
    AbstractServerHttpResponse(cn.taketoday.core.io.buffer.DataBufferFactory dataBufferFactory, HttpHeaders headers)
     
  • 方法概要

    修饰符和类型
    方法
    说明
    void
    Add the given ResponseCookie.
    protected abstract void
    Add cookies from getHeaders() to the underlying response.
    protected abstract void
    Invoked when the response is getting committed allowing sub-classes to make apply header values to the underlying response.
    protected abstract void
    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.
    final cn.taketoday.core.io.buffer.DataBufferFactory
    Return a DataBufferFactory that can be used to create the body.
    protected reactor.core.publisher.Mono<Void>
    A variant of doCommit(Supplier) for a response without no body.
    protected reactor.core.publisher.Mono<Void>
    doCommit(Supplier<? extends reactor.core.publisher.Mono<Void>> writeAction)
    Apply beforeCommit actions, 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> T
    Return 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.
    boolean
    Whether 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 via HttpMessage.getHeaders() to the underlying HTTP message (if not applied already).
    boolean
    Set the HTTP status code to the given value (potentially non-standard and not resolvable through the HttpStatus enum) as an integer.
    boolean
    Set the HTTP status code of the response.
    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.
    final reactor.core.publisher.Mono<Void>
    writeAndFlushWith(org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends cn.taketoday.core.io.buffer.DataBuffer>> body)
    Use the given Publisher of Publishers to write the body of the HttpOutputMessage to the underlying HTTP layer, flushing after each Publisher<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 each Publisher<DataBuffer>.
    final reactor.core.publisher.Mono<Void>
    writeWith(org.reactivestreams.Publisher<? extends cn.taketoday.core.io.buffer.DataBuffer> body)
    Use the given Publisher to 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.

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 字段详细资料

  • 构造器详细资料

    • 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()
      从接口复制的说明: ReactiveHttpOutputMessage
      Return a DataBufferFactory that can be used to create the body.
      指定者:
      bufferFactory 在接口中 ReactiveHttpOutputMessage
      返回:
      a buffer factory
      另请参阅:
    • setStatusCode

      public boolean setStatusCode(@Nullable HttpStatus status)
      从接口复制的说明: ServerHttpResponse
      Set the HTTP status code of the response.
      指定者:
      setStatusCode 在接口中 ServerHttpResponse
      参数:
      status - the HTTP status as an HttpStatus enum value
      返回:
      false if the status code change wasn't processed because the HTTP response is committed, true if successfully set.
    • getStatusCode

      @Nullable public HttpStatusCode 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 be null if the status code value is outside the HttpStatus 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 the HttpStatus 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 be null if there is no default value from the underlying server.
      指定者:
      getRawStatusCode 在接口中 ServerHttpResponse
    • getHeaders

      public HttpHeaders getHeaders()
      从接口复制的说明: HttpMessage
      Return the headers of this message.
      指定者:
      getHeaders 在接口中 HttpMessage
      返回:
      a corresponding HttpHeaders object (never null)
    • getCookies

      public cn.taketoday.util.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 given ResponseCookie.
      指定者:
      addCookie 在接口中 ServerHttpResponse
      参数:
      cookie - the cookie to add
    • getNativeResponse

      public abstract <T> T getNativeResponse()
      Return the underlying server response.
    • 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>>) or Mono.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 cn.taketoday.core.io.buffer.DataBuffer> body)
      从接口复制的说明: ReactiveHttpOutputMessage
      Use the given Publisher 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 cn.taketoday.core.io.buffer.DataBuffer>> body)
      从接口复制的说明: ReactiveHttpOutputMessage
      Use the given Publisher of Publishers to write the body of the HttpOutputMessage to the underlying HTTP layer, flushing after each Publisher<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 via HttpMessage.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 of doCommit(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)
      Apply beforeCommit actions, apply the response status and headers/cookies, and write the response body.
      参数:
      writeAction - the action to write the response body (may be null)
      返回:
      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 each Publisher<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 from getHeaders() 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