/** * Performs a GET request to the specified URI. * * @param uri the URI to GET * @return the {@link ContentResponse} for the request * @see #GET(URI) */ public ContentResponse GET(String uri) throws InterruptedException, ExecutionException, TimeoutException { return GET(URI.create(uri)); }
/** * Performs a GET request to the specified URI. * * @param uri the URI to GET * @return the {@link ContentResponse} for the request * @see #GET(URI) */ public ContentResponse GET(String uri) throws InterruptedException, ExecutionException, TimeoutException { return GET(URI.create(uri)); }
/** * Performs a GET request to the specified URI. * * @param uri the URI to GET * @return the {@link ContentResponse} for the request * @throws InterruptedException if send threading has been interrupted * @throws ExecutionException the execution failed * @throws TimeoutException the send timed out * @see #GET(URI) */ public ContentResponse GET(String uri) throws InterruptedException, ExecutionException, TimeoutException { return GET(URI.create(uri)); }
public static Waiter waitFor(String name, URI url, long timeout, TimeUnit unit) { return new Waiter(name, client -> { try { client.GET(url); return true; } catch (InterruptedException e) { return true; // erg... really want to bubble this but can't } catch (Exception ex) { return false; } }, timeout, unit); } }
SslContextFactory sslContextFactory = new SslContextFactory(true); HTTP2Client http2Client = new HTTP2Client(); HttpClient httpClient = new HttpClient(new HttpClientTransportOverHTTP2(http2Client), sslContextFactory); httpClient.start(); ContentResponse response = httpClient.GET("https://ec2-52-57-54-142.eu-central-1.compute.amazonaws.com/");
// Setup and start HttpClient with HTTP/2 transport. HTTP2Client http2Client = new HTTP2Client(); SslContextFactory sslContextFactory = new SslContextFactory(); HttpClient httpClient = new HttpClient(new HttpClientTransportOverHTTP2(http2Client), sslContextFactory); httpClient.start(); // Make a request. ContentResponse response = httpClient.GET("https://webtide.com/");
// Setup. HTTP2Client http2Client = new HTTP2Client(); SslContextFactory sslContextFactory = new SslContextFactory(); HttpClient httpClient = new HttpClient(new HttpClientTransportOverHTTP2(http2Client), sslContextFactory); httpClient.start(); // Does webtide.com support HTTP/2 ? ContentResponse response = httpClient.GET("https://webtide.com/"); // No errors, yes it supports HTTP/2 !
public static void main(String args[]) throws Exception { HttpClientSocketFactory f = HttpClientSocketFactory.getDefaultInstance(); f.sslProviderClass = null; HttpClient c = f.getHttpClient(HttpType.HTTP); System.out.println(c.GET(args[0]).getContentAsString()); c.stop(); }
@Test public void shouldGetNonExistingValue() throws Exception { //when ContentResponse response = client.GET("http://localhost:" + restServer().getPort() + "/rest/default/nonExisting"); //then ResponseAssertion.assertThat(response).doesntExist(); }
public void performGets(int pertentageOfMisses, int numberOfGets, String existingKey, String nonExistingKey) throws Exception { Random r = ThreadLocalRandom.current(); for (int i = 0; i < numberOfGets; ++i) { String key = r.nextInt(100) < pertentageOfMisses ? nonExistingKey : existingKey; executorCompletionService.submit(() -> { if (http2) { FullHttpRequest getRequest = new DefaultFullHttpRequest(HTTP_1_1, GET, "/rest/default/" + key); nettyHttpClient.sendRequest(getRequest); } else { try { String scheme = usesTLS ? "https" : "http"; http1Client .GET(String.format("%s://localhost:%d/rest/%s/%s", scheme, port, "default", key)); } catch (Exception e) { throw new RuntimeException(e); } } return 1; }); } for (int i = 0; i < numberOfGets; ++i) { executorCompletionService.take().get(); } if (http2) { nettyHttpClient.getResponses(); } }
@Test public void testIncludeCipherEmpty() throws Exception { HttpServerConfig config = createHttpServerConfig() .setHttpsIncludedCipherSuites(" , "); NodeInfo nodeInfo = new NodeInfo("test"); HttpServerInfo httpServerInfo = new HttpServerInfo(config, nodeInfo); HttpServer server = createServer(nodeInfo, httpServerInfo, config); try { server.start(); URI httpsUri = httpServerInfo.getHttpsUri(); HttpClient httpClient = createClientIncludeCiphers(CIPHER_1); httpClient.GET(httpsUri); httpClient = createClientIncludeCiphers(CIPHER_2); httpClient.GET(httpsUri); httpClient = createClientIncludeCiphers(CIPHER_3); httpClient.GET(httpsUri); } finally { server.stop(); } }
@Test public void testIncludeCipherEmpty() throws Exception { HttpServerConfig config = createHttpServerConfig() .setHttpsExcludedCipherSuites("") .setHttpsIncludedCipherSuites(" , "); NodeInfo nodeInfo = new NodeInfo("test"); HttpServerInfo httpServerInfo = new HttpServerInfo(config, nodeInfo); HttpServer server = createServer(nodeInfo, httpServerInfo, config); try { server.start(); URI httpsUri = httpServerInfo.getHttpsUri(); HttpClient httpClient = createClientIncludeCiphers(CIPHER_1); httpClient.GET(httpsUri); httpClient = createClientIncludeCiphers(CIPHER_2); httpClient.GET(httpsUri); httpClient = createClientIncludeCiphers(CIPHER_3); httpClient.GET(httpsUri); } finally { server.stop(); } }
@Test public void testExcludedCipher() throws Exception { HttpServerConfig config = createHttpServerConfig() .setHttpsExcludedCipherSuites(CIPHER_1 + "," + CIPHER_2); NodeInfo nodeInfo = new NodeInfo("test"); HttpServerInfo httpServerInfo = new HttpServerInfo(config, nodeInfo); HttpServer server = createServer(nodeInfo, httpServerInfo, config); try { server.start(); URI httpsUri = httpServerInfo.getHttpsUri(); // should succeed because all ciphers accepted HttpClient httpClient = createClientIncludeCiphers(); httpClient.GET(httpsUri); httpClient = createClientIncludeCiphers(CIPHER_1, CIPHER_2); try { httpClient.GET(httpsUri); Assert.fail("SSL handshake should fail because client included only ciphers the server excluded"); } catch (ExecutionException e) { // expected } } finally { server.stop(); } }
@Test public void testExcludedCipher() throws Exception { HttpServerConfig config = createHttpServerConfig() .setHttpsExcludedCipherSuites(CIPHER_1 + "," + CIPHER_2); NodeInfo nodeInfo = new NodeInfo("test"); HttpServerInfo httpServerInfo = new HttpServerInfo(config, nodeInfo); HttpServer server = createServer(nodeInfo, httpServerInfo, config); try { server.start(); URI httpsUri = httpServerInfo.getHttpsUri(); // should succeed because all ciphers accepted HttpClient httpClient = createClientIncludeCiphers(); httpClient.GET(httpsUri); httpClient = createClientIncludeCiphers(CIPHER_1, CIPHER_2); try { httpClient.GET(httpsUri); fail("SSL handshake should fail because client included only ciphers the server excluded"); } catch (ExecutionException e) { // expected } } finally { server.stop(); } }
ContentResponse response1 = client.GET(url + "?action=init"); assertEquals(HttpServletResponse.SC_OK,response1.getStatus()); String sessionCookie = response1.getHeaders().get("Set-Cookie");
ContentResponse response = client.GET("http://localhost:" + port + "/mod/test?action=create");
ContentResponse response = client.GET("http://localhost:" + port + "/mod/test?action=create");
ContentResponse response = client.GET("http://localhost:" + port + "/mod/test?action=create");