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