Search in sources :

Example 41 with TransportCallbackAdapter

use of com.linkedin.r2.transport.common.bridge.server.TransportCallbackAdapter in project rest.li by linkedin.

the class MockClient method streamRequest.

@Override
public void streamRequest(StreamRequest request, RequestContext requestContext, Callback<StreamResponse> callback) {
    TransportCallback<StreamResponse> adapter = HttpBridge.streamToHttpCallback(new TransportCallbackAdapter<StreamResponse>(callback), request);
    RestResponse response = new RestResponseBuilder().setStatus(status()).setHeaders(headers()).setEntity(body()).build();
    adapter.onResponse(TransportResponseImpl.success(Messages.toStreamResponse(response)));
}
Also used : RestResponse(com.linkedin.r2.message.rest.RestResponse) StreamResponse(com.linkedin.r2.message.stream.StreamResponse) RestResponseBuilder(com.linkedin.r2.message.rest.RestResponseBuilder)

Aggregations

RequestContext (com.linkedin.r2.message.RequestContext)34 FutureCallback (com.linkedin.common.callback.FutureCallback)30 RestRequest (com.linkedin.r2.message.rest.RestRequest)30 RestRequestBuilder (com.linkedin.r2.message.rest.RestRequestBuilder)27 Test (org.testng.annotations.Test)26 RestResponse (com.linkedin.r2.message.rest.RestResponse)23 StreamResponse (com.linkedin.r2.message.stream.StreamResponse)22 TransportCallbackAdapter (com.linkedin.r2.transport.common.bridge.client.TransportCallbackAdapter)22 ExecutionException (java.util.concurrent.ExecutionException)21 RemoteInvocationException (com.linkedin.r2.RemoteInvocationException)15 URI (java.net.URI)15 ByteString (com.linkedin.data.ByteString)14 TimeoutException (java.util.concurrent.TimeoutException)13 AsciiString (io.netty.util.AsciiString)10 None (com.linkedin.common.util.None)8 HashMap (java.util.HashMap)7 RestException (com.linkedin.r2.message.rest.RestException)6 StreamRequest (com.linkedin.r2.message.stream.StreamRequest)6 TransportCallback (com.linkedin.r2.transport.common.bridge.common.TransportCallback)6 Server (org.eclipse.jetty.server.Server)6