use of org.webpieces.httpclient11.api.HttpSocket in project webpieces by deanhiller.
the class BasicStartWithNoHttps method testNoHttps.
@Test
public void testNoHttps() throws InterruptedException, ExecutionException, TimeoutException {
String[] arguments = new String[] { "-http.port=:0", "-https.port=" };
PrivateWebserverForTest webserver = new PrivateWebserverForTest(getOverrides(false, new SimpleMeterRegistry()), null, null, arguments);
webserver.start();
// connecting http still works
HttpSocket http11Socket = connectHttp(false, webserver.getUnderlyingHttpChannel().getLocalAddress());
// https has no channel in webserver
Assert.assertNull(webserver.getUnderlyingHttpsChannel());
}
use of org.webpieces.httpclient11.api.HttpSocket in project webpieces by deanhiller.
the class Http2ClientProxy method createHttpsSocket.
@Override
public Http2Socket createHttpsSocket(SSLEngine engine, Http2SocketListener listener) {
Http11CloseListener http11Listener = new Http11CloseListener(listener);
HttpSocket socket11 = client11.createHttpsSocket(engine, http11Listener);
Http2SocketImpl http2Socket = new Http2SocketImpl(socket11);
http11Listener.setHttp2Socket(http2Socket);
return http2Socket;
}
use of org.webpieces.httpclient11.api.HttpSocket in project webpieces by deanhiller.
the class IntegGoogleHttps method createSocket.
public static HttpSocket createSocket(boolean isHttp, String host, int port) {
HttpClient client = createHttpClient();
HttpSocket socket;
if (isHttp)
socket = client.createHttpSocket(new SocketListener());
else {
ForTestSslClientEngineFactory sslFactory = new ForTestSslClientEngineFactory();
socket = client.createHttpsSocket(sslFactory.createSslEngine(host, port), new SocketListener());
}
return socket;
}
use of org.webpieces.httpclient11.api.HttpSocket in project webpieces by deanhiller.
the class TestLesson7AdvancedCookiesCrud method setUp.
@Before
public void setUp() throws InterruptedException, ClassNotFoundException, ExecutionException, TimeoutException {
log.info("Setting up test");
Asserts.assertWasCompiledWithParamNames("test");
// clear in-memory database
jdbc.dropAllTablesFromDatabase();
SimpleMeterRegistry metrics = new SimpleMeterRegistry();
// you may want to create this server ONCE in a static method BUT if you do, also remember to clear out all your
// mocks after every test AND you can no longer run single threaded(tradeoffs, tradeoffs)
// This is however pretty fast to do in many systems...
Server webserver = new Server(getOverrides(metrics), null, new ServerConfig(JavaCache.getCacheLocation()), args);
webserver.start();
HttpSocket https11Socket = connectHttps(null, webserver.getUnderlyingHttpChannel().getLocalAddress());
webBrowser = new WebBrowserSimulator(https11Socket);
}
use of org.webpieces.httpclient11.api.HttpSocket in project webpieces by deanhiller.
the class AbstractWebpiecesTest method connectHttps.
public HttpSocket connectHttps(SSLEngine engine, InetSocketAddress addr, HttpSocketListener listener) {
if (listener == null)
listener = new NullHttp1CloseListener();
HttpSocket socket = getClient().createHttpsSocket(engine, listener);
XFuture<Void> connect = socket.connect(addr);
try {
connect.get(2, TimeUnit.SECONDS);
return socket;
} catch (InterruptedException | ExecutionException | TimeoutException e) {
throw SneakyThrow.sneak(e);
}
}
Aggregations