use of java.net.http.HttpRequest.BodyPublisher in project jena by apache.
the class TestWebappServerReadOnly method dataset_w_readonly_POST.
@Test
public void dataset_w_readonly_POST() {
// Try to write
HttpTest.execWithHttpException(HttpSC.METHOD_NOT_ALLOWED_405, () -> {
BodyPublisher bodyPublisher = BodyPublishers.ofString("");
HttpOp.httpPost(ServerCtl.urlDataset(), null, bodyPublisher);
});
}
use of java.net.http.HttpRequest.BodyPublisher in project jena by apache.
the class TestAdmin method addTestDataset.
private static void addTestDataset(String filename) {
try {
Path f = Path.of(filename);
BodyPublisher body = BodyPublishers.ofFile(f);
String ct = WebContent.contentTypeTurtle;
httpPost(ServerCtl.urlRoot() + "$/" + opDatasets, ct, body);
} catch (FileNotFoundException e) {
IO.exception(e);
}
}
use of java.net.http.HttpRequest.BodyPublisher in project feign by OpenFeign.
the class Http2Client method newRequestBuilder.
private Builder newRequestBuilder(Request request, Options options) throws URISyntaxException {
URI uri = new URI(request.url());
final BodyPublisher body;
final byte[] data = request.body();
if (data == null) {
body = BodyPublishers.noBody();
} else {
body = BodyPublishers.ofByteArray(data);
}
final Builder requestBuilder = HttpRequest.newBuilder().uri(uri).timeout(Duration.ofMillis(options.readTimeoutMillis())).version(client.version());
final Map<String, Collection<String>> headers = filterRestrictedHeaders(request.headers());
if (!headers.isEmpty()) {
requestBuilder.headers(asString(headers));
}
switch(request.httpMethod()) {
case GET:
return requestBuilder.GET();
case POST:
return requestBuilder.POST(body);
case PUT:
return requestBuilder.PUT(body);
case DELETE:
return requestBuilder.DELETE();
default:
// fall back scenario, http implementations may restrict some methods
return requestBuilder.method(request.httpMethod().toString(), body);
}
}
use of java.net.http.HttpRequest.BodyPublisher in project jena by apache.
the class HttpRDF method httpPutGraph.
public static void httpPutGraph(HttpClient httpClient, String url, Graph graph, RDFFormat format, Map<String, String> httpHeaders) {
BodyPublisher bodyPublisher = graphToHttpBody(graph, format);
pushBody(httpClient, url, Push.PUT, bodyPublisher, format, httpHeaders);
}
use of java.net.http.HttpRequest.BodyPublisher in project jena by apache.
the class HttpRDF method httpPostDataset.
public static void httpPostDataset(HttpClient httpClient, String url, DatasetGraph dataset, RDFFormat format, Map<String, String> httpHeaders) {
BodyPublisher bodyPublisher = datasetToHttpBody(dataset, format);
pushBody(httpClient, url, Push.POST, bodyPublisher, format, httpHeaders);
}
Aggregations