Search in sources :

Example 26 with HttpClient

use of java.net.http.HttpClient in project jena by apache.

the class ExAuth03_UpdateExecutionPW method exampleUpdateAuthWithHttpClient.

// HttpClient
public static void exampleUpdateAuthWithHttpClient() {
    System.out.println();
    System.out.println("HttpClient + UpdateExecutionHTTP");
    Authenticator authenticator = AuthLib.authenticator("u", "p");
    HttpClient httpClient = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(10)).authenticator(authenticator).build();
    UpdateExecutionHTTP.service(dataURL).httpClient(httpClient).update("CLEAR ALL").execute();
}
Also used : HttpClient(java.net.http.HttpClient) Authenticator(java.net.Authenticator)

Example 27 with HttpClient

use of java.net.http.HttpClient in project jena by apache.

the class AbstractTestWebappAuth_JDK method withAuthJDK.

public static UpdateExecutionHTTP withAuthJDK(UpdateExecutionHTTPBuilder builder, String user, String passwd) {
    Authenticator authenticator = AuthLib.authenticator(user, passwd);
    HttpClient hc = HttpClient.newBuilder().authenticator(authenticator).build();
    return builder.httpClient(hc).build();
}
Also used : HttpClient(java.net.http.HttpClient) Authenticator(java.net.Authenticator)

Example 28 with HttpClient

use of java.net.http.HttpClient in project jena by apache.

the class GSP method PUT.

// /**
// * PUT the contents of a file using the filename extension to determine the
// * Content-Type to use if it is not already set.
// * <p>
// * Synonym for {@link #PUT(String)}.
// * <p>
// * This operation does not parse the file.
// * <p>
// * If the data may have quads (named graphs), use {@link #putDataset(String)}.
// */
// public void putGraph(String file) {
// // Synonym
// PUT(file);
// }
/**
 * PUT a graph.
 */
public void PUT(Graph graph) {
    validateGraphOperation();
    RDFFormat requestFmt = rdfFormat(HttpEnv.defaultTriplesFormat);
    String url = graphRequestURL();
    HttpClient hc = requestHttpClient(serviceEndpoint, url);
    HttpRDF.httpPutGraph(hc, url, graph, requestFmt, httpHeaders);
}
Also used : HttpClient(java.net.http.HttpClient) RDFFormat(org.apache.jena.riot.RDFFormat)

Example 29 with HttpClient

use of java.net.http.HttpClient in project jena by apache.

the class GSP method DELETE.

// /**
// * Put a graph - replace the previous contents.
// * <p>
// * Synonym for {@link #PUT(Graph)}.
// */
// public void putGraph(Graph graph) {
// // Synonym
// PUT(graph);
// }
/**
 * Delete a graph.
 */
public void DELETE() {
    validateGraphOperation();
    String url = graphRequestURL();
    HttpClient hc = requestHttpClient(serviceEndpoint, url);
    HttpRDF.httpDeleteGraph(hc, url);
}
Also used : HttpClient(java.net.http.HttpClient)

Example 30 with HttpClient

use of java.net.http.HttpClient in project jena by apache.

the class GSP method POST.

// /**
// * Load the contents of a file into the target graph using the filename extension to determine the
// * Content-Type to use if it is not already set.
// * <p>
// * Synonym for {@link #POST(String)}.
// * <p>
// * This operation does not parse the file.
// * <p>
// * If the data may have quads (named graphs), use {@link #postDataset(String)}.
// *
// */
// public void postGraph(String file) {
// POST(file);
// }
/**
 * POST a graph.
 */
public void POST(Graph graph) {
    validateGraphOperation();
    RDFFormat requestFmt = rdfFormat(HttpEnv.defaultTriplesFormat);
    String url = graphRequestURL();
    HttpClient hc = requestHttpClient(serviceEndpoint, url);
    HttpRDF.httpPostGraph(hc, url, graph, requestFmt, httpHeaders);
}
Also used : HttpClient(java.net.http.HttpClient) RDFFormat(org.apache.jena.riot.RDFFormat)

Aggregations

HttpClient (java.net.http.HttpClient)42 Authenticator (java.net.Authenticator)11 HttpRequest (java.net.http.HttpRequest)8 HttpResponse (java.net.http.HttpResponse)6 URI (java.net.URI)4 RDFConnection (org.apache.jena.rdfconnection.RDFConnection)4 RDFFormat (org.apache.jena.riot.RDFFormat)4 Context (org.apache.jena.sparql.util.Context)4 SerializedClassRunner (io.pravega.test.common.SerializedClassRunner)3 TestUtils (io.pravega.test.common.TestUtils)3 URISyntaxException (java.net.URISyntaxException)3 Duration (java.time.Duration)3 Pattern (java.util.regex.Pattern)3 GZIPInputStream (java.util.zip.GZIPInputStream)3 Cleanup (lombok.Cleanup)3 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)3 Assert.assertTrue (org.junit.Assert.assertTrue)3 Test (org.junit.Test)3 RunWith (org.junit.runner.RunWith)3 Counter (io.pravega.shared.metrics.Counter)2