/** * Create a new PUT request builder. The client name will be selected based * on a prefix of the host name. * * @param uri * URI to use for the request. * @return * Builder for creating and executing a request. */ default HttpRequestBuilder put(URI uri) { return newRequest(HttpUtils.clientNameForURI(uri), uri).withMethod("PUT"); }
@Test public void emptyChunked() throws IOException { HttpResponse res = HttpClient.DEFAULT .get(uri("/ok")) .addHeader("X-Status", "200") .addHeader("X-Length", "0") .send(); Assertions.assertEquals(200, res.status()); }
@Test public void okWithBody() throws IOException { HttpResponse res = HttpClient.DEFAULT .post(uri("/echo")) .addHeader("X-Status", "200") .withContent("text/plain", "foo") .send(); Assertions.assertEquals(200, res.status()); Assertions.assertEquals("foo", res.entityAsString()); }
@Test public void unavailableEmpty() throws IOException { HttpResponse res = HttpClient.DEFAULT .get(uri("/ok")) .addHeader("X-Status", "503") .addHeader("X-Length", "-1") .send(); Assertions.assertEquals(503, res.status()); }
@Test public void okWithCompressedBody() throws IOException { HttpResponse res = HttpClient.DEFAULT .post(uri("/echo")) .acceptGzip() .addHeader("X-Status", "200") .withContent("text/plain", "foo") .compress() .send() .decompress(); Assertions.assertEquals(200, res.status()); Assertions.assertEquals("foo", res.entityAsString()); } }
/** * Create a new GET request builder. The client name will be selected based * on a prefix of the host name. * * @param uri * URI to use for the request. * @return * Builder for creating and executing a request. */ default HttpRequestBuilder get(URI uri) { return newRequest(HttpUtils.clientNameForURI(uri), uri).withMethod("GET"); }
@Test public void ok() throws IOException { HttpResponse res = HttpClient.DEFAULT .get(uri("/ok")) .addHeader("X-Status", "200") .addHeader("X-Length", "-1") .send(); Assertions.assertEquals(200, res.status()); }
/** * Create a new POST request builder. The client name will be selected based * on a prefix of the host name. * * @param uri * URI to use for the request. * @return * Builder for creating and executing a request. */ default HttpRequestBuilder post(URI uri) { return newRequest(HttpUtils.clientNameForURI(uri), uri).withMethod("POST"); }
@Test public void unavailableEmptyChunked() throws IOException { HttpResponse res = HttpClient.DEFAULT .get(uri("/ok")) .addHeader("X-Status", "503") .addHeader("X-Length", "0") .send(); Assertions.assertEquals(503, res.status()); }
/** * Create a new POST request builder. The client name will be selected based * on a prefix of the host name. * * @param uri * URI to use for the request. * @return * Builder for creating and executing a request. */ default HttpRequestBuilder post(URI uri) { return newRequest(HttpUtils.clientNameForURI(uri), uri).withMethod("POST"); }
/** * Create a new GET request builder. The client name will be selected based * on a prefix of the host name. * * @param uri * URI to use for the request. * @return * Builder for creating and executing a request. */ default HttpRequestBuilder get(URI uri) { return newRequest(HttpUtils.clientNameForURI(uri), uri).withMethod("GET"); }
/** * Create a new PUT request builder. The client name will be selected based * on a prefix of the host name. * * @param uri * URI to use for the request. * @return * Builder for creating and executing a request. */ default HttpRequestBuilder put(URI uri) { return newRequest(HttpUtils.clientNameForURI(uri), uri).withMethod("PUT"); }
/** * Create a new DELETE request builder. The client name will be selected based * on a prefix of the host name. * * @param uri * URI to use for the request. * @return * Builder for creating and executing a request. */ default HttpRequestBuilder delete(URI uri) { return newRequest(HttpUtils.clientNameForURI(uri), uri).withMethod("DELETE"); } }
/** * Create a new DELETE request builder. The client name will be selected based * on a prefix of the host name. * * @param uri * URI to use for the request. * @return * Builder for creating and executing a request. */ default HttpRequestBuilder delete(URI uri) { return newRequest(HttpUtils.clientNameForURI(uri), uri).withMethod("DELETE"); } }
HttpClient.DEFAULT.newRequest("spectator-reg-atlas", URI.create(config.uri())) .withMethod("POST") .withConnectTimeout((int) config.connectTimeout().toMillis())