use of com.webpieces.hpack.api.dto.Http2Headers in project webpieces by deanhiller.
the class TestCMaxConcurrentSetting method testSend2ndRequestOnlyOnCompletionOfFirst.
@Test
public void testSend2ndRequestOnlyOnCompletionOfFirst() throws InterruptedException, ExecutionException {
RequestsSent sent = sendTwoRequests();
int streamId1 = sent.getRequest1().getRequest().getStreamId();
CompletableFuture<StreamWriter> future2 = sent.getRequest2().getFuture();
RequestHolder holder1 = sent.getRequest1();
RequestHolder holder2 = sent.getRequest2();
MockResponseListener listener1 = holder1.getListener();
MockStreamWriter writer1 = holder1.getWriter();
//endOfStream=false
mockChannel.write(Requests.createResponse(streamId1));
listener1.getSingleReturnValueIncomingResponse();
//endOfStream=false
mockChannel.write(new DataFrame(streamId1, false));
writer1.getSingleFrame();
//at this point, should not have a call outstanding
mockChannel.assertNoIncomingMessages();
Assert.assertFalse(future2.isDone());
MockResponseListener listener2 = holder2.getListener();
MockStreamWriter writer2 = holder2.getWriter();
listener2.addReturnValueIncomingResponse(CompletableFuture.completedFuture(writer2));
Assert.assertFalse(future2.isDone());
DataFrame dataFrame = new DataFrame(streamId1, true);
//endOfStream = true
mockChannel.write(dataFrame);
StreamMsg data = writer1.getSingleFrame();
Assert.assertEquals(dataFrame.getStreamId(), data.getStreamId());
Http2Headers frame = (Http2Headers) mockChannel.getFrameAndClear();
Assert.assertEquals(sent.getRequest2().getRequest(), frame);
Assert.assertTrue(future2.isDone());
}
use of com.webpieces.hpack.api.dto.Http2Headers in project webpieces by deanhiller.
the class LoginFilter method addCacheHeaders.
private Object addCacheHeaders(Object response) {
Http2Headers resp = (Http2Headers) response;
//http://stackoverflow.com/questions/49547/how-to-control-web-page-caching-across-all-browsers
//This forces the browser back button to re-request the page as it would never have the page
//and is good to use to hide banking information type pages
//resp.addHeader(new Header(KnownHeaderName.CACHE_CONTROL, "no-store"));
resp.addHeader(new Http2Header(Http2HeaderName.CACHE_CONTROL, "no-cache, no-store, must-revalidate"));
resp.addHeader(new Http2Header(Http2HeaderName.PRAGMA, "no-cache"));
resp.addHeader(new Http2Header(Http2HeaderName.EXPIRES, "0"));
return resp;
}
Aggregations