Search in sources :

Example 11 with ResponseStreamHandle

use of com.webpieces.http2.api.streaming.ResponseStreamHandle in project webpieces by deanhiller.

the class JsonController method myStream.

// Method signature cannot have RequestContext since in microservices, we implement an api as the server
// AND a client implements the same api AND client does not have a RequestContext!!
@Override
public StreamRef myStream(ResponseStreamHandle handle2) {
    RouterStreamHandle handle = (RouterStreamHandle) handle2;
    RequestContext requestCtx = Current.getContext();
    Http2Response response = handle.createBaseResponse(requestCtx.getRequest().originalRequest, "text/plain", 200, "Ok");
    response.setEndOfStream(false);
    XFuture<StreamWriter> responseWriter = handle.process(response);
    return new RequestStreamEchoWriter(requestCtx, handle, responseWriter);
}
Also used : RouterStreamHandle(org.webpieces.router.api.RouterStreamHandle) Http2Response(com.webpieces.http2.api.dto.highlevel.Http2Response) StreamWriter(com.webpieces.http2.api.streaming.StreamWriter) RequestContext(org.webpieces.ctx.api.RequestContext)

Aggregations

ResponseStreamHandle (com.webpieces.http2.api.streaming.ResponseStreamHandle)5 StreamWriter (com.webpieces.http2.api.streaming.StreamWriter)5 Http2Response (com.webpieces.http2.api.dto.highlevel.Http2Response)4 Http2Request (com.webpieces.http2.api.dto.highlevel.Http2Request)2 Http2Header (com.webpieces.http2.api.dto.lowlevel.lib.Http2Header)2 PushStreamHandle (com.webpieces.http2.api.streaming.PushStreamHandle)2 StreamRef (com.webpieces.http2.api.streaming.StreamRef)2 RequestContext (org.webpieces.ctx.api.RequestContext)2 XFuture (org.webpieces.util.futures.XFuture)2 HeaderType (com.webpieces.http2.api.dto.lowlevel.lib.HeaderType)1 Http2HeaderName (com.webpieces.http2.api.dto.lowlevel.lib.Http2HeaderName)1 PushPromiseListener (com.webpieces.http2.api.streaming.PushPromiseListener)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Locale (java.util.Locale)1 Set (java.util.Set)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeUnit (java.util.concurrent.TimeUnit)1 Collectors (java.util.stream.Collectors)1 HttpMethod (org.webpieces.ctx.api.HttpMethod)1