use of org.webpieces.httpparser.api.HttpParser in project webpieces by deanhiller.
the class Http2to11ClientFactory method createHttpClient.
public static Http2Client createHttpClient(String id, ChannelManager mgr, MeterRegistry metrics, BufferPool pool, boolean optimizeForBufferPool) {
HttpParser parser = HttpParserFactory.createParser(id, metrics, pool, optimizeForBufferPool);
HttpClient client11 = HttpClientFactory.createHttpClient(id, mgr, parser);
return new Http2ClientProxy(client11);
}
use of org.webpieces.httpparser.api.HttpParser in project webpieces by deanhiller.
the class TestBeansAndSplit method testIncomingDataAndDataSeperate.
@Test
public void testIncomingDataAndDataSeperate() {
HttpFullRequest req = Requests.createPostRequest("/postArray2", "user.accounts[1].name", "Account2Name", "user.accounts[1].color", "green", "user.accounts[2].addresses[0].number", "56", "user.firstName", "D&D", "user.lastName", "Hiller", "user.fullName", "Dean Hiller");
DataWrapperGenerator dataGen = DataWrapperGeneratorFactory.createDataWrapperGenerator();
HttpParser parser = HttpParserFactory.createParser("a", new SimpleMeterRegistry(), new TwoPools("pl", new SimpleMeterRegistry()));
MarshalState state = parser.prepareToMarshal();
ByteBuffer buffer = parser.marshalToByteBuffer(state, req.getRequest());
DataWrapper d1 = dataGen.wrapByteBuffer(buffer);
DataWrapper data = dataGen.chainDataWrappers(d1, req.getData());
// Split the body in half
List<? extends DataWrapper> split = dataGen.split(data, data.getReadableSize() - 20);
ByteBuffer buffer1 = ByteBuffer.wrap(split.get(0).createByteArray());
ByteBuffer buffer2 = ByteBuffer.wrap(split.get(1).createByteArray());
dataListener.incomingData(channel, buffer1);
dataListener.incomingData(channel, buffer2);
ResponseWrapper response = create();
response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
UserDto user = mockSomeLib.getUser();
Assert.assertEquals("D&D", user.getFirstName());
Assert.assertEquals(3, user.getAccounts().size());
Assert.assertEquals("Account2Name", user.getAccounts().get(1).getName());
Assert.assertEquals(56, user.getAccounts().get(2).getAddresses().get(0).getNumber());
}
use of org.webpieces.httpparser.api.HttpParser in project webpieces by deanhiller.
the class HttpFrontendFactory method createFrontEnd.
public static HttpFrontendManager createFrontEnd(AsyncServerManager svrMgr, BufferPool pool, Http2Config http2Config, MeterRegistry metrics) {
ScheduledExecutorService timer = Executors.newSingleThreadScheduledExecutor();
HttpParser httpParser = HttpParserFactory.createParser(svrMgr.getName(), metrics, pool);
HpackParser http2Parser = HpackParserFactory.createParser(pool, true);
InjectionConfig injConfig = new InjectionConfig(http2Parser, new TimeImpl(), http2Config);
Http2ServerEngineFactory svrEngineFactory = new Http2ServerEngineFactory(injConfig);
return new FrontEndServerManagerImpl(svrMgr, timer, svrEngineFactory, httpParser);
}
use of org.webpieces.httpparser.api.HttpParser in project webpieces by deanhiller.
the class IntegGoogleHttps method createHttpClient.
public static HttpClient createHttpClient() {
BufferPool pool2 = new TwoPools("pl", new SimpleMeterRegistry());
Executor executor2 = Executors.newFixedThreadPool(10, new NamedThreadFactory("clientThread"));
ChannelManagerFactory factory = ChannelManagerFactory.createFactory(Metrics.globalRegistry);
ChannelManager mgr = factory.createMultiThreadedChanMgr("client", pool2, new BackpressureConfig(), executor2);
HttpParser parser = HttpParserFactory.createParser("a", new SimpleMeterRegistry(), pool2);
HttpClient client = HttpClientFactory.createHttpClient("myClient", mgr, parser);
return client;
}
use of org.webpieces.httpparser.api.HttpParser in project webpieces by deanhiller.
the class HttpClientFactory method createHttpClient.
public static HttpClient createHttpClient(String id, int numThreads, BackpressureConfig backPressureConfig, MeterRegistry metrics) {
Executor executor = Executors.newFixedThreadPool(numThreads, new NamedThreadFactory("httpclient"));
MetricsCreator.monitor(metrics, executor, id);
TwoPools pool = new TwoPools(id + ".bufferpool", metrics);
HttpParser parser = HttpParserFactory.createParser(id, metrics, pool);
ChannelManagerFactory factory = ChannelManagerFactory.createFactory(metrics);
ChannelManager mgr = factory.createMultiThreadedChanMgr("httpClientChanMgr", pool, backPressureConfig, executor);
return createHttpClient(id, mgr, parser);
}
Aggregations