Search in sources :

Example 36 with HttpServerResponse

use of io.vertx.core.http.HttpServerResponse in project java-chassis by ServiceComb.

the class TestVertxRestServer method setUp.

@Before
public void setUp() throws Exception {
    Router mainRouter = Router.router(null);
    mainRouter.route().handler(BodyHandler.create());
    instance = new VertxRestServer(mainRouter) {

        @Override
        protected RestOperationMeta findRestOperation(RestServerRequestInternal restRequest) {
            return super.findRestOperation(restRequest);
        }

        @Override
        public void sendFailResponse(RestServerRequestInternal restRequest, HttpServerResponse httpResponse, Throwable throwable) {
        }
    };
}
Also used : RestOperationMeta(io.servicecomb.common.rest.definition.RestOperationMeta) RestServerRequestInternal(io.servicecomb.common.rest.codec.RestServerRequestInternal) HttpServerResponse(io.vertx.core.http.HttpServerResponse) Router(io.vertx.ext.web.Router) Before(org.junit.Before)

Example 37 with HttpServerResponse

use of io.vertx.core.http.HttpServerResponse in project java-chassis by ServiceComb.

the class GrpcServerInvoke method sendSuccessResponse.

private void sendSuccessResponse(Invocation invocation, Response response) {
    Buffer buffer = null;
    try {
        buffer = GrpcCodec.encodeResponse(invocation, response, operationProtobuf);
    } catch (Exception e) {
        LOGGER.error("grpc encode success response failed.", e);
        sendFailResponse(e);
        return;
    }
    HttpServerResponse httpServerResponse = routingContext.response();
    httpServerResponse.putTrailer("grpc-status", "0");
    httpServerResponse.end(buffer);
    ChannelHandlerContext ctx = (ChannelHandlerContext) ReflectionUtils.getField(ctxfield, httpServerResponse);
    ctx.flush();
}
Also used : Buffer(io.vertx.core.buffer.Buffer) HttpServerResponse(io.vertx.core.http.HttpServerResponse) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext)

Aggregations

HttpServerResponse (io.vertx.core.http.HttpServerResponse)37 Test (org.junit.Test)29 Buffer (io.vertx.core.buffer.Buffer)20 HttpClientRequest (io.vertx.core.http.HttpClientRequest)20 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)19 HttpClientOptions (io.vertx.core.http.HttpClientOptions)17 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)16 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)16 HttpMethod (io.vertx.core.http.HttpMethod)15 HttpServerOptions (io.vertx.core.http.HttpServerOptions)15 NetSocket (io.vertx.core.net.NetSocket)14 TimeUnit (java.util.concurrent.TimeUnit)14 AtomicReference (java.util.concurrent.atomic.AtomicReference)14 ChannelFuture (io.netty.channel.ChannelFuture)13 HttpConnection (io.vertx.core.http.HttpConnection)13 HttpVersion (io.vertx.core.http.HttpVersion)13 TestUtils.assertIllegalStateException (io.vertx.test.core.TestUtils.assertIllegalStateException)13 ArrayList (java.util.ArrayList)13 Collections (java.util.Collections)13 List (java.util.List)13