Search in sources :

Example 6 with Http2Socket

use of org.webpieces.http2client.api.Http2Socket in project webpieces by deanhiller.

the class TestC6_5SettingsFrameErrors method setUp.

@Before
public void setUp() throws InterruptedException, ExecutionException {
    mockChannel.setIncomingFrameDefaultReturnValue(CompletableFuture.completedFuture(mockChannel));
    Http2Config config = new Http2Config();
    //start with 1 max concurrent
    config.setInitialRemoteMaxConcurrent(1);
    config.setLocalSettings(localSettings);
    InjectionConfig injConfig = new InjectionConfig(mockTime, config);
    Http2Client client = Http2ClientFactory.createHttpClient(mockChanMgr, injConfig);
    mockChanMgr.addTCPChannelToReturn(mockChannel);
    socket = client.createHttpSocket("simple");
    CompletableFuture<Http2Socket> connect = socket.connect(new InetSocketAddress(555));
    Assert.assertTrue(connect.isDone());
    Assert.assertEquals(socket, connect.get());
    //clear preface and settings frame from client
    mockChannel.getFramesAndClear();
}
Also used : InetSocketAddress(java.net.InetSocketAddress) Http2Config(com.webpieces.http2engine.api.client.Http2Config) Http2Socket(org.webpieces.http2client.api.Http2Socket) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) Http2Client(org.webpieces.http2client.api.Http2Client) Before(org.junit.Before)

Example 7 with Http2Socket

use of org.webpieces.http2client.api.Http2Socket in project webpieces by deanhiller.

the class AbstractTest method setUp.

@Before
public void setUp() throws InterruptedException, ExecutionException {
    mockChannel.setIncomingFrameDefaultReturnValue(CompletableFuture.completedFuture(mockChannel));
    Http2Config config = new Http2Config();
    //start with 1 max concurrent
    config.setInitialRemoteMaxConcurrent(1);
    localSettings.setInitialWindowSize(localSettings.getMaxFrameSize() * 4);
    config.setLocalSettings(localSettings);
    InjectionConfig injConfig = new InjectionConfig(mockTime, config);
    Http2Client client = Http2ClientFactory.createHttpClient(mockChanMgr, injConfig);
    mockChanMgr.addTCPChannelToReturn(mockChannel);
    httpSocket = client.createHttpSocket("simple");
    CompletableFuture<Http2Socket> connect = httpSocket.connect(new InetSocketAddress(555));
    Assert.assertTrue(connect.isDone());
    Assert.assertEquals(httpSocket, connect.get());
    //clear preface and settings frame from client
    mockChannel.getFramesAndClear();
    //server's settings frame is finally coming in as well with maxConcurrent=1
    sendAndAckSettingsFrame(1);
}
Also used : InetSocketAddress(java.net.InetSocketAddress) Http2Config(com.webpieces.http2engine.api.client.Http2Config) Http2Socket(org.webpieces.http2client.api.Http2Socket) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) Http2Client(org.webpieces.http2client.api.Http2Client) Before(org.junit.Before)

Example 8 with Http2Socket

use of org.webpieces.http2client.api.Http2Socket in project webpieces by deanhiller.

the class IntegMultiThreaded method main.

public static void main(String[] args) throws InterruptedException {
    boolean isHttp = true;
    String path = "/";
    //String host = www.google.com; 
    //String host = "localhost"; //jetty
    String host = "nghttp2.org";
    int port = 443;
    if (isHttp)
        port = 80;
    if (host.equals("localhost")) {
        //IF jetty, use a path with a bigger download
        path = "/test/data.txt";
        port = 8443;
        if (isHttp)
            port = 8080;
    }
    List<Http2Header> req = createRequest(host, isHttp, path);
    log.info("starting socket");
    InetSocketAddress addr = new InetSocketAddress(host, port);
    Http2Socket socket = IntegSingleRequest.createHttpClient("clientSocket", isHttp, addr);
    socket.connect(addr).thenApply(s -> {
        for (int i = 0; i < 99; i += 100) {
            executor.execute(new WorkItem(socket, req, i, i));
        }
        return s;
    }).exceptionally(e -> {
        reportException(socket, e);
        return null;
    });
    Thread.sleep(100000000);
}
Also used : Logger(org.webpieces.util.logging.Logger) SortedSet(java.util.SortedSet) Executor(java.util.concurrent.Executor) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) CancelReason(com.webpieces.http2parser.api.dto.CancelReason) Http2Header(com.webpieces.http2parser.api.dto.lib.Http2Header) CompletableFuture(java.util.concurrent.CompletableFuture) InetSocketAddress(java.net.InetSocketAddress) TreeSet(java.util.TreeSet) Executors(java.util.concurrent.Executors) Http2HeaderName(com.webpieces.http2parser.api.dto.lib.Http2HeaderName) ArrayList(java.util.ArrayList) PushPromiseListener(com.webpieces.http2engine.api.PushPromiseListener) PushStreamHandle(com.webpieces.http2engine.api.PushStreamHandle) List(java.util.List) StreamWriter(com.webpieces.http2engine.api.StreamWriter) Http2Push(com.webpieces.hpack.api.dto.Http2Push) Http2Request(com.webpieces.hpack.api.dto.Http2Request) LoggerFactory(org.webpieces.util.logging.LoggerFactory) Http2Response(com.webpieces.hpack.api.dto.Http2Response) Http2Socket(org.webpieces.http2client.api.Http2Socket) ResponseHandler(com.webpieces.http2engine.api.ResponseHandler) InetSocketAddress(java.net.InetSocketAddress) Http2Header(com.webpieces.http2parser.api.dto.lib.Http2Header) Http2Socket(org.webpieces.http2client.api.Http2Socket)

Aggregations

Http2Socket (org.webpieces.http2client.api.Http2Socket)8 InetSocketAddress (java.net.InetSocketAddress)7 InjectionConfig (com.webpieces.http2engine.api.client.InjectionConfig)6 Http2Client (org.webpieces.http2client.api.Http2Client)6 Http2Config (com.webpieces.http2engine.api.client.Http2Config)4 Before (org.junit.Before)4 Http2Push (com.webpieces.hpack.api.dto.Http2Push)3 Http2Request (com.webpieces.hpack.api.dto.Http2Request)3 Http2Response (com.webpieces.hpack.api.dto.Http2Response)3 PushPromiseListener (com.webpieces.http2engine.api.PushPromiseListener)3 PushStreamHandle (com.webpieces.http2engine.api.PushStreamHandle)3 ResponseHandler (com.webpieces.http2engine.api.ResponseHandler)3 StreamWriter (com.webpieces.http2engine.api.StreamWriter)3 CancelReason (com.webpieces.http2parser.api.dto.CancelReason)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 Executor (java.util.concurrent.Executor)3 SSLEngine (javax.net.ssl.SSLEngine)3 Logger (org.webpieces.util.logging.Logger)3 LoggerFactory (org.webpieces.util.logging.LoggerFactory)3 NamedThreadFactory (org.webpieces.util.threading.NamedThreadFactory)3