[ 
https://issues.apache.org/jira/browse/JENA-2133?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17380157#comment-17380157
 ] 

Rem Collier commented on JENA-2133:
-----------------------------------

Hi Rob,

I understand the Content Negotiation part. In the case of the server i am 
working with, the server is configured to return both XML/RDF and TURTLE.  
Based on the order provided, the server always returns turtle, even when I 
request XML/RDF. I suppose, I had expected that the priorities of the media 
types would be revised so that the preferred type has the highest priority...

So basically, reading the second part of the comment, the recommendation is not 
to bother with the read(...) method or RDFDataMgr (which had the same result), 
but to use something lower level. I had previously solved the problem by 
writing my own HttpClient code and then dumping the contents of the entity into 
a different read(...) method:
 
{code:java}
HttpGet get = new HttpGet();
get.setURI(URI.create("http://localhost:8080/sim";));
get.setHeader("Accept", "text/turtle");
HttpClient client = HttpClientBuilder.create().build();
HttpResponse response = client.execute(get);
HttpEntity entity = response.getEntity();
model.read(entity.getContent(), "http://127.0.1.1:8080/sim", "TURTLE";);{code}
 

> 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)

Reply via email to