[
https://issues.apache.org/jira/browse/JENA-2133?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17380140#comment-17380140
]
Rob Vesse commented on JENA-2133:
---------------------------------
Jena is doing [Content
Negotiation|https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation],
for remote content it does not assume that the language you say you want to
read it as is the language the remote server will necessarily respond with (or
even supports in some cases). It sends a broad {{Accept}} header covering the
formats it supports in Jena's order of preference.
What do you mean by the following:
bq. This results in the knowledge being downloaded in the incorrect format...
Do you get an error? Something else?
RDF is an abstract data model with many interchangeable serialisations,
whatever serialisation the server chooses to respond with the same triples will
be encoded in its response and loaded by Jena (possibly with some minor
differences around blank node identifier assignment) i.e. Media Type should be
irrelevant
Generally there are two approaches for reading remote data:
* Do not specify the language at all and let Jena handle the content
negotiation for you
* Use lower level Parser APIs which give you more control over how a remote
resource is retrieved and parsed e.g.
https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/riot/RDFParserBuilder.html
> Jena sends multiple media types in accept header when reading knowledge via a
> url
> ---------------------------------------------------------------------------------
>
> Key: JENA-2133
> URL: https://issues.apache.org/jira/browse/JENA-2133
> Project: Apache Jena
> Issue Type: Bug
> Components: RIOT
> Affects Versions: Jena 4.1.0
> Environment: Windows / WSL2 / Maven / Java 14.0.2
> Reporter: Rem Collier
> Priority: Major
> Fix For: Jena 4.2.0
>
>
> When I create a basic model and use the read(...) method to read a remote
> file, Jena includes multiple media types in the request header.
>
> {code:java}
> Accept:
> text/turtle,application/n-triples;q=0.9,application/rdf+xml;q=0.7,application/trig,application/n-quads;q=0.9,application/ld+json;q=0.8,*/*;q=0.5{code}
> The ordering and priorities of the media types does not change, even when
> different formats are chosen.
> i.e. the following code gives the above list of media types:
>
>
> {code:java}
> Model model = ModelFactory.createDefaultModel();
> model.read("http://localhost:8080/sim", "TURTLE"); {code}
> However, the code below also gives the same list of media types:
>
> {code:java}
> Model model = ModelFactory.createDefaultModel();
> model.read("http://localhost:8080/sim", "RDF/XML");{code}
>
> This results in the knowledge being downloaded in the incorrect format...
--
This message was sent by Atlassian Jira
(v8.3.4#803005)