You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@jena.apache.org by "Aklakan (via GitHub)" <gi...@apache.org> on 2025/09/15 23:38:18 UTC
[PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Aklakan opened a new pull request, #3441:
URL: https://github.com/apache/jena/pull/3441
GitHub issue resolved (Can create one if desired)
Pull request Description: Headers configured on `RDFConnectionRemoteBuilder` were not passed on to the created `QueryExecHTTPBuilder` instances when parseCheck was disabled. For example, setting the select-header to thrift on a connection to DBpedia would unexpectedly work - although DBpedia (so far) does not support this content type.
* Added "set-acceptHeader" methods to `QueryExecHTTPBuilder`. Headers are on response format level - e.g. one graph header for describe, construct and GSP GET. If desired, fine grained setters for each aspect could be added.
* `RDFConnectionRemoteBuilder` initializes created `QueryExecHTTPBuilder` instances with its headers.
* Added `QueryExecHTTP.getAcceptHeader` methods to inspect the headers for the query types.
Unrelated minor fix: Quad.isConcrete() would raise NPE if the graph was null ("true triple in quad").
----
- [x] Tests are included.
- [x] Commits have been squashed to remove intermediate development commit messages.
- [ ] Key commit messages start with the issue number (GH-xxxx)
By submitting this pull request, I acknowledge that I am making a contribution to the Apache Software Foundation under the terms and conditions of the [Contributor's Agreement](https://www.apache.org/licenses/contributor-agreements.html).
----
See the [Apache Jena "Contributing" guide](https://github.com/apache/jena/blob/main/CONTRIBUTING.md).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2356772627
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -316,53 +312,54 @@ protected void setQuery(Query query, String queryStr) {
queryType = query == null ? QueryType.UNKNOWN : query.queryType();
}
+ /**
+ * For parsed queries: Derive and return the appropriate accept header.
+ * For non-parsed queries: This method returns null. The header is then chosen
+ * based on the used method of the query exec. For example,
+ * {@link QueryExecHTTP#select()} will use the configured select header.
+ */
+ private String deriveAcceptHeaderFromQueryType() {
Review Comment:
Removed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386339028
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
The QueryType may not be particularly useful in this impl
The main reason is that I though that `QueryExecBuilder` should be the single point of truth, and logic outside of it should be avoided:
Having query type handling here seems to add needless complexity because these methods are mostly shortcuts to `QueryExecBuilder` (plus transaction wrapping). `QueryExecBuilder` does not have an API to which the query type can be passed, and in these specific cases, the `QueryExec` created by the `QueryExecBuilder` attempts to execute the string with a certain query type just one line below - so it felt redundant.
Of course, if you prefer I can restore this. Alternatively, `QueryExecBuilder` could receive query(queryString, queryType) method variants - but again the use might be limited. It would allow for `QueryExec` to check whether a called exec method, such as ask(), is consistent with the set query type prior to actually sending an e.g. remote request. But one would then always have to supply query strings with query types and in case of an inconsistency, there would be an eventual failure anyway.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389261302
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTPHeaders.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.rdfconnection;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.jena.query.QueryExecution;
+import org.apache.jena.sparql.exec.QueryExec;
+import org.apache.jena.sparql.exec.http.QueryExecHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTPBuilder;
+import org.junit.jupiter.api.Test;
+
+public class TestRDFConnectionHTTPHeaders {
+
+ /**
+ * Test whether connection headers are properly passed on to the query execution.
+ * No query is actually executed.
+ */
+ @Test void test_headers_non_parsed() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderSelectQuery("s")
+ .acceptHeaderAskQuery("a")
+ .acceptHeaderGraph("g")
+ .acceptHeaderDataset("d")
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("s", qe.getAcceptHeaderSelect());
+ assertEquals("a", qe.getAcceptHeaderAsk());
+ assertEquals("g", qe.getAcceptHeaderDescribe());
+ assertEquals("g", qe.getAcceptHeaderConstructGraph());
+ assertEquals("d", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ @Test void test_headers_non_parsed_fallback() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("f", qe.getAcceptHeaderSelect());
+ assertEquals("f", qe.getAcceptHeaderAsk());
+ assertEquals("f", qe.getAcceptHeaderDescribe());
+ assertEquals("f", qe.getAcceptHeaderConstructGraph());
+ assertEquals("f", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ @Test void test_headers_parsed_fallback() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
+ .build()) {
+
+ try (QueryExecution qExec = conn.newQuery()
+ .query("SELECT * { ?s ?p ?o }")
+ .build()) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("f", qe.getAcceptHeaderSelect());
+
+ assertEquals("f", qe.getAcceptHeaderAsk());
+ assertEquals("f", qe.getAcceptHeaderDescribe());
+ assertEquals("f", qe.getAcceptHeaderConstructGraph());
+ assertEquals("f", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ /**
+ * Setting an override-header on the builder should set all
+ * headers on the QueryExecHTTP instance to that override.
+ */
+ @Test
+ public void test_override_header() {
+ try (QueryExecutionHTTP qExec =
+ QueryExecutionHTTPBuilder.create()
+ .endpoint("urn:dummy-service")
+ .queryString("SELECT * { ?s ?p ?o }")
+ .acceptHeader("o") // Override header
+ .build()) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("o", qe.getAppProvidedAcceptHeader());
+ assertEquals("o", qe.getAcceptHeaderSelect());
+ assertEquals("o", qe.getAcceptHeaderAsk());
+ assertEquals("o", qe.getAcceptHeaderDescribe());
+ assertEquals("o", qe.getAcceptHeaderConstructGraph());
+ assertEquals("o", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+}
Review Comment:
Added as `TestRDFConnectionHTTPHeaders.test_override_header_02`.
Note: Order matters:
```
.acceptHeaderAskQuery("a")
.acceptHeader("o") // Sets everything to "o" and thus overrides the prior setting for "a".
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2355482782
##########
jena-examples/src/main/java/rdfconnection/examples/RDFConnectionExampleDBpedia01.java:
##########
@@ -0,0 +1,55 @@
+package rdfconnection.examples;
+
+import java.util.List;
+
+import org.apache.jena.query.QueryExecution;
+import org.apache.jena.query.ResultSet;
+import org.apache.jena.query.ResultSetFormatter;
+import org.apache.jena.rdfconnection.RDFConnection;
+import org.apache.jena.rdfconnection.RDFConnectionRemote;
+import org.apache.jena.riot.WebContent;
+import org.apache.jena.sparql.resultset.ResultsFormat;
+
+/**
+ * Example that showcases querying DBpedia with disabled parse check and
+ * different accept headers.
+ * <p>
+ *
+ * The expected output should be similar to this snippet:
+ * <pre>
+ * Trying to query with content type: application/sparql-results+thrift
+ * Request failed: Not Acceptable
+ *
+ * Trying to query with content type: application/sparql-results+json
+ * -------------------------
+ * | l |
+ * =========================
+ * | "Jena (Framework)"@de |
+ * -------------------------<
Review Comment:
```suggestion
* -------------------------
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386339028
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
The QueryType may not be particularly useful in this impl
The main reason is that I though that `QueryExecBuilder` should be the single point of truth, and logic outside of it should be avoided:
Having query type handling here seems to add needless complexity because these methods are mostly shortcuts to QueryExecBuilder (plus transaction wrapping). QueryExecBuilder does not have an API to which the query type can be passed, and in these specific cases, the QueryExec created by the QueryExecBuilder attempts to execute the string with a certain query type just one line below - so it felt redundant.
Of course, if you prefer I can restore this. Alternatively, QueryExecBuilder could receive query(queryString, queryType) method variants - but again the use might be limited. It would allow for QueryExec to check whether a called exec method, such as ask(), is consistent with the set query type prior to actually sending an e.g. remote request. But one would then always have to supply query strings with query types and in case of an inconsistency, there would be an eventual failure anyway.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386339028
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
> The QueryType may not be particularly useful in this impl
The main reason is that I though that `QueryExecBuilder` should be the single point of truth, and logic outside of it should be avoided. `QueryExecBuilder` does not have an API to which the query type can be passed, and in these specific cases, the `QueryExec` created by the `QueryExecBuilder` attempts to execute the string with a certain query type just one line below - so it felt redundant.
Of course, one could argue that e.g. in the future `QueryExecBuilder` could receive e.g. `query(queryString, queryType)` method variants. Then the query type here could eventually be passed to the extended builders. But as these specific methods are shortcuts with consistent use - the appropriate exec method, such as `.ask()` is just one line below - it wouldn't add anything here.
So I couldn't find good arguments for why to have this extra complexity in the shortcuts.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386170343
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTPHeaders.java:
##########
Review Comment:
Add to `TS_RDFConnection`.
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTP.java:
##########
@@ -1,99 +0,0 @@
-/*
Review Comment:
Where did the tests from this class go to?
(It should have been added to `TS_RDFConnection` when added.)
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
Could you say which this change is in the PR? The `QueryType` may no tbe partiucaly useful in this impl but when inheriited it might be useful.
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdflink/TestRDFLinkHTTPHeaders.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.rdflink;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.jena.sparql.exec.http.QueryExecHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecHTTPBuilder;
+import org.junit.jupiter.api.Test;
+
+public class TestRDFLinkHTTPHeaders {
Review Comment:
I don't see any tests for `acceptHeaderQuery`.
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdflink/TestRDFLinkHTTPHeaders.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.rdflink;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.jena.sparql.exec.http.QueryExecHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecHTTPBuilder;
+import org.junit.jupiter.api.Test;
+
+public class TestRDFLinkHTTPHeaders {
Review Comment:
Add to `TS_RDFLink` please.
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTPHeaders.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.rdfconnection;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.jena.query.QueryExecution;
+import org.apache.jena.sparql.exec.QueryExec;
+import org.apache.jena.sparql.exec.http.QueryExecHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTPBuilder;
+import org.junit.jupiter.api.Test;
+
+public class TestRDFConnectionHTTPHeaders {
+
+ /**
+ * Test whether connection headers are properly passed on to the query execution.
+ * No query is actually executed.
+ */
+ @Test void test_headers_non_parsed() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderSelectQuery("s")
+ .acceptHeaderAskQuery("a")
+ .acceptHeaderGraph("g")
+ .acceptHeaderDataset("d")
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("s", qe.getAcceptHeaderSelect());
+ assertEquals("a", qe.getAcceptHeaderAsk());
+ assertEquals("g", qe.getAcceptHeaderDescribe());
+ assertEquals("g", qe.getAcceptHeaderConstructGraph());
+ assertEquals("d", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ @Test void test_headers_non_parsed_fallback() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("f", qe.getAcceptHeaderSelect());
+ assertEquals("f", qe.getAcceptHeaderAsk());
+ assertEquals("f", qe.getAcceptHeaderDescribe());
+ assertEquals("f", qe.getAcceptHeaderConstructGraph());
+ assertEquals("f", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ @Test void test_headers_parsed_fallback() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
+ .build()) {
+
+ try (QueryExecution qExec = conn.newQuery()
+ .query("SELECT * { ?s ?p ?o }")
+ .build()) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("f", qe.getAcceptHeaderSelect());
+
+ assertEquals("f", qe.getAcceptHeaderAsk());
+ assertEquals("f", qe.getAcceptHeaderDescribe());
+ assertEquals("f", qe.getAcceptHeaderConstructGraph());
+ assertEquals("f", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ /**
+ * Setting an override-header on the builder should set all
+ * headers on the QueryExecHTTP instance to that override.
+ */
+ @Test
+ public void test_override_header() {
+ try (QueryExecutionHTTP qExec =
+ QueryExecutionHTTPBuilder.create()
+ .endpoint("urn:dummy-service")
+ .queryString("SELECT * { ?s ?p ?o }")
+ .acceptHeader("o") // Override header
+ .build()) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("o", qe.getAppProvidedAcceptHeader());
+ assertEquals("o", qe.getAcceptHeaderSelect());
+ assertEquals("o", qe.getAcceptHeaderAsk());
+ assertEquals("o", qe.getAcceptHeaderDescribe());
+ assertEquals("o", qe.getAcceptHeaderConstructGraph());
+ assertEquals("o", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+}
Review Comment:
There is a missing test:
```
.acceptHeader("o")
.acceptHeaderAskQuery("a")
```
which I would expect to set just the ASK query type to "a" and leave everything else as "o"
##########
jena-arq/src/main/java/org/apache/jena/sparql/exec/http/QueryExecHTTP.java:
##########
@@ -119,10 +117,28 @@ public static QueryExecHTTPBuilder service(String serviceURL) {
private HttpClient httpClient = HttpEnv.getDftHttpClient();
private Map<String, String> httpHeaders;
+ public QueryExecHTTP(String serviceURL, Query query, String queryString, int urlLimit,
Review Comment:
`public` does not like it is necessary
So Jena6, shall we make it `protected` and have only one constructor.
If so, add `@Deprecated` with a javadoc comment saying the constructor will become protected on both constructors.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on PR #3441:
URL: https://github.com/apache/jena/pull/3441#issuecomment-3344080243
> I created issue #3475 for this.
> Could it be a separate commit in this PR please?
Done with https://github.com/apache/jena/pull/3476
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386339028
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
> The QueryType may not be particularly useful in this impl
That was my main reason, and I doubted that there are good reasons for an override: Having query type handling here seems to add needless complexity because these methods are mostly shortcuts to `QueryExecBuilder` (plus transaction wrapping). `QueryExecBuilder` does not have an API to which the query type can be passed, and in these specific cases, the `QueryExec` created by the `QueryExecBuilder` performs the check of the query type just one line below - so it felt redundant.
Of course, if you prefer I can restore this. Alternatively, `QueryExecBuilder` could receive `query(queryString, queryType)` method variants - but again the use might be limited. It would allow for `QueryExec` to check whether a called exec method, such as `ask()`, is consistent with the set query type prior to actually sending an e.g. remote request. But in case of an inconsistency, there would most likely be an eventually failure anyway.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389261302
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTPHeaders.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.rdfconnection;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.jena.query.QueryExecution;
+import org.apache.jena.sparql.exec.QueryExec;
+import org.apache.jena.sparql.exec.http.QueryExecHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTPBuilder;
+import org.junit.jupiter.api.Test;
+
+public class TestRDFConnectionHTTPHeaders {
+
+ /**
+ * Test whether connection headers are properly passed on to the query execution.
+ * No query is actually executed.
+ */
+ @Test void test_headers_non_parsed() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderSelectQuery("s")
+ .acceptHeaderAskQuery("a")
+ .acceptHeaderGraph("g")
+ .acceptHeaderDataset("d")
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("s", qe.getAcceptHeaderSelect());
+ assertEquals("a", qe.getAcceptHeaderAsk());
+ assertEquals("g", qe.getAcceptHeaderDescribe());
+ assertEquals("g", qe.getAcceptHeaderConstructGraph());
+ assertEquals("d", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ @Test void test_headers_non_parsed_fallback() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("f", qe.getAcceptHeaderSelect());
+ assertEquals("f", qe.getAcceptHeaderAsk());
+ assertEquals("f", qe.getAcceptHeaderDescribe());
+ assertEquals("f", qe.getAcceptHeaderConstructGraph());
+ assertEquals("f", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ @Test void test_headers_parsed_fallback() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
+ .build()) {
+
+ try (QueryExecution qExec = conn.newQuery()
+ .query("SELECT * { ?s ?p ?o }")
+ .build()) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("f", qe.getAcceptHeaderSelect());
+
+ assertEquals("f", qe.getAcceptHeaderAsk());
+ assertEquals("f", qe.getAcceptHeaderDescribe());
+ assertEquals("f", qe.getAcceptHeaderConstructGraph());
+ assertEquals("f", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ /**
+ * Setting an override-header on the builder should set all
+ * headers on the QueryExecHTTP instance to that override.
+ */
+ @Test
+ public void test_override_header() {
+ try (QueryExecutionHTTP qExec =
+ QueryExecutionHTTPBuilder.create()
+ .endpoint("urn:dummy-service")
+ .queryString("SELECT * { ?s ?p ?o }")
+ .acceptHeader("o") // Override header
+ .build()) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("o", qe.getAppProvidedAcceptHeader());
+ assertEquals("o", qe.getAcceptHeaderSelect());
+ assertEquals("o", qe.getAcceptHeaderAsk());
+ assertEquals("o", qe.getAcceptHeaderDescribe());
+ assertEquals("o", qe.getAcceptHeaderConstructGraph());
+ assertEquals("o", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+}
Review Comment:
Added as `TestRDFConnectionHTTPHeaders.test_override_header_02`.
Note: Order matters:
```
.acceptHeaderAskQuery("a")
.acceptHeader("o") // Sets everything to "o" -> overrides setting for "a".
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389221931
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTPHeaders.java:
##########
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.rdfconnection;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.jena.query.QueryExecution;
+import org.apache.jena.sparql.exec.QueryExec;
+import org.apache.jena.sparql.exec.http.QueryExecHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTPBuilder;
+import org.junit.jupiter.api.Test;
+
+public class TestRDFConnectionHTTPHeaders {
+
+ /**
+ * Test whether connection headers are properly passed on to the query execution.
+ * No query is actually executed.
+ */
+ @Test void test_headers_non_parsed() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderSelectQuery("s")
+ .acceptHeaderAskQuery("a")
+ .acceptHeaderGraph("g")
+ .acceptHeaderDataset("d")
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("s", qe.getAcceptHeaderSelect());
+ assertEquals("a", qe.getAcceptHeaderAsk());
+ assertEquals("g", qe.getAcceptHeaderDescribe());
+ assertEquals("g", qe.getAcceptHeaderConstructGraph());
+ assertEquals("d", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ @Test void test_headers_non_parsed_fallback() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
Review Comment:
There are `acceptHeaderQuery` tests are in RDF**Connection**HTTPHeaders - if desired, they could be duplicated for the RDFLink level.
Note: The comment on the field `acceptSparqlResults` originally read:
> // All purpose SPARQL results header used if above specific cases do not apply.
So I interpreted this as a fallback. An alternative interpretation is that this sets *all* SPARQL query headers similar to `QueryExecHTTPBuilder.acceptHeader(headerString)`. In that case, separate SPARQL-only fields should be introduced that are not shared with GSP. `acceptHeaderQuery` would then set the fields for sparql graph results (construct and describe) but not for GSP retrieval.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386339028
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
> The QueryType may not be particularly useful in this impl
That was my main reason, and I doubted that there are good reasons for an override: Having query type handling here seems to add needless complexity because these methods are mostly shortcuts for `QueryExecBuilder` (plus transaction wrapping). `QueryExecBuilder` does not have an API to which the query type can be passed, and in this specific cases, the `QueryExec` created by the `QueryExecBuilder` performs the check of the query type just one line below - so it felt redundant.
Of course, if you prefer I can restore this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2356688273
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTP.java:
##########
@@ -20,80 +20,176 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.jupiter.api.Test;
-
-import org.apache.jena.query.Query;
import org.apache.jena.query.QueryExecution;
-import org.apache.jena.query.QueryFactory;
-import org.apache.jena.riot.WebContent;
+import org.apache.jena.rdflink.RDFLink;
+import org.apache.jena.rdflink.RDFLinkHTTP;
import org.apache.jena.sparql.exec.QueryExec;
import org.apache.jena.sparql.exec.http.QueryExecHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecHTTPBuilder;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTPBuilder;
+import org.junit.jupiter.api.Test;
public class TestRDFConnectionHTTP {
- @Test
- public void test_select_01() {
- doAssert(WebContent.contentTypeXML, "SELECT * { ?s a ?o } LIMIT 10");
- }
-
- @Test
- public void test_ask_01() {
- doAssert(WebContent.contentTypeJSON, "ASK { ?s a ?o }");
+ /**
+ * Test whether connection headers are properly passed on to the query execution.
+ * No query is actually executed.
+ */
+ @Test void test_headers_non_parsed() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderSelectQuery("s")
+ .acceptHeaderAskQuery("a")
+ .acceptHeaderGraph("g")
+ .acceptHeaderDataset("d")
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+
+ assertEquals("s", qe.getAcceptHeaderSelect());
+ assertEquals("a", qe.getAcceptHeaderAsk());
+ assertEquals("g", qe.getAcceptHeaderDescribe());
+ assertEquals("g", qe.getAcceptHeaderConstructGraph());
+ assertEquals("d", qe.getAcceptHeaderConstructDataset());
+ }
+ }
}
- @Test
- public void test_constructTriples_01() {
- doAssert(WebContent.contentTypeTurtle, "CONSTRUCT WHERE { ?s a ?o } LIMIT 10");
+ @Test void test_headers_non_parsed_fallback() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+
+ assertEquals("f", qe.getAcceptHeaderSelect());
+ assertEquals("f", qe.getAcceptHeaderAsk());
+ assertEquals("f", qe.getAcceptHeaderDescribe());
+ assertEquals("f", qe.getAcceptHeaderConstructGraph());
+ assertEquals("f", qe.getAcceptHeaderConstructDataset());
+ }
+ }
}
- @Test
- public void test_constructQuads_01() {
- doAssert(WebContent.contentTypeTriG, "CONSTRUCT WHERE { GRAPH ?g{ ?s a ?o } } LIMIT 10");
- }
+ /**
+ * Test whether connection headers are properly passed on to the query execution.
+ * No query is actually executed.
+ */
+ @Test void test_headers_parsed() {
+ try (RDFLink conn = RDFLinkHTTP.service("urn:dummy-service")
+ .acceptHeaderSelectQuery("s")
+ .acceptHeaderAskQuery("a")
+ .acceptHeaderGraph("g")
+ .acceptHeaderDataset("d")
+ .build()) {
+
+ try (QueryExecHTTP qe = ((QueryExecHTTPBuilder)conn.newQuery())
+ .query("SELECT * { ?s ?p ?o }")
+ .acceptHeaderSelectQuery("x").build()) {
+ assertEquals("x", qe.getAcceptHeaderSelect());
+
+ assertEquals("a", qe.getAcceptHeaderAsk());
+ assertEquals("g", qe.getAcceptHeaderDescribe());
+ assertEquals("g", qe.getAcceptHeaderConstructGraph());
+ assertEquals("d", qe.getAcceptHeaderConstructDataset());
+ }
- @Test
- public void test_describe_01() {
- doAssert(WebContent.contentTypeNTriples, "DESCRIBE <urn:x>");
- }
+ try (QueryExecHTTP qe = ((QueryExecHTTPBuilder)conn.newQuery())
+ .query("ASK { ?s ?p ?o }")
+ .acceptHeaderAskQuery("x").build()) {
+ assertEquals("x", qe.getAcceptHeaderAsk());
- private static RDFConnectionRemoteBuilder configureHeader(Query query, String header, RDFConnectionRemoteBuilder builder) {
- return switch (query.queryType()) {
- case SELECT -> builder.acceptHeaderSelectQuery(header);
- case CONSTRUCT -> !query.isConstructQuad()
- ? builder.acceptHeaderGraph(header)
- : builder.acceptHeaderDataset(header);
- case DESCRIBE -> builder.acceptHeaderGraph(header);
- case ASK -> builder.acceptHeaderAskQuery(header);
- default -> throw new UnsupportedOperationException("Unhandled query type for query: " + query);
- };
- }
+ assertEquals("s", qe.getAcceptHeaderSelect());
+ assertEquals("g", qe.getAcceptHeaderDescribe());
+ assertEquals("g", qe.getAcceptHeaderConstructGraph());
+ assertEquals("d", qe.getAcceptHeaderConstructDataset());
+ }
- /** Test whether the constructed QueryExec instance has the expected HTTP header set */
- private static void doAssert(String expectedHeader, String queryString) {
- Query query = QueryFactory.create(queryString);
+ try (QueryExecHTTP qe = ((QueryExecHTTPBuilder)conn.newQuery())
+ .query("DESCRIBE <urn:x>")
+ .acceptHeaderGraph("x").build()) {
+ assertEquals("x", qe.getAcceptHeaderDescribe());
+ assertEquals("x", qe.getAcceptHeaderConstructGraph());
- try (RDFConnection conn = configureHeader(query, expectedHeader, RDFConnectionRemote.newBuilder())
- .queryEndpoint("https://www.example.org/sparql") // Should never be resolved
- .build()) {
- try (QueryExecution qe = conn.query(queryString)) {
- QueryExecHTTP qeh = (QueryExecHTTP)QueryExec.adapt(qe);
- assertEquals(expectedHeader, qeh.getAppProvidedAcceptHeader());
+ assertEquals("s", qe.getAcceptHeaderSelect());
+ assertEquals("a", qe.getAcceptHeaderAsk());
+ assertEquals("d", qe.getAcceptHeaderConstructDataset());
}
- try (QueryExecution qe = conn.newQuery().query(queryString).build()) {
- QueryExecHTTP qeh = (QueryExecHTTP)QueryExec.adapt(qe);
- assertEquals(expectedHeader, qeh.getAppProvidedAcceptHeader());
+ try (QueryExecHTTP qe = ((QueryExecHTTPBuilder)conn.newQuery())
+ .query("CONSTRUCT WHERE { ?s ?p ?o }")
+ .acceptHeaderGraph("x").build()) {
+ assertEquals("x", qe.getAcceptHeaderConstructGraph());
+ assertEquals("x", qe.getAcceptHeaderDescribe());
+
+ assertEquals("s", qe.getAcceptHeaderSelect());
+ assertEquals("a", qe.getAcceptHeaderAsk());
+ assertEquals("d", qe.getAcceptHeaderConstructDataset());
}
- try (QueryExecution qe = conn.query(query)) {
- QueryExecHTTP qeh = (QueryExecHTTP)QueryExec.adapt(qe);
- assertEquals(expectedHeader, qeh.getAppProvidedAcceptHeader());
+ try (QueryExecHTTP qe = ((QueryExecHTTPBuilder)conn.newQuery())
+ .query("CONSTRUCT WHERE { GRAPH ?g { ?s ?p ?o } }")
+ .acceptHeaderDataset("x").build()) {
+ assertEquals("x", qe.getAcceptHeaderConstructDataset());
+
+ assertEquals("s", qe.getAcceptHeaderSelect());
+ assertEquals("a", qe.getAcceptHeaderAsk());
+ assertEquals("g", qe.getAcceptHeaderDescribe());
+ assertEquals("g", qe.getAcceptHeaderConstructGraph());
}
+ }
+ }
- try (QueryExecution qe = conn.newQuery().query(query).build()) {
- QueryExecHTTP qeh = (QueryExecHTTP)QueryExec.adapt(qe);
- assertEquals(expectedHeader, qeh.getAppProvidedAcceptHeader());
+ @Test void test_headers_parsed_fallback() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
+ .build()) {
+
+ try (QueryExecution qExec = conn.newQuery()
+ .query("SELECT * { ?s ?p ?o }")
+ .build()) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("f", qe.getAcceptHeaderSelect());
+
+ assertEquals("f", qe.getAcceptHeaderAsk());
+ assertEquals("f", qe.getAcceptHeaderDescribe());
+ assertEquals("f", qe.getAcceptHeaderConstructGraph());
+ assertEquals("f", qe.getAcceptHeaderConstructDataset());
}
}
}
+
+ /**
+ * Setting an override-header on the builder should set all
+ * headers on the QueryExecHTTP instance to that override.
+ */
+ @Test
+ public void test_override_header() {
+ try (QueryExecutionHTTP qExec =
+ QueryExecutionHTTPBuilder.create()
+ .endpoint("urn:dummy-service")
+ .queryString("SELECT * { ?s ?p ?o }")
+ .acceptHeader("o") // Override header
+ .build() ) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("o", qe.getAppProvidedAcceptHeader());
+ assertEquals("o", qe.getAcceptHeaderSelect());
+ assertEquals("o", qe.getAcceptHeaderAsk());
+ assertEquals("o", qe.getAcceptHeaderDescribe());
+ assertEquals("o", qe.getAcceptHeaderConstructGraph());
+ assertEquals("o", qe.getAcceptHeaderConstructDataset());
+ }
Review Comment:
I think that when setting the override header on the builder, then the concrete QueryExecHTTP instance should report that header for all query types.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2356699755
##########
jena-arq/src/main/java/org/apache/jena/sparql/exec/http/QueryExecHTTP.java:
##########
@@ -133,11 +149,15 @@ public QueryExecHTTP(String serviceURL, Query query, String queryString, int url
this.defaultGraphURIs = defaultGraphURIs;
this.namedGraphURIs = namedGraphURIs;
this.sendMode = Objects.requireNonNull(sendMode);
- this.appProvidedAcceptHeader = explicitAcceptHeader;
+ this.overrideAcceptHeader = overrideAcceptHeader;
+ this.selectAcceptHeader = selectAcceptheader;
+ this.askAcceptHeader = askAcceptHeader;
+ this.graphAcceptHeader = graphAcceptHeader;
+ this.datasetAcceptHeader = datasetAcceptHeader;
// Important - handled as special case because the defaults vary by query type.
if ( httpHeaders.containsKey(HttpNames.hAccept) ) {
- if ( this.appProvidedAcceptHeader != null )
- this.appProvidedAcceptHeader = httpHeaders.get(HttpNames.hAccept);
+ if ( this.overrideAcceptHeader != null )
+ this.overrideAcceptHeader = httpHeaders.get(HttpNames.hAccept);
Review Comment:
I think that this overrideAcceptHeader should eventually be handled exclusively in the builder - but since this feature is part of the public API I better not touch it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386177140
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
Could you say which this change is in the PR? The `QueryType` may not be particulaly useful in this impl but when inheritied it might be useful.
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
Could you say which this change is in the PR? The `QueryType` may not be particulaly useful in this impl but when inherited it might be useful.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs merged PR #3441:
URL: https://github.com/apache/jena/pull/3441
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389283479
##########
jena-arq/src/main/java/org/apache/jena/sparql/exec/http/QueryExecHTTP.java:
##########
@@ -133,11 +149,15 @@ public QueryExecHTTP(String serviceURL, Query query, String queryString, int url
this.defaultGraphURIs = defaultGraphURIs;
this.namedGraphURIs = namedGraphURIs;
this.sendMode = Objects.requireNonNull(sendMode);
- this.appProvidedAcceptHeader = explicitAcceptHeader;
+ this.overrideAcceptHeader = overrideAcceptHeader;
+ this.selectAcceptHeader = selectAcceptheader;
+ this.askAcceptHeader = askAcceptHeader;
+ this.graphAcceptHeader = graphAcceptHeader;
+ this.datasetAcceptHeader = datasetAcceptHeader;
// Important - handled as special case because the defaults vary by query type.
if ( httpHeaders.containsKey(HttpNames.hAccept) ) {
- if ( this.appProvidedAcceptHeader != null )
- this.appProvidedAcceptHeader = httpHeaders.get(HttpNames.hAccept);
+ if ( this.overrideAcceptHeader != null )
+ this.overrideAcceptHeader = httpHeaders.get(HttpNames.hAccept);
Review Comment:
Added handling of the overrideAcceptHeader to the builder - the new constructor of QueryExecHTTP no longer uses the field whereas the old constructor still supports it. This should resolve the issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389255394
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTP.java:
##########
@@ -1,99 +0,0 @@
-/*
Review Comment:
These tests used the `getAppProvidedAcceptHeader()` method, which I introduced only for testing in a previous PR and which was also stated in the javadoc ("For testing only."). In hindsight, a better solution would have been a package private method together with the test case in the `org.apache.jena.sparql.exec.http` package within jena-rdfconnection :/
The field and the method are now marked as deprecated - and the behavior for `getAppProvidedAcceptHeader` has changed - so the tests for this property no longer apply.
The new `QueryExecHTTP.getAcceptHeader*()` methods for the different query forms should be future proof.
The value of the `appProvidedAcceptHeader` used to rely on the QueryType - but since this wouldn't work generically for strings, this PR removed this logic. The header is now chosen based on the exec call such as `.ask()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389261302
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTPHeaders.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.rdfconnection;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.jena.query.QueryExecution;
+import org.apache.jena.sparql.exec.QueryExec;
+import org.apache.jena.sparql.exec.http.QueryExecHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTPBuilder;
+import org.junit.jupiter.api.Test;
+
+public class TestRDFConnectionHTTPHeaders {
+
+ /**
+ * Test whether connection headers are properly passed on to the query execution.
+ * No query is actually executed.
+ */
+ @Test void test_headers_non_parsed() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderSelectQuery("s")
+ .acceptHeaderAskQuery("a")
+ .acceptHeaderGraph("g")
+ .acceptHeaderDataset("d")
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("s", qe.getAcceptHeaderSelect());
+ assertEquals("a", qe.getAcceptHeaderAsk());
+ assertEquals("g", qe.getAcceptHeaderDescribe());
+ assertEquals("g", qe.getAcceptHeaderConstructGraph());
+ assertEquals("d", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ @Test void test_headers_non_parsed_fallback() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("f", qe.getAcceptHeaderSelect());
+ assertEquals("f", qe.getAcceptHeaderAsk());
+ assertEquals("f", qe.getAcceptHeaderDescribe());
+ assertEquals("f", qe.getAcceptHeaderConstructGraph());
+ assertEquals("f", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ @Test void test_headers_parsed_fallback() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
+ .build()) {
+
+ try (QueryExecution qExec = conn.newQuery()
+ .query("SELECT * { ?s ?p ?o }")
+ .build()) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("f", qe.getAcceptHeaderSelect());
+
+ assertEquals("f", qe.getAcceptHeaderAsk());
+ assertEquals("f", qe.getAcceptHeaderDescribe());
+ assertEquals("f", qe.getAcceptHeaderConstructGraph());
+ assertEquals("f", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ /**
+ * Setting an override-header on the builder should set all
+ * headers on the QueryExecHTTP instance to that override.
+ */
+ @Test
+ public void test_override_header() {
+ try (QueryExecutionHTTP qExec =
+ QueryExecutionHTTPBuilder.create()
+ .endpoint("urn:dummy-service")
+ .queryString("SELECT * { ?s ?p ?o }")
+ .acceptHeader("o") // Override header
+ .build()) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("o", qe.getAppProvidedAcceptHeader());
+ assertEquals("o", qe.getAcceptHeaderSelect());
+ assertEquals("o", qe.getAcceptHeaderAsk());
+ assertEquals("o", qe.getAcceptHeaderDescribe());
+ assertEquals("o", qe.getAcceptHeaderConstructGraph());
+ assertEquals("o", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+}
Review Comment:
Added as `TestRDFConnectionHTTPHeaders.test_override_header_{02, 03}`.
Note, that order matters:
```
.acceptHeaderAskQuery("a")
.acceptHeader("o") // Sets everything to "o" -> overrides setting for "a".
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386339028
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
> The QueryType may not be particularly useful in this impl
That was my main reason, and I doubted that there are good reasons for an override: Having query type handling here seems to add needless complexity because these methods are mostly shortcuts to `QueryExecBuilder` (plus transaction wrapping). `QueryExecBuilder` does not have an API to which the query type can be passed, and in these specific cases, the `QueryExec` created by the `QueryExecBuilder` attempts to execute the string with a certain type just one line below - so it felt redundant.
Of course, if you prefer I can restore this. Alternatively, `QueryExecBuilder` could receive `query(queryString, queryType)` method variants - but again the use might be limited. It would allow for `QueryExec` to check whether a called exec method, such as `ask()`, is consistent with the set query type prior to actually sending an e.g. remote request. But one would then always have to supply query strings with query types and in case of an inconsistency, there would be an eventual failure anyway.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386339028
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
> The QueryType may not be particularly useful in this impl
That was my main reason, and I doubted that there are good reasons for an override: Having query type handling here seems to add needless complexity because these methods are mostly shortcuts to `QueryExecBuilder` (plus transaction wrapping). `QueryExecBuilder` does not have an API to which the query type can be passed, and in these specific cases, the `QueryExec` created by the `QueryExecBuilder` performs the check of the query type just one line below - so it felt redundant.
Of course, if you prefer I can restore this. Alternatively, `QueryExecBuilder` could receive `query(queryString, queryType)` method variants - but again the use might be limited. It would allow for `QueryExec` to check whether a called exec method, such as `ask()`, is consistent with the set query type prior to actually sending an e.g. remote request. But one would then always have to supply query strings with query types and in case of an inconsistency, there would be an eventually failure anyway.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389255394
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTP.java:
##########
@@ -1,99 +0,0 @@
-/*
Review Comment:
These tests used the `getAppProvidedAcceptHeader` method, which I introduced only for testing in a previous PR and which was also stated in the javadoc ("For testing only."). In hindsight, a better solution would have been a package private method together with the test case in the `org.apache.jena.sparql.exec.http` package within jena-rdfconnection :/
The field and the method are now marked as deprecated - and the behavior has changed for this field.
The value of the `appProvidedAcceptHeader` used to rely on the QueryType - but since this wouldn't work generically for strings, this PR removed this logic. The header is now chosen based on the exec call such as `.ask()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389255394
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTP.java:
##########
@@ -1,99 +0,0 @@
-/*
Review Comment:
These tests used the `getAppProvidedAcceptHeader` method, which I introduced only for testing in a previous PR and which was also stated in the javadoc ("For testing only."). In hindsight, a better solution would have been a package private method together with the test case in the `org.apache.jena.sparql.exec.http` package within jena-rdfconnection :/
The field and the method are now marked as deprecated.
The value of the `appProvidedAcceptHeader` used to rely on the QueryType - but since this wouldn't work generically for strings, this PR removed this logic. The header is now chosen based on the exec call such as `.ask()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386339028
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
> The QueryType may not be particularly useful in this impl
The main reason is that I though that `QueryExecBuilder` should be the single point of truth, and logic outside of it should be avoided:
Having query type handling here seems to add needless complexity because these methods are mostly shortcuts to `QueryExecBuilder` (plus transaction wrapping). `QueryExecBuilder` does not have an API to which the query type can be passed, and in these specific cases, the `QueryExec` created by the `QueryExecBuilder` attempts to execute the string with a certain query type just one line below - so it felt redundant.
Of course, if you prefer I can restore this. Alternatively, `QueryExecBuilder` could receive query(queryString, queryType) method variants - but again the use might be limited. It would allow for `QueryExec` to check whether a called exec method, such as ask(), is consistent with the set query type prior to actually sending an e.g. remote request. But one would then always have to supply query strings with query types and in case of an inconsistency, there would be an eventual failure anyway.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386339028
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
> The QueryType may not be particularly useful in this impl
That was my main reason, and I doubted that there are good reasons for an override: Having query type handling here seems to add needless complexity because these methods are mostly shortcuts to `QueryExecBuilder` (plus transaction wrapping). `QueryExecBuilder` does not have an API to which the query type can be passed, and in these specific cases, the `QueryExec` created by the `QueryExecBuilder` performs the check of the query type just one line below - so it felt redundant.
Of course, if you prefer I can restore this. Alternatively, `QueryExecBuilder` could receive `query(queryString, queryType)` method variants - but again the use might be limited. It would allow for `QueryExec` to check whether a called exec method, such as `ask()`, is consistent with the set query type prior to actually sending an e.g. remote request. But one would then always have to supply query strings with query types and in case of an inconsistency, there would be an eventual failure anyway.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386339028
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
> The QueryType may not be particularly useful in this impl
That was my main reason, and I doubted that there are good reasons for an override: Having query type handling here seems to add needless complexity because these methods are mostly shortcuts to `QueryExecBuilder` (plus transaction wrapping). `QueryExecBuilder` does not have an API to which the query type can be passed, and in this specific cases, the `QueryExec` created by the `QueryExecBuilder` performs the check of the query type just one line below - so it felt redundant.
Of course, if you prefer I can restore this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2350334586
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -316,53 +312,54 @@ protected void setQuery(Query query, String queryStr) {
queryType = query == null ? QueryType.UNKNOWN : query.queryType();
}
+ /**
+ * For parsed queries: Derive and return the appropriate accept header.
+ * For non-parsed queries: This method returns null. The header is then chosen
+ * based on the used method of the query exec. For example,
+ * {@link QueryExecHTTP#select()} will use the configured select header.
+ */
+ private String deriveAcceptHeaderFromQueryType() {
Review Comment:
I think this method can new be removed: QueryExecHTTP now knows all headers and can choose among the configured ones when `QueryExecHTTP.[queryType]` is called.
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -316,53 +312,54 @@ protected void setQuery(Query query, String queryStr) {
queryType = query == null ? QueryType.UNKNOWN : query.queryType();
}
+ /**
+ * For parsed queries: Derive and return the appropriate accept header.
+ * For non-parsed queries: This method returns null. The header is then chosen
+ * based on the used method of the query exec. For example,
+ * {@link QueryExecHTTP#select()} will use the configured select header.
+ */
+ private String deriveAcceptHeaderFromQueryType() {
Review Comment:
I think this method can now be removed: QueryExecHTTP now knows all headers and can choose among the configured ones when `QueryExecHTTP.[queryType]` is called.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on PR #3441:
URL: https://github.com/apache/jena/pull/3441#issuecomment-3334710040
> Should be rebased - I had removed a couple of whitespaces just before your message 😄
(claimed) 7000+ different files down to 12 files.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389255394
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTP.java:
##########
@@ -1,99 +0,0 @@
-/*
Review Comment:
These tests used the `getAppProvidedAcceptHeader()` method, which I introduced only for testing in a previous PR and which was also stated in the javadoc ("For testing only."). In hindsight, a better solution would have been a package private method together with the test case in the `org.apache.jena.sparql.exec.http` package within jena-rdfconnection :/
The field and the method are now marked as deprecated - and the behavior for `getAppProvidedAcceptHeader` has changed - so the tests no longer applied.
The value of the `appProvidedAcceptHeader` used to rely on the QueryType - but since this wouldn't work generically for strings, this PR removed this logic. The header is now chosen based on the exec call such as `.ask()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2356699755
##########
jena-arq/src/main/java/org/apache/jena/sparql/exec/http/QueryExecHTTP.java:
##########
@@ -133,11 +149,15 @@ public QueryExecHTTP(String serviceURL, Query query, String queryString, int url
this.defaultGraphURIs = defaultGraphURIs;
this.namedGraphURIs = namedGraphURIs;
this.sendMode = Objects.requireNonNull(sendMode);
- this.appProvidedAcceptHeader = explicitAcceptHeader;
+ this.overrideAcceptHeader = overrideAcceptHeader;
+ this.selectAcceptHeader = selectAcceptheader;
+ this.askAcceptHeader = askAcceptHeader;
+ this.graphAcceptHeader = graphAcceptHeader;
+ this.datasetAcceptHeader = datasetAcceptHeader;
// Important - handled as special case because the defaults vary by query type.
if ( httpHeaders.containsKey(HttpNames.hAccept) ) {
- if ( this.appProvidedAcceptHeader != null )
- this.appProvidedAcceptHeader = httpHeaders.get(HttpNames.hAccept);
+ if ( this.overrideAcceptHeader != null )
+ this.overrideAcceptHeader = httpHeaders.get(HttpNames.hAccept);
Review Comment:
I think that this overrideAcceptHeader should eventually be handled exclusively in the builder - but since this feature is part of the public API I better not touch it I guess.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on PR #3441:
URL: https://github.com/apache/jena/pull/3441#issuecomment-3334246084
Please rebase to current main.
I tried to compare using GH and there are too many files!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386339028
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
> The QueryType may not be particularly useful in this impl
That was my main reason, and I doubted that there are good reasons for an override: Having query type handling here seems to add needless complexity because these methods are mostly shortcuts for `QueryExecBuilder` (plus transaction wrapping). `QueryExecBuilder` does not have an API to handle an individual query type, and in this specific cases, the `QueryExec` created by the `QueryExecBuilder` performs the check of the query type just one line below - so it felt redundant.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386339028
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
> The QueryType may not be particularly useful in this impl
That was my main reason, and I doubted that there are good reasons for an override: Having query type handling here seems to add needless complexity because these methods are mostly shortcuts to `QueryExecBuilder` (plus transaction wrapping). `QueryExecBuilder` does not have an API to which the query type can be passed, and in these specific cases, the `QueryExec` created by the `QueryExecBuilder` performs the check of the query type just one line below - so it felt redundant.
Of course, if you prefer I can restore this. Alternatively, `QueryExecBuilder` could receive a `query(queryString, queryType)` method - but again the use might be limited. It would allow for `QueryExec` to check whether a called exec method, such as `ask()`, is consistent with the set query type prior to actually sending an e.g. remote request. But it would most likely eventually fail anyway.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386339028
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
> The QueryType may not be particularly useful in this impl
That was my main reason, and I doubted that there are good reasons for an override: Having query type handling here seems to add needless complexity because these methods are mostly shortcuts to `QueryExecBuilder` (plus transaction wrapping). `QueryExecBuilder` does not have an API to which the query type can be passed, and in these specific cases, the `QueryExec` created by the `QueryExecBuilder` performs the check of the query type just one line below - so it felt redundant.
Of course, if you prefer I can restore this. Alternatively, `QueryExecBuilder` could receive a `query(queryString, queryType)` method - but again the use might be limited. It would allow for checking whether the exec method, such as `ask()`, is consistent with the set query type prior to actually sending an e.g. remote request.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386339028
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
> The QueryType may not be particularly useful in this impl
That was my main reason, and I doubted that there are good reasons for an override: Having query type handling here seems to add needless complexity because these methods are mostly shortcuts to `QueryExecBuilder` (plus transaction wrapping). `QueryExecBuilder` does not have an API to which the query type can be passed, and in these specific cases, the `QueryExec` created by the `QueryExecBuilder` performs the check of the query type just one line below - so it felt redundant.
Of course, if you prefer I can restore this. Alternatively, `QueryExecBuilder` could receive a `query(queryString, queryType)` method - but again the use might be limited. It would allow for `QueryExec` to check whether a called exec method, such as `ask()`, is consistent with the set query type prior to actually sending an e.g. remote request.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389283479
##########
jena-arq/src/main/java/org/apache/jena/sparql/exec/http/QueryExecHTTP.java:
##########
@@ -133,11 +149,15 @@ public QueryExecHTTP(String serviceURL, Query query, String queryString, int url
this.defaultGraphURIs = defaultGraphURIs;
this.namedGraphURIs = namedGraphURIs;
this.sendMode = Objects.requireNonNull(sendMode);
- this.appProvidedAcceptHeader = explicitAcceptHeader;
+ this.overrideAcceptHeader = overrideAcceptHeader;
+ this.selectAcceptHeader = selectAcceptheader;
+ this.askAcceptHeader = askAcceptHeader;
+ this.graphAcceptHeader = graphAcceptHeader;
+ this.datasetAcceptHeader = datasetAcceptHeader;
// Important - handled as special case because the defaults vary by query type.
if ( httpHeaders.containsKey(HttpNames.hAccept) ) {
- if ( this.appProvidedAcceptHeader != null )
- this.appProvidedAcceptHeader = httpHeaders.get(HttpNames.hAccept);
+ if ( this.overrideAcceptHeader != null )
+ this.overrideAcceptHeader = httpHeaders.get(HttpNames.hAccept);
Review Comment:
Added handling of the overrideAcceptHeader to the builder - the new constructor of QueryExecHTTP no longer uses the parameter whereas the old constructor still supports it. This should resolve the issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389221931
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTPHeaders.java:
##########
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.rdfconnection;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.jena.query.QueryExecution;
+import org.apache.jena.sparql.exec.QueryExec;
+import org.apache.jena.sparql.exec.http.QueryExecHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTPBuilder;
+import org.junit.jupiter.api.Test;
+
+public class TestRDFConnectionHTTPHeaders {
+
+ /**
+ * Test whether connection headers are properly passed on to the query execution.
+ * No query is actually executed.
+ */
+ @Test void test_headers_non_parsed() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderSelectQuery("s")
+ .acceptHeaderAskQuery("a")
+ .acceptHeaderGraph("g")
+ .acceptHeaderDataset("d")
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("s", qe.getAcceptHeaderSelect());
+ assertEquals("a", qe.getAcceptHeaderAsk());
+ assertEquals("g", qe.getAcceptHeaderDescribe());
+ assertEquals("g", qe.getAcceptHeaderConstructGraph());
+ assertEquals("d", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ @Test void test_headers_non_parsed_fallback() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
Review Comment:
There are `acceptHeaderQuery` tests are in RDF**Connection**HTTPHeaders - if desired, they could be duplicated for the RDFLink level.
Note: The comment on the field `acceptSparqlResults` originally read:
> // All purpose SPARQL results header used if above specific cases do not apply.
So I interpreted this as a fallback. An alternative interpretation is that this sets *all* SPARQL query headers - in this case, separate SPARQL-only fields should be introduced that are not shared with GSP. `acceptHeaderQuery` would then set the fields for sparql graph results (construct and describe) but not for GSP retrieval.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389255394
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTP.java:
##########
@@ -1,99 +0,0 @@
-/*
Review Comment:
These tests used the `getAppProvidedAcceptHeader()` method, which I introduced only for testing in a previous PR and which was also stated in the javadoc ("For testing only."). In hindsight, a better solution would have been a package private method together with the test case in the `org.apache.jena.sparql.exec.http` package within jena-rdfconnection :/
The field and the method are now marked as deprecated - and the behavior for `getAppProvidedAcceptHeader` has changed - so the tests for this property no longer apply.
In contrast, the new `QueryExecHTTP.getAcceptHeader*()` methods for the different query forms should be future proof.
The value of the `appProvidedAcceptHeader` used to rely on the QueryType - but since this wouldn't work generically for strings, this PR removed this logic. The header is now chosen based on the exec call such as `.ask()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on PR #3441:
URL: https://github.com/apache/jena/pull/3441#issuecomment-3343873488
> * Minor unrelated fix: Quad.isConcrete() would raise NPE if the graph was null ("true triple in quad").
I created issue #3475 for this.
Could it be a separate commit please?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386339028
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
> The QueryType may not be particularly useful in this impl
That was my main reason, and I doubted that there are good reasons for an override: Having query type handling here seems to add needless complexity because these methods are mostly shortcuts to `QueryExecBuilder` (plus transaction wrapping). `QueryExecBuilder` does not have an API to which the query type can be passed, and in these specific cases, the `QueryExec` created by the `QueryExecBuilder` attempts to execute the string with a certain query type just one line below - so it felt redundant.
Of course, if you prefer I can restore this. Alternatively, `QueryExecBuilder` could receive `query(queryString, queryType)` method variants - but again the use might be limited. It would allow for `QueryExec` to check whether a called exec method, such as `ask()`, is consistent with the set query type prior to actually sending an e.g. remote request. But one would then always have to supply query strings with query types and in case of an inconsistency, there would be an eventual failure anyway.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386339028
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
> The QueryType may not be particularly useful in this impl
That was my main reason, and I doubted that there are good reasons for an override: Having query type handling here seems to add needless complexity because these methods are mostly shortcuts to `QueryExecBuilder` (plus transaction wrapping). `QueryExecBuilder` does not have an API to which the query type can be passed, and in these specific cases, the `QueryExec` created by the `QueryExecBuilder` performs the check of the query type just one line below - so it felt redundant.
Of course, if you prefer I can restore this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386339028
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
> The QueryType may not be particularly useful in this impl
The main reason is that I though that `QueryExecBuilder` should be the single point of truth, and logic outside of it should be avoided:
Having query type handling here seems to add needless complexity because these methods are mostly shortcuts to `QueryExecBuilder` (plus transaction wrapping). `QueryExecBuilder` does not have an API to which the query type can be passed, and in these specific cases, the `QueryExec` created by the `QueryExecBuilder` attempts to execute the string with a certain query type just one line below - so it felt redundant.
Of course, if you prefer I can restore this. Alternatively, `QueryExecBuilder` could receive `query(queryString, queryType)` method variants - but again the use might be limited. It would allow for `QueryExec` to check whether a called exec method, such as ask(), is consistent with the set query type prior to actually sending an e.g. remote request. But one would then always have to supply query strings with query types and in case of an inconsistency, there would be an eventual failure anyway.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386339028
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
> The QueryType may not be particularly useful in this impl
The main reason is that I though that `QueryExecBuilder` should be the single point of truth, and logic outside of it should be avoided. `QueryExecBuilder` does not have an API to which the query type can be passed, and in these specific cases, the `QueryExec` created by the `QueryExecBuilder` attempts to execute the string with a certain query type just one line below - so it felt redundant.
Of course, one could argue that e.g. in the future `QueryExecBuilder` could receive e.g. `query(queryString, queryType)` method variants. Then the query type here could eventually passed to the extended builders. But as these specific methods are shortcuts with consistent use - the appropriate exec method, such as `.ask()` is just one line below - it wouldn't add anything here.
So I couldn't find good arguments for why to have this extra complexity in the shortcuts.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389263644
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdflink/TestRDFLinkHTTPHeaders.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.rdflink;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.jena.sparql.exec.http.QueryExecHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecHTTPBuilder;
+import org.junit.jupiter.api.Test;
+
+public class TestRDFLinkHTTPHeaders {
Review Comment:
There are tests in `RDFConnectionHTTPHeaders` for this which however are not duplicated on the RDFLink level.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389255394
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTP.java:
##########
@@ -1,99 +0,0 @@
-/*
Review Comment:
These tests used the `getAppProvidedAcceptHeader()` method, which I introduced only for testing in a previous PR and which was also stated in the javadoc ("For testing only."). In hindsight, a better solution would have been a package private method together with the test case in the `org.apache.jena.sparql.exec.http` package within jena-rdfconnection :/
The field and the method are now marked as deprecated - and the behavior for `getAppProvidedAcceptHeader` has changed - so the tests for this property no longer apply.
The value of the `appProvidedAcceptHeader` used to rely on the QueryType - but since this wouldn't work generically for strings, this PR removed this logic. The header is now chosen based on the exec call such as `.ask()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2394849251
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTPHeaders.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.rdfconnection;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.jena.query.QueryExecution;
+import org.apache.jena.sparql.exec.QueryExec;
+import org.apache.jena.sparql.exec.http.QueryExecHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTPBuilder;
+import org.junit.jupiter.api.Test;
+
+public class TestRDFConnectionHTTPHeaders {
+
+ /**
+ * Test whether connection headers are properly passed on to the query execution.
+ * No query is actually executed.
+ */
+ @Test void test_headers_non_parsed() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderSelectQuery("s")
+ .acceptHeaderAskQuery("a")
+ .acceptHeaderGraph("g")
+ .acceptHeaderDataset("d")
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("s", qe.getAcceptHeaderSelect());
+ assertEquals("a", qe.getAcceptHeaderAsk());
+ assertEquals("g", qe.getAcceptHeaderDescribe());
+ assertEquals("g", qe.getAcceptHeaderConstructGraph());
+ assertEquals("d", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ @Test void test_headers_non_parsed_fallback() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("f", qe.getAcceptHeaderSelect());
+ assertEquals("f", qe.getAcceptHeaderAsk());
+ assertEquals("f", qe.getAcceptHeaderDescribe());
+ assertEquals("f", qe.getAcceptHeaderConstructGraph());
+ assertEquals("f", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ @Test void test_headers_parsed_fallback() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
+ .build()) {
+
+ try (QueryExecution qExec = conn.newQuery()
+ .query("SELECT * { ?s ?p ?o }")
+ .build()) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("f", qe.getAcceptHeaderSelect());
+
+ assertEquals("f", qe.getAcceptHeaderAsk());
+ assertEquals("f", qe.getAcceptHeaderDescribe());
+ assertEquals("f", qe.getAcceptHeaderConstructGraph());
+ assertEquals("f", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ /**
+ * Setting an override-header on the builder should set all
+ * headers on the QueryExecHTTP instance to that override.
+ */
+ @Test
+ public void test_override_header() {
+ try (QueryExecutionHTTP qExec =
+ QueryExecutionHTTPBuilder.create()
+ .endpoint("urn:dummy-service")
+ .queryString("SELECT * { ?s ?p ?o }")
+ .acceptHeader("o") // Override header
+ .build()) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("o", qe.getAppProvidedAcceptHeader());
+ assertEquals("o", qe.getAcceptHeaderSelect());
+ assertEquals("o", qe.getAcceptHeaderAsk());
+ assertEquals("o", qe.getAcceptHeaderDescribe());
+ assertEquals("o", qe.getAcceptHeaderConstructGraph());
+ assertEquals("o", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+}
Review Comment:
When passing half-built builders around (uncommon) the later options should override.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2356699755
##########
jena-arq/src/main/java/org/apache/jena/sparql/exec/http/QueryExecHTTP.java:
##########
@@ -133,11 +149,15 @@ public QueryExecHTTP(String serviceURL, Query query, String queryString, int url
this.defaultGraphURIs = defaultGraphURIs;
this.namedGraphURIs = namedGraphURIs;
this.sendMode = Objects.requireNonNull(sendMode);
- this.appProvidedAcceptHeader = explicitAcceptHeader;
+ this.overrideAcceptHeader = overrideAcceptHeader;
+ this.selectAcceptHeader = selectAcceptheader;
+ this.askAcceptHeader = askAcceptHeader;
+ this.graphAcceptHeader = graphAcceptHeader;
+ this.datasetAcceptHeader = datasetAcceptHeader;
// Important - handled as special case because the defaults vary by query type.
if ( httpHeaders.containsKey(HttpNames.hAccept) ) {
- if ( this.appProvidedAcceptHeader != null )
- this.appProvidedAcceptHeader = httpHeaders.get(HttpNames.hAccept);
+ if ( this.overrideAcceptHeader != null )
+ this.overrideAcceptHeader = httpHeaders.get(HttpNames.hAccept);
Review Comment:
I think that this overrideAcceptHeader should eventually be handled exclusively in the builder - but since this feature is now here I better not touch it I guess.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on PR #3441:
URL: https://github.com/apache/jena/pull/3441#issuecomment-3307107375
I have completed my revisions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2350334586
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -316,53 +312,54 @@ protected void setQuery(Query query, String queryStr) {
queryType = query == null ? QueryType.UNKNOWN : query.queryType();
}
+ /**
+ * For parsed queries: Derive and return the appropriate accept header.
+ * For non-parsed queries: This method returns null. The header is then chosen
+ * based on the used method of the query exec. For example,
+ * {@link QueryExecHTTP#select()} will use the configured select header.
+ */
+ private String deriveAcceptHeaderFromQueryType() {
Review Comment:
I think this method can be removed. The approriate header is now chosen when calling the `QueryExecHTTP.[queryType]` variants.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389261302
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTPHeaders.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.rdfconnection;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.jena.query.QueryExecution;
+import org.apache.jena.sparql.exec.QueryExec;
+import org.apache.jena.sparql.exec.http.QueryExecHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTPBuilder;
+import org.junit.jupiter.api.Test;
+
+public class TestRDFConnectionHTTPHeaders {
+
+ /**
+ * Test whether connection headers are properly passed on to the query execution.
+ * No query is actually executed.
+ */
+ @Test void test_headers_non_parsed() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderSelectQuery("s")
+ .acceptHeaderAskQuery("a")
+ .acceptHeaderGraph("g")
+ .acceptHeaderDataset("d")
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("s", qe.getAcceptHeaderSelect());
+ assertEquals("a", qe.getAcceptHeaderAsk());
+ assertEquals("g", qe.getAcceptHeaderDescribe());
+ assertEquals("g", qe.getAcceptHeaderConstructGraph());
+ assertEquals("d", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ @Test void test_headers_non_parsed_fallback() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("f", qe.getAcceptHeaderSelect());
+ assertEquals("f", qe.getAcceptHeaderAsk());
+ assertEquals("f", qe.getAcceptHeaderDescribe());
+ assertEquals("f", qe.getAcceptHeaderConstructGraph());
+ assertEquals("f", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ @Test void test_headers_parsed_fallback() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
+ .build()) {
+
+ try (QueryExecution qExec = conn.newQuery()
+ .query("SELECT * { ?s ?p ?o }")
+ .build()) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("f", qe.getAcceptHeaderSelect());
+
+ assertEquals("f", qe.getAcceptHeaderAsk());
+ assertEquals("f", qe.getAcceptHeaderDescribe());
+ assertEquals("f", qe.getAcceptHeaderConstructGraph());
+ assertEquals("f", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ /**
+ * Setting an override-header on the builder should set all
+ * headers on the QueryExecHTTP instance to that override.
+ */
+ @Test
+ public void test_override_header() {
+ try (QueryExecutionHTTP qExec =
+ QueryExecutionHTTPBuilder.create()
+ .endpoint("urn:dummy-service")
+ .queryString("SELECT * { ?s ?p ?o }")
+ .acceptHeader("o") // Override header
+ .build()) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("o", qe.getAppProvidedAcceptHeader());
+ assertEquals("o", qe.getAcceptHeaderSelect());
+ assertEquals("o", qe.getAcceptHeaderAsk());
+ assertEquals("o", qe.getAcceptHeaderDescribe());
+ assertEquals("o", qe.getAcceptHeaderConstructGraph());
+ assertEquals("o", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+}
Review Comment:
Added as `TestRDFConnectionHTTPHeaders.test_override_header_02`.
Note, that order matters:
```
.acceptHeaderAskQuery("a")
.acceptHeader("o") // Sets everything to "o" -> overrides setting for "a".
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386339028
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
> The QueryType may not be particularly useful in this impl
The main reason is that I though that `QueryExecBuilder` should be the single point of truth, and logic outside of it should be avoided. `QueryExecBuilder` does not have an API to which the query type can be passed, and in these specific cases, the `QueryExec` created by the `QueryExecBuilder` attempts to execute the string with a certain query type just one line below - so it felt redundant.
Of course, one could argue that e.g. in the future `QueryExecBuilder` could receive e.g. `query(queryString, queryType)`. Then the query type here could eventually passed to the extended builders. But as these specific methods are shortcuts with consistent use - the appropriate exec method, such as `.ask()` is just one line below - it wouldn't add anything here.
So I couldn't find good arguments for why to have this extra complexity in the shortcuts.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386339028
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
> The QueryType may not be particularly useful in this impl
That was my main reason, and I doubted that there are good reasons for an override: Having query type handling here seems to add needless complexity because these methods are mostly shortcuts to `QueryExecBuilder` (plus transaction wrapping). `QueryExecBuilder` does not have an API to which the query type can be passed, and in these specific cases, the `QueryExec` created by the `QueryExecBuilder` performs the check of the query type just one line below - so it felt redundant.
Of course, if you prefer I can restore this. Alternatively, `QueryExecBuilder` could receive a `query(queryString, queryType)` method - but again the use might be limited. It would allow for checking whether the exec method is consistent with the set query string prior to actually sending a request.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389304046
##########
jena-arq/src/main/java/org/apache/jena/http/sys/ExecHTTPBuilder.java:
##########
@@ -253,22 +262,58 @@ public Y substitution(Var var, Node value) {
return thisBuilder();
}
+ /** Setting this header overrides any other header. */
public Y acceptHeader(String acceptHeader) {
Objects.requireNonNull(acceptHeader);
this.appAcceptHeader = acceptHeader;
+ this.selectAcceptHeader = acceptHeader;
+ this.askAcceptHeader = acceptHeader;
+ this.graphAcceptHeader = acceptHeader;
+ this.datasetAcceptHeader = acceptHeader;
+ return thisBuilder();
+ }
Review Comment:
This method now sets all header fields to the given value. Subsequent calls to e.g. `acceptHeaderSelectQuery()` can set specific headers again. The `appAcceptHeader` field is not used anymore.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389304046
##########
jena-arq/src/main/java/org/apache/jena/http/sys/ExecHTTPBuilder.java:
##########
@@ -253,22 +262,58 @@ public Y substitution(Var var, Node value) {
return thisBuilder();
}
+ /** Setting this header overrides any other header. */
public Y acceptHeader(String acceptHeader) {
Objects.requireNonNull(acceptHeader);
this.appAcceptHeader = acceptHeader;
+ this.selectAcceptHeader = acceptHeader;
+ this.askAcceptHeader = acceptHeader;
+ this.graphAcceptHeader = acceptHeader;
+ this.datasetAcceptHeader = acceptHeader;
+ return thisBuilder();
+ }
Review Comment:
This method now sets all header fields to the given value. The `appAcceptHeader` field is not used anymore.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on PR #3441:
URL: https://github.com/apache/jena/pull/3441#issuecomment-3302967756
> (Can create one if desired)
Yes, please. Separating the report from the solution makes for a better long term record.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389261302
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTPHeaders.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.rdfconnection;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.jena.query.QueryExecution;
+import org.apache.jena.sparql.exec.QueryExec;
+import org.apache.jena.sparql.exec.http.QueryExecHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTPBuilder;
+import org.junit.jupiter.api.Test;
+
+public class TestRDFConnectionHTTPHeaders {
+
+ /**
+ * Test whether connection headers are properly passed on to the query execution.
+ * No query is actually executed.
+ */
+ @Test void test_headers_non_parsed() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderSelectQuery("s")
+ .acceptHeaderAskQuery("a")
+ .acceptHeaderGraph("g")
+ .acceptHeaderDataset("d")
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("s", qe.getAcceptHeaderSelect());
+ assertEquals("a", qe.getAcceptHeaderAsk());
+ assertEquals("g", qe.getAcceptHeaderDescribe());
+ assertEquals("g", qe.getAcceptHeaderConstructGraph());
+ assertEquals("d", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ @Test void test_headers_non_parsed_fallback() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("f", qe.getAcceptHeaderSelect());
+ assertEquals("f", qe.getAcceptHeaderAsk());
+ assertEquals("f", qe.getAcceptHeaderDescribe());
+ assertEquals("f", qe.getAcceptHeaderConstructGraph());
+ assertEquals("f", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ @Test void test_headers_parsed_fallback() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
+ .build()) {
+
+ try (QueryExecution qExec = conn.newQuery()
+ .query("SELECT * { ?s ?p ?o }")
+ .build()) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("f", qe.getAcceptHeaderSelect());
+
+ assertEquals("f", qe.getAcceptHeaderAsk());
+ assertEquals("f", qe.getAcceptHeaderDescribe());
+ assertEquals("f", qe.getAcceptHeaderConstructGraph());
+ assertEquals("f", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ /**
+ * Setting an override-header on the builder should set all
+ * headers on the QueryExecHTTP instance to that override.
+ */
+ @Test
+ public void test_override_header() {
+ try (QueryExecutionHTTP qExec =
+ QueryExecutionHTTPBuilder.create()
+ .endpoint("urn:dummy-service")
+ .queryString("SELECT * { ?s ?p ?o }")
+ .acceptHeader("o") // Override header
+ .build()) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("o", qe.getAppProvidedAcceptHeader());
+ assertEquals("o", qe.getAcceptHeaderSelect());
+ assertEquals("o", qe.getAcceptHeaderAsk());
+ assertEquals("o", qe.getAcceptHeaderDescribe());
+ assertEquals("o", qe.getAcceptHeaderConstructGraph());
+ assertEquals("o", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+}
Review Comment:
Added as `TestRDFConnectionHTTPHeaders.test_override_header_02`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389261816
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdflink/TestRDFLinkHTTPHeaders.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.rdflink;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.jena.sparql.exec.http.QueryExecHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecHTTPBuilder;
+import org.junit.jupiter.api.Test;
+
+public class TestRDFLinkHTTPHeaders {
Review Comment:
done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389255394
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTP.java:
##########
@@ -1,99 +0,0 @@
-/*
Review Comment:
These tests used the `getAppProvidedAcceptHeader` method, which I introduced only for testing in a previous PR and which was also stated in the javadoc ("For testing only."). In hindsight, a better solution would have been a package private method together with the test case in the `org.apache.jena.sparql.exec.http` package within jena-rdfconnection :/
The field and the method are now marked as deprecated - and the behavior has changed for the method - so the tests no longer apply.
The value of the `appProvidedAcceptHeader` used to rely on the QueryType - but since this wouldn't work generically for strings, this PR removed this logic. The header is now chosen based on the exec call such as `.ask()`.
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTP.java:
##########
@@ -1,99 +0,0 @@
-/*
Review Comment:
These tests used the `getAppProvidedAcceptHeader` method, which I introduced only for testing in a previous PR and which was also stated in the javadoc ("For testing only."). In hindsight, a better solution would have been a package private method together with the test case in the `org.apache.jena.sparql.exec.http` package within jena-rdfconnection :/
The field and the method are now marked as deprecated - and the behavior has changed for the method - so the tests no longer applied.
The value of the `appProvidedAcceptHeader` used to rely on the QueryType - but since this wouldn't work generically for strings, this PR removed this logic. The header is now chosen based on the exec call such as `.ask()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389263644
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdflink/TestRDFLinkHTTPHeaders.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.rdflink;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.jena.sparql.exec.http.QueryExecHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecHTTPBuilder;
+import org.junit.jupiter.api.Test;
+
+public class TestRDFLinkHTTPHeaders {
Review Comment:
There are tests in `RDFConnectionHTTPHeaders` for this which however are not duplicated on the RDFLink level. See my corresponding comment there about how to interpret this method.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389261302
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTPHeaders.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.rdfconnection;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.jena.query.QueryExecution;
+import org.apache.jena.sparql.exec.QueryExec;
+import org.apache.jena.sparql.exec.http.QueryExecHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTPBuilder;
+import org.junit.jupiter.api.Test;
+
+public class TestRDFConnectionHTTPHeaders {
+
+ /**
+ * Test whether connection headers are properly passed on to the query execution.
+ * No query is actually executed.
+ */
+ @Test void test_headers_non_parsed() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderSelectQuery("s")
+ .acceptHeaderAskQuery("a")
+ .acceptHeaderGraph("g")
+ .acceptHeaderDataset("d")
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("s", qe.getAcceptHeaderSelect());
+ assertEquals("a", qe.getAcceptHeaderAsk());
+ assertEquals("g", qe.getAcceptHeaderDescribe());
+ assertEquals("g", qe.getAcceptHeaderConstructGraph());
+ assertEquals("d", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ @Test void test_headers_non_parsed_fallback() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("f", qe.getAcceptHeaderSelect());
+ assertEquals("f", qe.getAcceptHeaderAsk());
+ assertEquals("f", qe.getAcceptHeaderDescribe());
+ assertEquals("f", qe.getAcceptHeaderConstructGraph());
+ assertEquals("f", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ @Test void test_headers_parsed_fallback() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
+ .build()) {
+
+ try (QueryExecution qExec = conn.newQuery()
+ .query("SELECT * { ?s ?p ?o }")
+ .build()) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("f", qe.getAcceptHeaderSelect());
+
+ assertEquals("f", qe.getAcceptHeaderAsk());
+ assertEquals("f", qe.getAcceptHeaderDescribe());
+ assertEquals("f", qe.getAcceptHeaderConstructGraph());
+ assertEquals("f", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ /**
+ * Setting an override-header on the builder should set all
+ * headers on the QueryExecHTTP instance to that override.
+ */
+ @Test
+ public void test_override_header() {
+ try (QueryExecutionHTTP qExec =
+ QueryExecutionHTTPBuilder.create()
+ .endpoint("urn:dummy-service")
+ .queryString("SELECT * { ?s ?p ?o }")
+ .acceptHeader("o") // Override header
+ .build()) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("o", qe.getAppProvidedAcceptHeader());
+ assertEquals("o", qe.getAcceptHeaderSelect());
+ assertEquals("o", qe.getAcceptHeaderAsk());
+ assertEquals("o", qe.getAcceptHeaderDescribe());
+ assertEquals("o", qe.getAcceptHeaderConstructGraph());
+ assertEquals("o", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+}
Review Comment:
Added as `TestRDFConnectionHTTPHeaders.test_override_header_{02, 03}`.
Note, that order matters:
```
.acceptHeaderAskQuery("a")
.acceptHeader("o") // Sets everything to "o" -> overrides setting for "a".
```
The alternative would be to only compute the effective headers during build based on the explicitly set properties. What's your preference?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386339028
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
> The QueryType may not be particularly useful in this impl
That was my main reason, and I doubted that there are good reasons for an override: Having query type handling here seems to add needless complexity because these methods are mostly shortcuts to `QueryExecBuilder` (plus transaction wrapping). `QueryExecBuilder` does not have an API to which the query type can be passed, and in these specific cases, the `QueryExec` created by the `QueryExecBuilder` performs the check of the query type just one line below - so it felt redundant.
Of course, if you prefer I can restore this. Alternatively, `QueryExecBuilder` could receive a `query(queryString, queryType)` method - but again the use might be limited. It would allow for `QueryExec` to check whether a called exec method, such as `ask()`, is consistent with the set query type prior to actually sending an e.g. remote request. But in case of an inconsistency, there would most likely be an eventually failure anyway.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389261302
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTPHeaders.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.rdfconnection;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.jena.query.QueryExecution;
+import org.apache.jena.sparql.exec.QueryExec;
+import org.apache.jena.sparql.exec.http.QueryExecHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTPBuilder;
+import org.junit.jupiter.api.Test;
+
+public class TestRDFConnectionHTTPHeaders {
+
+ /**
+ * Test whether connection headers are properly passed on to the query execution.
+ * No query is actually executed.
+ */
+ @Test void test_headers_non_parsed() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderSelectQuery("s")
+ .acceptHeaderAskQuery("a")
+ .acceptHeaderGraph("g")
+ .acceptHeaderDataset("d")
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("s", qe.getAcceptHeaderSelect());
+ assertEquals("a", qe.getAcceptHeaderAsk());
+ assertEquals("g", qe.getAcceptHeaderDescribe());
+ assertEquals("g", qe.getAcceptHeaderConstructGraph());
+ assertEquals("d", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ @Test void test_headers_non_parsed_fallback() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("f", qe.getAcceptHeaderSelect());
+ assertEquals("f", qe.getAcceptHeaderAsk());
+ assertEquals("f", qe.getAcceptHeaderDescribe());
+ assertEquals("f", qe.getAcceptHeaderConstructGraph());
+ assertEquals("f", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ @Test void test_headers_parsed_fallback() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
+ .build()) {
+
+ try (QueryExecution qExec = conn.newQuery()
+ .query("SELECT * { ?s ?p ?o }")
+ .build()) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("f", qe.getAcceptHeaderSelect());
+
+ assertEquals("f", qe.getAcceptHeaderAsk());
+ assertEquals("f", qe.getAcceptHeaderDescribe());
+ assertEquals("f", qe.getAcceptHeaderConstructGraph());
+ assertEquals("f", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ /**
+ * Setting an override-header on the builder should set all
+ * headers on the QueryExecHTTP instance to that override.
+ */
+ @Test
+ public void test_override_header() {
+ try (QueryExecutionHTTP qExec =
+ QueryExecutionHTTPBuilder.create()
+ .endpoint("urn:dummy-service")
+ .queryString("SELECT * { ?s ?p ?o }")
+ .acceptHeader("o") // Override header
+ .build()) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("o", qe.getAppProvidedAcceptHeader());
+ assertEquals("o", qe.getAcceptHeaderSelect());
+ assertEquals("o", qe.getAcceptHeaderAsk());
+ assertEquals("o", qe.getAcceptHeaderDescribe());
+ assertEquals("o", qe.getAcceptHeaderConstructGraph());
+ assertEquals("o", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+}
Review Comment:
Added as `TestRDFConnectionHTTPHeaders.test_override_header_{02, 03}`.
Note, that order matters:
```
.acceptHeaderAskQuery("a")
.acceptHeader("o") // Sets everything to "o" -> overrides setting for "a".
```
The alternative would be to only compute the effective headers during build based on the explicitly set properties.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389221931
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTPHeaders.java:
##########
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.rdfconnection;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.jena.query.QueryExecution;
+import org.apache.jena.sparql.exec.QueryExec;
+import org.apache.jena.sparql.exec.http.QueryExecHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTPBuilder;
+import org.junit.jupiter.api.Test;
+
+public class TestRDFConnectionHTTPHeaders {
+
+ /**
+ * Test whether connection headers are properly passed on to the query execution.
+ * No query is actually executed.
+ */
+ @Test void test_headers_non_parsed() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderSelectQuery("s")
+ .acceptHeaderAskQuery("a")
+ .acceptHeaderGraph("g")
+ .acceptHeaderDataset("d")
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("s", qe.getAcceptHeaderSelect());
+ assertEquals("a", qe.getAcceptHeaderAsk());
+ assertEquals("g", qe.getAcceptHeaderDescribe());
+ assertEquals("g", qe.getAcceptHeaderConstructGraph());
+ assertEquals("d", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ @Test void test_headers_non_parsed_fallback() {
+ try (RDFConnection conn = RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
Review Comment:
There are `acceptHeaderQuery` tests are in RDF**Connection**HTTPHeaders - if desired, they could be duplicated for the RDFLink level.
Note: The comment on the field `acceptSparqlResults` originally read:
> // All purpose SPARQL results header used if above specific cases do not apply.
So I interpreted this as a fallback. An alternative interpretation is that this sets *all* SPARQL query headers similar to `QueryExecHTTPBuilder.acceptHeader`. In that case, separate SPARQL-only fields should be introduced that are not shared with GSP. `acceptHeaderQuery` would then set the fields for sparql graph results (construct and describe) but not for GSP retrieval.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389255394
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTP.java:
##########
@@ -1,99 +0,0 @@
-/*
Review Comment:
These tests used the `getAppProvidedAcceptHeader()` method, which I introduced only for testing in a previous PR and which was also stated in the javadoc ("For testing only."). In hindsight, a better solution would have been a package private method together with the test case in the `org.apache.jena.sparql.exec.http` package within jena-rdfconnection :/
The field and the method are now marked as deprecated - and the behavior for `getAppProvidedAcceptHeader` has changed - so the tests no longer apply.
The value of the `appProvidedAcceptHeader` used to rely on the QueryType - but since this wouldn't work generically for strings, this PR removed this logic. The header is now chosen based on the exec call such as `.ask()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389278231
##########
jena-arq/src/main/java/org/apache/jena/sparql/exec/http/QueryExecHTTP.java:
##########
@@ -119,10 +117,28 @@ public static QueryExecHTTPBuilder service(String serviceURL) {
private HttpClient httpClient = HttpEnv.getDftHttpClient();
private Map<String, String> httpHeaders;
+ public QueryExecHTTP(String serviceURL, Query query, String queryString, int urlLimit,
Review Comment:
Done. The new constructor no longer uses the now deprecated override header, whereas the original one still supports it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2389280797
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTPHeaders.java:
##########
Review Comment:
done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] Choose HTTP headers for non-parsed queries based on API usage. [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on PR #3441:
URL: https://github.com/apache/jena/pull/3441#issuecomment-3334323704
Should be rebased.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org