Search in sources :

Example 1 with HttpServerResponse

use of io.vertx.reactivex.core.http.HttpServerResponse in project vertx-examples by vert-x3.

the class Server method start.

@Override
public void start() throws Exception {
    HttpServer server = vertx.createHttpServer();
    server.requestStream().toFlowable().subscribe(req -> {
        HttpServerResponse resp = req.response();
        String contentType = req.getHeader("Content-Type");
        if (contentType != null) {
            resp.putHeader("Content-Type", contentType);
        }
        resp.setChunked(true);
        req.toFlowable().subscribe(resp::write, err -> {
        }, resp::end);
    });
    server.listen(8080);
}
Also used : HttpServerResponse(io.vertx.reactivex.core.http.HttpServerResponse) HttpServer(io.vertx.reactivex.core.http.HttpServer)

Example 2 with HttpServerResponse

use of io.vertx.reactivex.core.http.HttpServerResponse in project knotx by Cognifide.

the class KnotxGatewayResponseProviderHandler method sendResponse.

private void sendResponse(final RoutingContext context, final ClientResponse clientResponse) {
    HttpServerResponse httpResponse = context.response();
    writeHeaders(context.response(), clientResponse);
    httpResponse.setStatusCode(clientResponse.getStatusCode());
    if (isOkClientResponse(clientResponse)) {
        httpResponse.end(Buffer.newInstance(clientResponse.getBody()));
    } else {
        httpResponse.end();
    }
}
Also used : HttpServerResponse(io.vertx.reactivex.core.http.HttpServerResponse)

Example 3 with HttpServerResponse

use of io.vertx.reactivex.core.http.HttpServerResponse in project knotx by Cognifide.

the class KnotxAssemblerHandler method sendResponse.

private void sendResponse(final RoutingContext context, final ClientResponse clientResponse) {
    HttpServerResponse httpResponse = context.response();
    writeHeaders(context.response(), clientResponse);
    httpResponse.setStatusCode(clientResponse.getStatusCode());
    if (isOkClientResponse(clientResponse)) {
        httpResponse.end(Buffer.newInstance(clientResponse.getBody()));
    } else {
        httpResponse.end();
    }
}
Also used : HttpServerResponse(io.vertx.reactivex.core.http.HttpServerResponse)

Aggregations

HttpServerResponse (io.vertx.reactivex.core.http.HttpServerResponse)3 HttpServer (io.vertx.reactivex.core.http.HttpServer)1