Package ratpack.http

Examples of ratpack.http.Response.sendStream()


  public void render(Context context, ServerSentEvents object) throws Exception {
    Response response = context.getResponse();
    response.getHeaders().add(HttpHeaderConstants.CONTENT_TYPE, TEXT_EVENT_STREAM_CHARSET_UTF_8);
    response.getHeaders().add(HttpHeaderConstants.CACHE_CONTROL, HttpHeaderConstants.NO_CACHE_FULL);
    response.getHeaders().add(HttpHeaderConstants.PRAGMA, HttpHeaderConstants.NO_CACHE);
    response.sendStream(Streams.map(object.getPublisher(), encoder));
  }

  public static class Encoder implements Function<ServerSentEvent, ByteBuf> {
    private final ByteBufAllocator bufferAllocator;
View Full Code Here


  public void render(Context context, ResponseChunks chunks) throws Exception {
    Response response = context.getResponse();
    response.getHeaders().add(HttpHeaderConstants.TRANSFER_ENCODING, HttpHeaderConstants.CHUNKED);
    response.getHeaders().set(HttpHeaderConstants.CONTENT_TYPE, chunks.getContentType());
    Publisher<? extends ByteBuf> publisher = chunks.publisher(context.getLaunchConfig().getBufferAllocator());
    response.sendStream(publisher);
  }

}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.