use of org.webpieces.httpparser.api.HttpStatefulParser in project webpieces by deanhiller.
the class TestHttp11Backpressure method create4SplitPayloads.
private List<ByteBuffer> create4SplitPayloads() {
HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/xxxx");
req.addHeader(new Header(KnownHeaderName.TRANSFER_ENCODING, "chunked"));
HttpChunk chunk = new HttpChunk();
String bodyStr = "hi here and there";
DataWrapper data = DATA_GEN.wrapByteArray(bodyStr.getBytes(StandardCharsets.UTF_8));
chunk.setBody(data);
HttpLastChunk lastChunk = new HttpLastChunk();
HttpStatefulParser parser = HttpParserFactory.createStatefulParser("a", new SimpleMeterRegistry(), new TwoPools("pl", new SimpleMeterRegistry()));
ByteBuffer buf1 = parser.marshalToByteBuffer(req);
ByteBuffer buf2 = parser.marshalToByteBuffer(chunk);
ByteBuffer buf3 = parser.marshalToByteBuffer(lastChunk);
byte[] part1 = new byte[10];
byte[] part2 = new byte[buf1.remaining()];
buf1.get(part1);
int toWrite = buf1.remaining();
buf1.get(part2, 0, toWrite);
buf2.get(part2, toWrite, part2.length - toWrite);
byte[] part3 = new byte[buf2.remaining() + 2];
int toWrite2 = buf2.remaining();
buf2.get(part3, 0, toWrite2);
buf3.get(part3, toWrite2, 2);
byte[] part4 = new byte[buf3.remaining()];
buf3.get(part4);
List<ByteBuffer> buffers = new ArrayList<>();
buffers.add(ByteBuffer.wrap(part1));
buffers.add(ByteBuffer.wrap(part2));
buffers.add(ByteBuffer.wrap(part3));
buffers.add(ByteBuffer.wrap(part4));
return buffers;
}
use of org.webpieces.httpparser.api.HttpStatefulParser in project webpieces by deanhiller.
the class TestHttp1Backpressure method create4BuffersWith3Messags.
private List<ByteBuffer> create4BuffersWith3Messags(Http2Response response1, HttpChunk response2, HttpLastChunk lastChunk) {
HttpStatefulParser parser = HttpParserFactory.createStatefulParser("a", new SimpleMeterRegistry(), new TwoPools("pl", new SimpleMeterRegistry()));
HttpResponse resp1 = Http2ToHttp11.translateResponse(response1);
ByteBuffer buf1 = parser.marshalToByteBuffer(resp1);
ByteBuffer buf2 = parser.marshalToByteBuffer(response2);
ByteBuffer buf3 = parser.marshalToByteBuffer(lastChunk);
byte[] part1 = new byte[10];
byte[] part2 = new byte[buf1.remaining()];
buf1.get(part1);
int toWrite = buf1.remaining();
buf1.get(part2, 0, toWrite);
buf2.get(part2, toWrite, part2.length - toWrite);
byte[] part3 = new byte[buf2.remaining() + 2];
int toWrite2 = buf2.remaining();
buf2.get(part3, 0, toWrite2);
buf3.get(part3, toWrite2, 2);
byte[] part4 = new byte[buf3.remaining()];
buf3.get(part4);
List<ByteBuffer> buffers = new ArrayList<>();
buffers.add(ByteBuffer.wrap(part1));
buffers.add(ByteBuffer.wrap(part2));
buffers.add(ByteBuffer.wrap(part3));
buffers.add(ByteBuffer.wrap(part4));
return buffers;
}
use of org.webpieces.httpparser.api.HttpStatefulParser in project webpieces by deanhiller.
the class TestHttp1Backpressure method create3BuffersWithTwoMessags.
private List<ByteBuffer> create3BuffersWithTwoMessags(Http2Response response1, HttpData response2) {
HttpStatefulParser parser = HttpParserFactory.createStatefulParser("a", new SimpleMeterRegistry(), new TwoPools("pl", new SimpleMeterRegistry()));
HttpResponse resp1 = Http2ToHttp11.translateResponse(response1);
ByteBuffer buf1 = parser.marshalToByteBuffer(resp1);
ByteBuffer buf2 = parser.marshalToByteBuffer(response2);
byte[] part1 = new byte[10];
byte[] part2 = new byte[buf1.remaining()];
buf1.get(part1);
int toWrite = buf1.remaining();
buf1.get(part2, 0, toWrite);
buf2.get(part2, toWrite, part2.length - toWrite);
byte[] part3 = new byte[buf2.remaining()];
buf2.get(part3);
List<ByteBuffer> buffers = new ArrayList<>();
buffers.add(ByteBuffer.wrap(part1));
buffers.add(ByteBuffer.wrap(part2));
buffers.add(ByteBuffer.wrap(part3));
return buffers;
}
Aggregations