Search in sources :

Example 6 with Http2Trailers

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

the class TestCBasicRequestResponse method testWithDataAndTrailingHeaders.

@Test
public void testWithDataAndTrailingHeaders() throws InterruptedException, ExecutionException, TimeoutException {
    FullRequest request1 = Requests.createHttp2Request();
    Http2Trailers trailing = Requests.createTrailers();
    request1.setTrailingHeaders(trailing);
    XFuture<FullResponse> future = httpSocket.send(request1);
    Assert.assertFalse(future.isDone());
    List<Http2Msg> frames = mockChannel.getFramesAndClear();
    Assert.assertEquals(3, frames.size());
    Http2Response resp = Requests.createResponse(request1.getHeaders().getStreamId());
    mockChannel.write(resp);
    Assert.assertFalse(future.isDone());
    DataFrame data = Requests.createData(request1.getHeaders().getStreamId(), false);
    mockChannel.write(data);
    Assert.assertFalse(future.isDone());
    mockChannel.write(trailing);
    FullResponse response = future.get(2, TimeUnit.SECONDS);
    Assert.assertEquals(2, response.getPayload().getReadableSize());
    Assert.assertNotNull(response.getTrailingHeaders());
}
Also used : Http2Response(com.webpieces.http2.api.dto.highlevel.Http2Response) FullResponse(org.webpieces.http2client.api.dto.FullResponse) Http2Trailers(com.webpieces.http2.api.dto.highlevel.Http2Trailers) DataFrame(com.webpieces.http2.api.dto.lowlevel.DataFrame) Http2Msg(com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg) FullRequest(org.webpieces.http2client.api.dto.FullRequest) Test(org.junit.Test)

Aggregations

Http2Trailers (com.webpieces.http2.api.dto.highlevel.Http2Trailers)5 DataFrame (com.webpieces.http2.api.dto.lowlevel.DataFrame)3 StreamWriter (com.webpieces.http2.api.streaming.StreamWriter)3 Http2Request (com.webpieces.http2.api.dto.highlevel.Http2Request)2 Http2Response (com.webpieces.http2.api.dto.highlevel.Http2Response)2 Http2Header (com.webpieces.http2.api.dto.lowlevel.lib.Http2Header)2 Http2Msg (com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 FullRequest (org.webpieces.http2client.api.dto.FullRequest)2 FullResponse (org.webpieces.http2client.api.dto.FullResponse)2 Http2Headers (com.webpieces.http2.api.dto.highlevel.Http2Headers)1 RequestStreamHandle (com.webpieces.http2.api.streaming.RequestStreamHandle)1 StreamRef (com.webpieces.http2.api.streaming.StreamRef)1 Supplier (java.util.function.Supplier)1 DataWrapper (org.webpieces.data.api.DataWrapper)1 PassedIn (org.webpieces.httpfrontend2.api.mock2.MockHttp2RequestListener.PassedIn)1 MockStreamWriter (org.webpieces.httpfrontend2.api.mock2.MockStreamWriter)1 XFuture (org.webpieces.util.futures.XFuture)1