Java Code Examples for io.reactivex.netty.protocol.http.server.HttpServerResponse#writeAndFlush()
The following examples show how to use
io.reactivex.netty.protocol.http.server.HttpServerResponse#writeAndFlush() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NettyToJerseyBridge.java From karyon with Apache License 2.0 | 6 votes |
ContainerResponseWriter bridgeResponse(final HttpServerResponse<ByteBuf> serverResponse) { return new ContainerResponseWriter() { private final ByteBuf contentBuffer = serverResponse.getChannel().alloc().buffer(); @Override public OutputStream writeStatusAndHeaders(long contentLength, ContainerResponse response) { int responseStatus = response.getStatus(); serverResponse.setStatus(HttpResponseStatus.valueOf(responseStatus)); HttpResponseHeaders responseHeaders = serverResponse.getHeaders(); for(Map.Entry<String, List<Object>> header : response.getHttpHeaders().entrySet()){ responseHeaders.setHeader(header.getKey(), header.getValue()); } return new ByteBufOutputStream(contentBuffer); } @Override public void finish() { serverResponse.writeAndFlush(contentBuffer); } }; }
Example 2
Source File: HystrixMetricsStreamHandler.java From ReactiveLab with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private void writeMetric(String json, HttpServerResponse<O> response) { byte[] bytes = json.getBytes(Charset.defaultCharset()); ByteBuf byteBuf = UnpooledByteBufAllocator.DEFAULT.buffer(bytes.length + EXTRA_SPACE); byteBuf.writeBytes(HEADER); byteBuf.writeBytes(bytes); byteBuf.writeBytes(FOOTER); response.writeAndFlush((O) byteBuf); }
Example 3
Source File: HystrixMetricsStreamHandler.java From ReactiveLab with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private void writeMetric(String json, HttpServerResponse<O> response) { byte[] bytes = json.getBytes(Charset.defaultCharset()); ByteBuf byteBuf = UnpooledByteBufAllocator.DEFAULT.buffer(bytes.length + EXTRA_SPACE); byteBuf.writeBytes(HEADER); byteBuf.writeBytes(bytes); byteBuf.writeBytes(FOOTER); response.writeAndFlush((O) byteBuf); }