类 MockServerHttpResponse

java.lang.Object
cn.taketoday.http.server.reactive.AbstractServerHttpResponse
cn.taketoday.mock.http.server.reactive.MockServerHttpResponse
所有已实现的接口:
cn.taketoday.http.HttpMessage, cn.taketoday.http.ReactiveHttpOutputMessage, cn.taketoday.http.server.reactive.ServerHttpResponse

public class MockServerHttpResponse extends cn.taketoday.http.server.reactive.AbstractServerHttpResponse
Mock extension of AbstractServerHttpResponse for use in tests without an actual server.

By default response content is consumed in full upon writing and cached for subsequent access, however it is also possible to set a custom writeHandler.

从以下版本开始:
4.0
作者:
Rossen Stoyanchev
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    private reactor.core.publisher.Flux<cn.taketoday.core.io.buffer.DataBuffer>
     
    private Function<reactor.core.publisher.Flux<cn.taketoday.core.io.buffer.DataBuffer>,reactor.core.publisher.Mono<Void>>
     
  • 构造器概要

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

    修饰符和类型
    方法
    说明
    protected void
     
    protected void
     
    protected void
     
    reactor.core.publisher.Flux<cn.taketoday.core.io.buffer.DataBuffer>
    Return the response body or an error stream if the body was not set.
    reactor.core.publisher.Mono<String>
    Aggregate response data and convert to a String using the "Content-Type" charset or "UTF-8" by default.
    <T> T
     
    reactor.core.publisher.Mono<Void>
     
    void
    setWriteHandler(Function<reactor.core.publisher.Flux<cn.taketoday.core.io.buffer.DataBuffer>,reactor.core.publisher.Mono<Void>> writeHandler)
    Configure a custom handler to consume the response body.
    protected reactor.core.publisher.Mono<Void>
    writeAndFlushWithInternal(org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends cn.taketoday.core.io.buffer.DataBuffer>> body)
     
    protected reactor.core.publisher.Mono<Void>
    writeWithInternal(org.reactivestreams.Publisher<? extends cn.taketoday.core.io.buffer.DataBuffer> body)
     

    从类继承的方法 cn.taketoday.http.server.reactive.AbstractServerHttpResponse

    addCookie, beforeCommit, bufferFactory, doCommit, doCommit, getCookies, getHeaders, getRawStatusCode, getStatusCode, isCommitted, setRawStatusCode, setStatusCode, touchDataBuffer, writeAndFlushWith, writeWith

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

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

    • body

      private reactor.core.publisher.Flux<cn.taketoday.core.io.buffer.DataBuffer> body
    • writeHandler

      private Function<reactor.core.publisher.Flux<cn.taketoday.core.io.buffer.DataBuffer>,reactor.core.publisher.Mono<Void>> writeHandler
  • 构造器详细资料

    • MockServerHttpResponse

      public MockServerHttpResponse()
    • MockServerHttpResponse

      public MockServerHttpResponse(cn.taketoday.core.io.buffer.DataBufferFactory dataBufferFactory)
  • 方法详细资料

    • setWriteHandler

      public void setWriteHandler(Function<reactor.core.publisher.Flux<cn.taketoday.core.io.buffer.DataBuffer>,reactor.core.publisher.Mono<Void>> writeHandler)
      Configure a custom handler to consume the response body.

      By default, response body content is consumed in full and cached for subsequent access in tests. Use this option to take control over how the response body is consumed.

      参数:
      writeHandler - the write handler to use returning Mono<Void> when the body has been "written" (i.e. consumed).
    • getNativeResponse

      public <T> T getNativeResponse()
      指定者:
      getNativeResponse 在类中 cn.taketoday.http.server.reactive.AbstractServerHttpResponse
    • applyStatusCode

      protected void applyStatusCode()
      指定者:
      applyStatusCode 在类中 cn.taketoday.http.server.reactive.AbstractServerHttpResponse
    • applyHeaders

      protected void applyHeaders()
      指定者:
      applyHeaders 在类中 cn.taketoday.http.server.reactive.AbstractServerHttpResponse
    • applyCookies

      protected void applyCookies()
      指定者:
      applyCookies 在类中 cn.taketoday.http.server.reactive.AbstractServerHttpResponse
    • writeWithInternal

      protected reactor.core.publisher.Mono<Void> writeWithInternal(org.reactivestreams.Publisher<? extends cn.taketoday.core.io.buffer.DataBuffer> body)
      指定者:
      writeWithInternal 在类中 cn.taketoday.http.server.reactive.AbstractServerHttpResponse
    • writeAndFlushWithInternal

      protected reactor.core.publisher.Mono<Void> writeAndFlushWithInternal(org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends cn.taketoday.core.io.buffer.DataBuffer>> body)
      指定者:
      writeAndFlushWithInternal 在类中 cn.taketoday.http.server.reactive.AbstractServerHttpResponse
    • setComplete

      public reactor.core.publisher.Mono<Void> setComplete()
      指定者:
      setComplete 在接口中 cn.taketoday.http.ReactiveHttpOutputMessage
      覆盖:
      setComplete 在类中 cn.taketoday.http.server.reactive.AbstractServerHttpResponse
    • getBody

      public reactor.core.publisher.Flux<cn.taketoday.core.io.buffer.DataBuffer> getBody()
      Return the response body or an error stream if the body was not set.
    • getBodyAsString

      public reactor.core.publisher.Mono<String> getBodyAsString()
      Aggregate response data and convert to a String using the "Content-Type" charset or "UTF-8" by default.