Search in sources :

Example 11 with Http2Push

use of com.webpieces.http2.api.dto.highlevel.Http2Push in project webpieces by deanhiller.

the class Level8NotifyClntListeners method sendPushToApp.

public XFuture<Void> sendPushToApp(ClientPushStream stream, Http2Push fullPromise) {
    ResponseStreamHandle listener = stream.getOriginalResponseListener();
    PushStreamHandle pushHandle = listener.openPushStream();
    stream.setPushStreamHandle(pushHandle);
    return pushHandle.process(fullPromise).thenApply(l -> {
        stream.setPushPromiseListener(l);
        return null;
    });
}
Also used : PushStreamHandle(com.webpieces.http2.api.streaming.PushStreamHandle) ResponseStreamHandle(com.webpieces.http2.api.streaming.ResponseStreamHandle)

Example 12 with Http2Push

use of com.webpieces.http2.api.dto.highlevel.Http2Push in project webpieces by deanhiller.

the class Requests method createPush.

public static Http2Push createPush(int streamId) {
    Http2Push push = new Http2Push();
    push.setStreamId(streamId);
    push.setPromisedStreamId(2);
    push.addHeader(new Http2Header(Http2HeaderName.SERVER, "me"));
    return push;
}
Also used : Http2Header(com.webpieces.http2.api.dto.lowlevel.lib.Http2Header) Http2Push(com.webpieces.http2.api.dto.highlevel.Http2Push)

Example 13 with Http2Push

use of com.webpieces.http2.api.dto.highlevel.Http2Push in project webpieces by deanhiller.

the class HpackParserImpl method createPushPromiseData.

private DataWrapper createPushPromiseData(MarshalStateImpl state, Http2Push p) {
    long maxFrameSize = state.getMaxRemoteFrameSize();
    Encoder encoder = state.getEncoder();
    List<Http2Frame> headerFrames = encoding.translateToFrames(maxFrameSize, encoder, p);
    return translate(headerFrames);
}
Also used : Encoder(com.twitter.hpack.Encoder) Http2Frame(com.webpieces.http2.api.dto.lowlevel.lib.Http2Frame)

Example 14 with Http2Push

use of com.webpieces.http2.api.dto.highlevel.Http2Push in project webpieces by deanhiller.

the class TestSBasicRequestResponse method testPushPromise.

@Test
public void testPushPromise() throws InterruptedException, ExecutionException, TimeoutException {
    Http2Request request1 = Http2Requests.createRequest(1, true);
    mockChannel.send(request1);
    PassedIn incoming = mockListener.getSingleRequest();
    Assert.assertEquals(request1, incoming.request);
    Http2Push push = Http2Requests.createPush(request1.getStreamId());
    XFuture<PushPromiseListener> future = incoming.stream.openPushStream().process(push);
    PushPromiseListener pushWriter = future.get(2, TimeUnit.SECONDS);
    Http2Push pushRecv = (Http2Push) mockChannel.getFrameAndClear();
    Assert.assertEquals(push, pushRecv);
    Http2Response preEmptive = Http2Requests.createResponse(push.getPromisedStreamId());
    pushWriter.processPushResponse(preEmptive);
    Http2Headers preEmptRecv = (Http2Headers) mockChannel.getFrameAndClear();
    Assert.assertEquals(preEmptive, preEmptRecv);
    Http2Response response = Http2Requests.createResponse(request1.getStreamId());
    incoming.stream.process(response);
    Http2Headers responseRecv = (Http2Headers) mockChannel.getFrameAndClear();
    Assert.assertEquals(response, responseRecv);
}
Also used : Http2Response(com.webpieces.http2.api.dto.highlevel.Http2Response) PushPromiseListener(com.webpieces.http2.api.streaming.PushPromiseListener) Http2Request(com.webpieces.http2.api.dto.highlevel.Http2Request) Http2Headers(com.webpieces.http2.api.dto.highlevel.Http2Headers) Http2Push(com.webpieces.http2.api.dto.highlevel.Http2Push) PassedIn(org.webpieces.httpfrontend2.api.mock2.MockHttp2RequestListener.PassedIn) Test(org.junit.Test)

Aggregations

Http2Push (com.webpieces.http2.api.dto.highlevel.Http2Push)10 Http2Header (com.webpieces.http2.api.dto.lowlevel.lib.Http2Header)4 Http2Headers (com.webpieces.http2.api.dto.highlevel.Http2Headers)3 Http2Request (com.webpieces.http2.api.dto.highlevel.Http2Request)3 Http2Response (com.webpieces.http2.api.dto.highlevel.Http2Response)3 DataFrame (com.webpieces.http2.api.dto.lowlevel.DataFrame)3 Test (org.junit.Test)3 DataWrapper (org.webpieces.data.api.DataWrapper)3 PassedIn (org.webpieces.httpfrontend2.api.mock2.MockHttp2RequestListener.PassedIn)3 GoAwayFrame (com.webpieces.http2.api.dto.lowlevel.GoAwayFrame)2 PushPromiseFrame (com.webpieces.http2.api.dto.lowlevel.PushPromiseFrame)2 Http2Frame (com.webpieces.http2.api.dto.lowlevel.lib.Http2Frame)2 Http2Msg (com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg)2 PushPromiseListener (com.webpieces.http2.api.streaming.PushPromiseListener)2 StreamWriter (com.webpieces.http2.api.streaming.StreamWriter)2 MockPushListener (org.webpieces.http2client.mock.MockPushListener)2 Encoder (com.twitter.hpack.Encoder)1 ConnectionException (com.webpieces.http2.api.dto.error.ConnectionException)1 CancelReason (com.webpieces.http2.api.dto.lowlevel.CancelReason)1 HeadersFrame (com.webpieces.http2.api.dto.lowlevel.HeadersFrame)1