You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@jena.apache.org by "Aklakan (via GitHub)" <gi...@apache.org> on 2024/01/31 23:51:54 UTC
[I] Explicit HTTP headers on RDFConnectionRemote not always forwarded [jena]
Aklakan opened a new issue, #2233:
URL: https://github.com/apache/jena/issues/2233
### Version
5.0.0-SNAPSHOT
### What happened?
Setting headers explicitly using e.g. `.acceptHeaderSelectQuery(WebContent.contentTypeResultsXML)` does not work consistently across the APIs.
Only `RDFConnection.query(queryObject)` works as expected.
* For query *strings*, internally the query type is always considered QueryType.UNKNOWN and the custom header is ignored - even if query parsing is enabled (it is by default):
https://github.com/apache/jena/blob/0fd96b64e1f404477eb8f95cefa49c776d907c27/jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java#L256
* For query *objects*, using `RDFConnection.newQuery()` does not forward the header:
See https://github.com/apache/jena/blob/0fd96b64e1f404477eb8f95cefa49c776d907c27/jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java#L268
```java
class Test {
public static void main(String[] args) {
JenaSystem.init();
try (RDFConnection conn = RDFConnectionRemote.newBuilder()
.queryEndpoint("https://dbpedia.org/sparql")
.acceptHeaderSelectQuery(WebContent.contentTypeResultsXML)
.build()) {
String queryStr = "SELECT * { ?s <urn:bar> <urn:baz> }";
System.out.println("String - Direct");
// DEBUG org.apache.jena.http.HTTP: > GET https://dbpedia.org/sparql?query=SELECT%20%2A%20%7B%20?s%20%3Curn:bar%3E%20%3Curn:baz%3E%20%7D
// DEBUG org.apache.jena.http.HTTP: Accept application/sparql-results+json, application/sparql-results+xml;q=0.9, text/tab-separated-values;q=0.7, text/csv;q=0.5,application/json;q=0.2,application/xml;q=0.2,*/*;q=0.1
try (QueryExecution qe = conn.query(queryStr)) {
ResultSet rs = qe.execSelect().materialise();
System.out.println(ResultSetFormatter.asText(rs));
}
System.out.println("String - Builder");
// DEBUG org.apache.jena.http.HTTP: > GET https://dbpedia.org/sparql?query=SELECT%20%2A%20%7B%20?s%20%3Curn:bar%3E%20%3Curn:baz%3E%20%7D
// DEBUG org.apache.jena.http.HTTP: Accept application/sparql-results+json, application/sparql-results+xml;q=0.9, text/tab-separated-values;q=0.7, text/csv;q=0.5,application/json;q=0.2,application/xml;q=0.2,*/*;q=0.1
try (QueryExecution qe = conn.newQuery().query(queryStr).build()) {
ResultSet rs = qe.execSelect().materialise();
System.out.println(ResultSetFormatter.asText(rs));
}
Query query = QueryFactory.create(queryStr);
System.out.println("Query - Direct");
// DEBUG org.apache.jena.http.HTTP: > GET https://dbpedia.org/sparql?query=SELECT%20%20%2A%0AWHERE%0A%20%20%7B%20?s%20%20%3Curn:bar%3E%20%20%3Curn:baz%3E%20%7D%0A
// DEBUG org.apache.jena.http.HTTP: Accept application/sparql-results+xml
try (QueryExecution qe = conn.query(query)) {
ResultSet rs = qe.execSelect().materialise();
System.out.println(ResultSetFormatter.asText(rs));
}
System.out.println("Query - Builder");
// DEBUG org.apache.jena.http.HTTP: > GET https://dbpedia.org/sparql?query=SELECT%20%20%2A%0AWHERE%0A%20%20%7B%20?s%20%20%3Curn:bar%3E%20%20%3Curn:baz%3E%20%7D%0A
// DEBUG org.apache.jena.http.HTTP: Accept application/sparql-results+json, application/sparql-results+xml;q=0.9, text/tab-separated-values;q=0.7, text/csv;q=0.5,application/json;q=0.2,application/xml;q=0.2,*/*;q=0.1
try (QueryExecution qe = conn.newQuery().query(query).build()) {
ResultSet rs = qe.execSelect().materialise();
System.out.println(ResultSetFormatter.asText(rs));
}
}
}
}
```
### Relevant output and stacktrace
_No response_
### Are you interested in making a pull request?
Maybe
--
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: issues-unsubscribe@jena.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
Re: [I] Explicit Accept headers on RDFConnectionRemote not always forwarded [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs closed issue #2233: Explicit Accept headers on RDFConnectionRemote not always forwarded
URL: https://github.com/apache/jena/issues/2233
--
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: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
Re: [I] Explicit Accept headers on RDFConnectionRemote not always forwarded [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on issue #2233:
URL: https://github.com/apache/jena/issues/2233#issuecomment-1935079561
The use case is to improve abstraction: Once the connection is configured with the send mode, then the rest of the application no longer has to concern itself with that aspect. Any call to `conn.query()` or `conn.newQuery()` will default to the configured send mode. This is useful when the triple store one connects to e.g. does not support `QuerySendMode.asGetWithLimitBody`. Otherwise, the application would have to break the encapsulation of the RDFConnection for each query: upcast the QueryExecBuilder to QueryExecHTTPBuilder and set the send mode - which wouldn't work for a RDFConnection to a Dataset.
> There seem to be visibility changes that don't seem necessary.
The constructor of `QueryExecHTTBuilder` could go from private to protected (rather than public). I think the other private attributes are passed to the `buildX` function, so their visibility could remain unchanged.
Will check in detail and separate the PR tomorrow.
--
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: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
Re: [I] Explicit Accept headers on RDFConnectionRemote not always forwarded [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on issue #2233:
URL: https://github.com/apache/jena/issues/2233#issuecomment-1930768868
There is now an initial PR based on subclassing ARQ's QueryExecHTTPBuilder in an internal class of RDFLinkHTTP.
The main question is, whether this is an appropriate approach to a fix the issue - or whether it should be resolved differently.
--
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: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
Re: [I] Explicit Accept headers on RDFConnectionRemote not always forwarded [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on issue #2233:
URL: https://github.com/apache/jena/issues/2233#issuecomment-1930965743
As a final update, I added methods to set QuerySendMode and UpdateSendMode on the remote builders.
Some legacy triple store instances don't support `QueryMode.asGetWithLimitBody` - so in these cases its possible to set the mode to `QueryMode.asGetWithLimitForm` on the connection.
Concrete use case example:
Does not work:
```
curl -X POST -H 'Content-Type: application/sparql-query;charset=utf-8' https://staging.databus.dbpedia.org/repo/sparql --data-urlencode 'SELECT * { ?s a ?o } LIMIT 10'
```
Works:
```
curl -X POST https://staging.databus.dbpedia.org/repo/sparql --data-urlencode 'query=SELECT * { ?s a ?o } LIMIT 10'
```
--
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: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
Re: [I] Explicit Accept headers on RDFConnectionRemote not always forwarded [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on issue #2233:
URL: https://github.com/apache/jena/issues/2233#issuecomment-1936805113
> One PR for two issues and two commits would be OK.
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: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
Re: [I] Explicit Accept headers on RDFConnectionRemote not always forwarded [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on issue #2233:
URL: https://github.com/apache/jena/issues/2233#issuecomment-1934924635
> As a final update, I added methods to set QuerySendMode and UpdateSendMode on the remote builders.
> This could be handled as a separate issue if desired.
Yes please. I can't see which changes relate to this issue and there aren't separate commit. One PR for two issues and two commits would be OK.
There seem to be visibility changes that don't seem necessary. I am trying to understand why QueryExecHTTPBuilder header setters sendmode setters aren't sufficient.
Do we need a clone-like operation (from a builder or from a built execution object) to create a builder to specialise?
--
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: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org