Search in sources :

Example 11 with HttpParser

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);
}
Also used : HttpClient(org.webpieces.httpclient11.api.HttpClient) HttpParser(org.webpieces.httpparser.api.HttpParser) Http2ClientProxy(org.webpieces.httpclientx.impl.Http2ClientProxy)

Example 12 with HttpParser

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());
}
Also used : DataWrapper(org.webpieces.data.api.DataWrapper) DataWrapperGenerator(org.webpieces.data.api.DataWrapperGenerator) MarshalState(org.webpieces.httpparser.api.MarshalState) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) TwoPools(org.webpieces.data.api.TwoPools) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) UserDto(org.webpieces.webserver.basic.app.biz.UserDto) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) HttpParser(org.webpieces.httpparser.api.HttpParser) ByteBuffer(java.nio.ByteBuffer) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) Test(org.junit.Test)

Example 13 with HttpParser

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);
}
Also used : HpackParser(com.webpieces.hpack.api.HpackParser) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) HttpParser(org.webpieces.httpparser.api.HttpParser) Http2ServerEngineFactory(com.webpieces.http2engine.api.server.Http2ServerEngineFactory) TimeImpl(org.webpieces.util.time.TimeImpl) FrontEndServerManagerImpl(org.webpieces.frontend2.impl.FrontEndServerManagerImpl)

Example 14 with 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;
}
Also used : BackpressureConfig(org.webpieces.nio.api.BackpressureConfig) BufferPool(org.webpieces.data.api.BufferPool) Executor(java.util.concurrent.Executor) ChannelManager(org.webpieces.nio.api.ChannelManager) TwoPools(org.webpieces.data.api.TwoPools) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) HttpClient(org.webpieces.httpclient11.api.HttpClient) HttpParser(org.webpieces.httpparser.api.HttpParser) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory)

Example 15 with HttpParser

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);
}
Also used : Executor(java.util.concurrent.Executor) ChannelManager(org.webpieces.nio.api.ChannelManager) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) TwoPools(org.webpieces.data.api.TwoPools) HttpParser(org.webpieces.httpparser.api.HttpParser) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory)

Aggregations

HttpParser (org.webpieces.httpparser.api.HttpParser)15 TwoPools (org.webpieces.data.api.TwoPools)6 HpackParser (com.webpieces.hpack.api.HpackParser)5 InjectionConfig (com.webpieces.http2engine.api.client.InjectionConfig)5 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)5 Executor (java.util.concurrent.Executor)5 ChannelManager (org.webpieces.nio.api.ChannelManager)5 ChannelManagerFactory (org.webpieces.nio.api.ChannelManagerFactory)5 NamedThreadFactory (org.webpieces.util.threading.NamedThreadFactory)5 Http2ServerEngineFactory (com.webpieces.http2engine.api.server.Http2ServerEngineFactory)3 BufferCreationPool (org.webpieces.data.api.BufferCreationPool)3 FrontEndServerManagerImpl (org.webpieces.frontend2.impl.FrontEndServerManagerImpl)3 Provides (com.google.inject.Provides)2 ByteBuffer (java.nio.ByteBuffer)2 Singleton (javax.inject.Singleton)2 Before (org.junit.Before)2 Test (org.junit.Test)2 AsyncServerManager (org.webpieces.asyncserver.api.AsyncServerManager)2 DataWrapper (org.webpieces.data.api.DataWrapper)2 DataWrapperGenerator (org.webpieces.data.api.DataWrapperGenerator)2