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;
});
}
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;
}
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);
}
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);
}
Aggregations