use of java.net.http.HttpRequest in project jena by apache.
the class HttpOp method httpDelete.
/**
* DELETE
*/
public static void httpDelete(HttpClient httpClient, String url) {
URI uri = toRequestURI(url);
HttpRequest requestData = HttpLib.requestBuilderFor(url).DELETE().uri(uri).build();
HttpResponse<InputStream> response = execute(httpClient, requestData);
handleResponseNoBody(response);
}
use of java.net.http.HttpRequest in project jena by apache.
the class UpdateExecHTTP method executeUpdate.
private String executeUpdate(String requestURL, BodyPublisher body, String contentType) {
HttpRequest.Builder builder = HttpLib.requestBuilder(requestURL, httpHeaders, -1L, null);
builder = contentTypeHeader(builder, contentType);
HttpRequest request = builder.POST(body).build();
logUpdate(updateString, request);
HttpResponse<InputStream> response = HttpLib.execute(httpClient, request);
return handleResponseRtnString(response);
}
use of java.net.http.HttpRequest in project feign by OpenFeign.
the class Http2Client method execute.
@Override
public Response execute(Request request, Options options) throws IOException {
final HttpRequest httpRequest;
try {
httpRequest = newRequestBuilder(request, options).version(client.version()).build();
} catch (URISyntaxException e) {
throw new IOException("Invalid uri " + request.url(), e);
}
HttpClient clientForRequest = getOrCreateClient(options);
HttpResponse<byte[]> httpResponse;
try {
httpResponse = clientForRequest.send(httpRequest, BodyHandlers.ofByteArray());
} catch (final InterruptedException e) {
Thread.currentThread().interrupt();
throw new IOException("Invalid uri " + request.url(), e);
}
return toFeignResponse(request, httpResponse);
}
use of java.net.http.HttpRequest in project feign by OpenFeign.
the class Http2Client method execute.
@Override
public CompletableFuture<Response> execute(Request request, Options options, Optional<Object> requestContext) {
HttpRequest httpRequest;
try {
httpRequest = newRequestBuilder(request, options).build();
} catch (URISyntaxException e) {
throw new IllegalArgumentException("Invalid uri " + request.url(), e);
}
HttpClient clientForRequest = getOrCreateClient(options);
CompletableFuture<HttpResponse<byte[]>> future = clientForRequest.sendAsync(httpRequest, HttpResponse.BodyHandlers.ofByteArray());
return future.thenApply(httpResponse -> toFeignResponse(request, httpResponse));
}
use of java.net.http.HttpRequest in project neo4j by neo4j.
the class BoltIT method boltAddressShouldComeFromConnectorAdvertisedAddress.
@Test
public void boltAddressShouldComeFromConnectorAdvertisedAddress() throws Throwable {
// Given
String host = "neo4j.com";
startServerWithBoltEnabled(host, 9999, "localhost", 0);
HttpRequest request = HttpRequest.newBuilder(testWebContainer.getBaseUri()).GET().build();
// When
HttpResponse<String> response = newHttpClient().send(request, ofString());
// Then
Map<String, Object> map = JsonHelper.jsonToMap(response.body());
assertThat(String.valueOf(map.get("bolt_direct"))).contains("bolt://" + host + ":" + 9999);
}
Aggregations