Search in sources :

Example 11 with FullRequest

use of org.webpieces.http2client.api.dto.FullRequest in project webpieces by deanhiller.

the class TestLesson8JsonHttp2 method createRequest.

public static FullRequest createRequest(String uri, DataWrapper body) {
    Http2Request req = new Http2Request();
    req.addHeader(new Http2Header(Http2HeaderName.AUTHORITY, "yourdomain.com"));
    req.addHeader(new Http2Header(Http2HeaderName.SCHEME, "https"));
    req.addHeader(new Http2Header(Http2HeaderName.METHOD, "GET"));
    req.addHeader(new Http2Header(Http2HeaderName.PATH, uri));
    req.addHeader(new Http2Header(Http2HeaderName.CONTENT_LENGTH, body.getReadableSize() + ""));
    FullRequest fullReq = new FullRequest(req, body, null);
    return fullReq;
}
Also used : Http2Request(com.webpieces.http2.api.dto.highlevel.Http2Request) Http2Header(com.webpieces.http2.api.dto.lowlevel.lib.Http2Header) FullRequest(org.webpieces.http2client.api.dto.FullRequest)

Example 12 with FullRequest

use of org.webpieces.http2client.api.dto.FullRequest in project webpieces by deanhiller.

the class TestBasicHttp2Client method testBasicSendRespond.

@Test
public void testBasicSendRespond() {
    FullRequest request1 = Requests.createHttp2Request();
    MockResponseListener respListener1 = new MockResponseListener();
    respListener1.setIncomingRespDefault(XFuture.completedFuture(null));
    XFuture<FullResponse> future = httpSocket.send(request1);
    Assert.assertFalse(future.isDone());
}
Also used : FullResponse(org.webpieces.http2client.api.dto.FullResponse) MockResponseListener(org.webpieces.http2client.mock.MockResponseListener) FullRequest(org.webpieces.http2client.api.dto.FullRequest) Test(org.junit.Test)

Example 13 with FullRequest

use of org.webpieces.http2client.api.dto.FullRequest in project webpieces by deanhiller.

the class TestCBasicRequestResponse method testWithData.

@Test
public void testWithData() throws InterruptedException, ExecutionException, TimeoutException {
    FullRequest request1 = Requests.createHttp2Request();
    XFuture<FullResponse> future = httpSocket.send(request1);
    Assert.assertFalse(future.isDone());
    List<Http2Msg> frames = mockChannel.getFramesAndClear();
    Assert.assertEquals(2, frames.size());
    Http2Response resp = Requests.createResponse(request1.getHeaders().getStreamId());
    mockChannel.write(resp);
    Assert.assertFalse(future.isDone());
    DataFrame data = Requests.createData(request1.getHeaders().getStreamId(), true);
    mockChannel.write(data);
    FullResponse response = future.get(2, TimeUnit.SECONDS);
    Assert.assertEquals(2, response.getPayload().getReadableSize());
}
Also used : Http2Response(com.webpieces.http2.api.dto.highlevel.Http2Response) FullResponse(org.webpieces.http2client.api.dto.FullResponse) 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)

Example 14 with FullRequest

use of org.webpieces.http2client.api.dto.FullRequest 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

FullRequest (org.webpieces.http2client.api.dto.FullRequest)14 FullResponse (org.webpieces.http2client.api.dto.FullResponse)9 Test (org.junit.Test)6 DataWrapper (org.webpieces.data.api.DataWrapper)5 Http2Request (com.webpieces.http2.api.dto.highlevel.Http2Request)4 Http2Response (com.webpieces.http2.api.dto.highlevel.Http2Response)3 DataFrame (com.webpieces.http2.api.dto.lowlevel.DataFrame)3 Http2Header (com.webpieces.http2.api.dto.lowlevel.lib.Http2Header)3 HttpFullRequest (org.webpieces.httpclient11.api.HttpFullRequest)3 Http2Trailers (com.webpieces.http2.api.dto.highlevel.Http2Trailers)2 Http2Msg (com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg)2 InetSocketAddress (java.net.InetSocketAddress)2 Http2Socket (org.webpieces.http2client.api.Http2Socket)2 HttpFullResponse (org.webpieces.httpclient11.api.HttpFullResponse)2 PrivateWebserverForTest (org.webpieces.webserver.PrivateWebserverForTest)2 AbstractHttp2Test (org.webpieces.webserver.test.http2.AbstractHttp2Test)2 ResponseWrapperHttp2 (org.webpieces.webserver.test.http2.ResponseWrapperHttp2)2 Http2Request (com.webpieces.hpack.api.dto.Http2Request)1 Http2Trailers (com.webpieces.hpack.api.dto.Http2Trailers)1 Http2Headers (com.webpieces.http2.api.dto.highlevel.Http2Headers)1