Search in sources :

Example 6 with Http2Headers

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());
}
Also used : StreamMsg(com.webpieces.http2parser.api.dto.lib.StreamMsg) Http2Headers(com.webpieces.hpack.api.dto.Http2Headers) MockStreamWriter(org.webpieces.http2client.mock.MockStreamWriter) StreamWriter(com.webpieces.http2engine.api.StreamWriter) RequestsSent(org.webpieces.http2client.util.RequestsSent) MockResponseListener(org.webpieces.http2client.mock.MockResponseListener) DataFrame(com.webpieces.http2parser.api.dto.DataFrame) RequestHolder(org.webpieces.http2client.util.RequestHolder) MockStreamWriter(org.webpieces.http2client.mock.MockStreamWriter) Test(org.junit.Test)

Example 7 with Http2Headers

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;
}
Also used : Http2Headers(com.webpieces.hpack.api.dto.Http2Headers) Http2Header(com.webpieces.http2parser.api.dto.lib.Http2Header)

Aggregations

Http2Headers (com.webpieces.hpack.api.dto.Http2Headers)7 Test (org.junit.Test)4 Http2Push (com.webpieces.hpack.api.dto.Http2Push)3 Http2Response (com.webpieces.hpack.api.dto.Http2Response)3 DataFrame (com.webpieces.http2parser.api.dto.DataFrame)3 Http2Request (com.webpieces.hpack.api.dto.Http2Request)2 StreamWriter (com.webpieces.http2engine.api.StreamWriter)2 Http2Header (com.webpieces.http2parser.api.dto.lib.Http2Header)2 PassedIn (org.webpieces.httpfrontend2.api.mock2.MockHttp2RequestListener.PassedIn)2 Http2Trailers (com.webpieces.hpack.api.dto.Http2Trailers)1 PushPromiseListener (com.webpieces.http2engine.api.PushPromiseListener)1 Http2PayloadType (com.webpieces.http2engine.impl.shared.data.Http2PayloadType)1 CancelReason (com.webpieces.http2parser.api.dto.CancelReason)1 HeadersFrame (com.webpieces.http2parser.api.dto.HeadersFrame)1 PushPromiseFrame (com.webpieces.http2parser.api.dto.PushPromiseFrame)1 HasHeaderFragment (com.webpieces.http2parser.api.dto.lib.HasHeaderFragment)1 Http2HeaderName (com.webpieces.http2parser.api.dto.lib.Http2HeaderName)1 Http2Msg (com.webpieces.http2parser.api.dto.lib.Http2Msg)1 StreamMsg (com.webpieces.http2parser.api.dto.lib.StreamMsg)1 HashMap (java.util.HashMap)1