You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Roberto García <ro...@gmail.com> on 2015/09/15 14:55:29 UTC

Configure DatasetAccessor Transfer-Encoding

Dear all,

While trying to interact with a SPARQL EndPoint using the DatasetAccessor
(or directly DatasetGraphAccessorHTTP) I'm experiencing problems because
chunked is used as the Transfer-Encoding the the endpoint doesn't support
it.

Is it possible to configure the underlying HTTP client to avoid this
transfer encoding mode? Looking at the documentation and code of these
classes I haven't been able to realise how.

Best regards,


Roberto García
http://rhizomik.net/~roberto/

Re: Configure DatasetAccessor Transfer-Encoding

Posted by Andy Seaborne <an...@apache.org>.
On 15/09/15 22:15, Roberto García wrote:
>>
>> (Jena version?)
>>
>
> 2.13.0

OK - Thanks

So what is the target system?

What does
   http://openphacts-8.cloud.anzonow.com:8080
use for HTTP?

Wikipedia implies it is required for HTTP 1.1:

https://en.wikipedia.org/wiki/Chunked_transfer_encoding
[[
For version 1.1 of the HTTP protocol, the chunked transfer mechanism is 
considered to be always and anyways acceptable,
]]

As far as I can see, this is the default setup for HTTP components 4.2.6 
when sending an entity without knowing it's length. Either 
Content-length is set or chunked encoding is used.  It's not 
controllable as  far as I can see.

Jena tries not to print to a buffer to find the length - some data 
formats naturally stream.

	Andy

>
>
>> Which direction is the chunk encoding? Sending RDF to the server or
>> receiving RDF from the server?
>>
>
> Sending to the server.
>
> As far as I can see, it's not set by Jena code.  Jena uses Apache
>> HttpComponents so it might be the default there somewhere, though on a
>> quick scan, the default is off.
>>
>> There are two related places: the Entity used to construct the body to
>> send and the HTTP request to retrieve data.  Do you have trace of the HTTP
>> request?
>>

So this is a call of add(String graphUri, Model data)?

Odd:

POST /runQuery.html?graph=http%3A%... HTTP/1.1
...

"query"? ".html"? Just based on this, is that a Graph Store Protocol 
endpoint?


>
> ...
> 01:34:00.669 [main] DEBUG org.apache.http.headers - >> POST /runQuery
> .html?graph=http%3A%... HTTP/1.1
> 01:34:00.669 [main] DEBUG org.apache.http.headers - >> User-Agent:
> Apache-Jena-ARQ/2.13.0
> 01:34:00.669 [main] DEBUG org.apache.http.headers - >> Transfer-Encoding:
> chunked
> 01:34:00.669 [main] DEBUG org.apache.http.headers - >> Content-Type:
> application/rdf+xml
> 01:34:00.669 [main] DEBUG org.apache.http.headers - >> Host: sparql
> .demo.com:8080 <http://openphacts-8.cloud.anzonow.com:8080/>
> 01:34:00.669 [main] DEBUG org.apache.http.headers - >> Connection:
> Keep-Alive
> 01:34:00.694 [main] DEBUG org.apache.http.wire - >> "2000[\r][\n]"
> 01:34:00.694 [main] DEBUG org.apache.http.wire - >> "<rdf:RDF[\n]"
> ...
>
> And for the response:
>
> ...
> 01:34:02.755 [main] DEBUG org.apache.jena.riot.web.HttpOp - [1] 400 Bad
> Request
> 01:34:02.757 [main] DEBUG org.apache.http.wire - << "<html>[\n]"
> 01:34:02.757 [main] DEBUG org.apache.http.wire - << "<body>[\n]"
> 01:34:02.757 [main] DEBUG org.apache.http.wire - << "<h1>Error
> Encountered:</h1>[\n]"
> 01:34:02.757 [main] DEBUG org.apache.http.wire - << "Error - detected at
> line 0 (char 0) near '2000': syntax error - syntax error[\n]"
> 01:34:02.757 [main] DEBUG org.apache.http.wire - << "</body>[\n]"
> 01:34:02.757 [main] DEBUG org.apache.http.wire - << "</html>[\n]"
> ...
>
>
>>
>>
>>          Andy
>>
>> For a Graph Store Protocol request I see the request as being 9thisis from
>> "fuseki1 -v"
>>
>> GET http://localhost:3030/ds/data?default
>>     Accept
>> text/turtle,application/n-triples;q=0.9,application/ld+json;q=0.8,application/rdf+xml;q=0.7,*/*;q=0.5
>>     Connection           keep-alive
>>     User-Agent           Apache-Jena-ARQ/3.0.1-SNAPSHOT
>>     Host                 localhost:3030
>>     Get: Content-Type=text/turtle, Charset=null => Turtle
>>     Content-Type         text/turtle
>>     Server               Fuseki (1.3.1-SNAPSHOT)
>>     Access-Control-Allow-Origin *
>>     Vary                 Accept,Accept-Encoding,Accept-Charset
>>
>


Re: Configure DatasetAccessor Transfer-Encoding

Posted by Roberto García <ro...@rhizomik.net>.
Well, it seems the chunked mode is activated automatically if the content
size is not known beforehand. I've been able to disable chunked mode by
working directly with HttpClient and first serialising the whole model to
be posted to a ByteArrayEntity.

This behaviour described in the HttpClient documentation:
http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/entity/AbstractHttpEntity.html#setChunked%28boolean%29

Best,

Roberto García
http://rhizomik.net/~roberto


On Tue, Sep 15, 2015 at 11:15 PM, Roberto García <ro...@rhizomik.net>
wrote:

> (Jena version?)
>>
>
> 2.13.0
>
>
>> Which direction is the chunk encoding? Sending RDF to the server or
>> receiving RDF from the server?
>>
>
> Sending to the server.
>
> As far as I can see, it's not set by Jena code.  Jena uses Apache
>> HttpComponents so it might be the default there somewhere, though on a
>> quick scan, the default is off.
>>
>> There are two related places: the Entity used to construct the body to
>> send and the HTTP request to retrieve data.  Do you have trace of the HTTP
>> request?
>>
>
> ...
> 01:34:00.669 [main] DEBUG org.apache.http.headers - >> POST /runQuery
> .html?graph=http%3A%... HTTP/1.1
> 01:34:00.669 [main] DEBUG org.apache.http.headers - >> User-Agent:
> Apache-Jena-ARQ/2.13.0
> 01:34:00.669 [main] DEBUG org.apache.http.headers - >> Transfer-Encoding:
> chunked
> 01:34:00.669 [main] DEBUG org.apache.http.headers - >> Content-Type:
> application/rdf+xml
> 01:34:00.669 [main] DEBUG org.apache.http.headers - >> Host: sparql
> .demo.com:8080 <http://openphacts-8.cloud.anzonow.com:8080/>
> 01:34:00.669 [main] DEBUG org.apache.http.headers - >> Connection:
> Keep-Alive
> 01:34:00.694 [main] DEBUG org.apache.http.wire - >> "2000[\r][\n]"
> 01:34:00.694 [main] DEBUG org.apache.http.wire - >> "<rdf:RDF[\n]"
> ...
>
> And for the response:
>
> ...
> 01:34:02.755 [main] DEBUG org.apache.jena.riot.web.HttpOp - [1] 400 Bad
> Request
> 01:34:02.757 [main] DEBUG org.apache.http.wire - << "<html>[\n]"
> 01:34:02.757 [main] DEBUG org.apache.http.wire - << "<body>[\n]"
> 01:34:02.757 [main] DEBUG org.apache.http.wire - << "<h1>Error
> Encountered:</h1>[\n]"
> 01:34:02.757 [main] DEBUG org.apache.http.wire - << "Error - detected at
> line 0 (char 0) near '2000': syntax error - syntax error[\n]"
> 01:34:02.757 [main] DEBUG org.apache.http.wire - << "</body>[\n]"
> 01:34:02.757 [main] DEBUG org.apache.http.wire - << "</html>[\n]"
> ...
>
>
>>
>>
>>         Andy
>>
>> For a Graph Store Protocol request I see the request as being 9thisis
>> from "fuseki1 -v"
>>
>> GET http://localhost:3030/ds/data?default
>>    Accept
>> text/turtle,application/n-triples;q=0.9,application/ld+json;q=0.8,application/rdf+xml;q=0.7,*/*;q=0.5
>>    Connection           keep-alive
>>    User-Agent           Apache-Jena-ARQ/3.0.1-SNAPSHOT
>>    Host                 localhost:3030
>>    Get: Content-Type=text/turtle, Charset=null => Turtle
>>    Content-Type         text/turtle
>>    Server               Fuseki (1.3.1-SNAPSHOT)
>>    Access-Control-Allow-Origin *
>>    Vary                 Accept,Accept-Encoding,Accept-Charset
>>
>
>

Re: Configure DatasetAccessor Transfer-Encoding

Posted by Roberto García <ro...@rhizomik.net>.
>
> (Jena version?)
>

2.13.0


> Which direction is the chunk encoding? Sending RDF to the server or
> receiving RDF from the server?
>

Sending to the server.

As far as I can see, it's not set by Jena code.  Jena uses Apache
> HttpComponents so it might be the default there somewhere, though on a
> quick scan, the default is off.
>
> There are two related places: the Entity used to construct the body to
> send and the HTTP request to retrieve data.  Do you have trace of the HTTP
> request?
>

...
01:34:00.669 [main] DEBUG org.apache.http.headers - >> POST /runQuery
.html?graph=http%3A%... HTTP/1.1
01:34:00.669 [main] DEBUG org.apache.http.headers - >> User-Agent:
Apache-Jena-ARQ/2.13.0
01:34:00.669 [main] DEBUG org.apache.http.headers - >> Transfer-Encoding:
chunked
01:34:00.669 [main] DEBUG org.apache.http.headers - >> Content-Type:
application/rdf+xml
01:34:00.669 [main] DEBUG org.apache.http.headers - >> Host: sparql
.demo.com:8080 <http://openphacts-8.cloud.anzonow.com:8080/>
01:34:00.669 [main] DEBUG org.apache.http.headers - >> Connection:
Keep-Alive
01:34:00.694 [main] DEBUG org.apache.http.wire - >> "2000[\r][\n]"
01:34:00.694 [main] DEBUG org.apache.http.wire - >> "<rdf:RDF[\n]"
...

And for the response:

...
01:34:02.755 [main] DEBUG org.apache.jena.riot.web.HttpOp - [1] 400 Bad
Request
01:34:02.757 [main] DEBUG org.apache.http.wire - << "<html>[\n]"
01:34:02.757 [main] DEBUG org.apache.http.wire - << "<body>[\n]"
01:34:02.757 [main] DEBUG org.apache.http.wire - << "<h1>Error
Encountered:</h1>[\n]"
01:34:02.757 [main] DEBUG org.apache.http.wire - << "Error - detected at
line 0 (char 0) near '2000': syntax error - syntax error[\n]"
01:34:02.757 [main] DEBUG org.apache.http.wire - << "</body>[\n]"
01:34:02.757 [main] DEBUG org.apache.http.wire - << "</html>[\n]"
...


>
>
>         Andy
>
> For a Graph Store Protocol request I see the request as being 9thisis from
> "fuseki1 -v"
>
> GET http://localhost:3030/ds/data?default
>    Accept
> text/turtle,application/n-triples;q=0.9,application/ld+json;q=0.8,application/rdf+xml;q=0.7,*/*;q=0.5
>    Connection           keep-alive
>    User-Agent           Apache-Jena-ARQ/3.0.1-SNAPSHOT
>    Host                 localhost:3030
>    Get: Content-Type=text/turtle, Charset=null => Turtle
>    Content-Type         text/turtle
>    Server               Fuseki (1.3.1-SNAPSHOT)
>    Access-Control-Allow-Origin *
>    Vary                 Accept,Accept-Encoding,Accept-Charset
>

Re: Configure DatasetAccessor Transfer-Encoding

Posted by Andy Seaborne <an...@apache.org>.
On 15/09/15 13:55, Roberto García wrote:
> Dear all,
>
> While trying to interact with a SPARQL EndPoint using the DatasetAccessor
> (or directly DatasetGraphAccessorHTTP) I'm experiencing problems because
> chunked is used as the Transfer-Encoding the the endpoint doesn't support
> it.
>
> Is it possible to configure the underlying HTTP client to avoid this
> transfer encoding mode? Looking at the documentation and code of these
> classes I haven't been able to realise how.
>
> Best regards,
>
>
> Roberto García
> http://rhizomik.net/~roberto/
>

(Jena version?)

Which direction is the chunk encoding? Sending RDF to the server or 
receiving RDF from the server?

As far as I can see, it's not set by Jena code.  Jena uses Apache 
HttpComponents so it might be the default there somewhere, though on a 
quick scan, the default is off.

There are two related places: the Entity used to construct the body to 
send and the HTTP request to retrieve data.  Do you have trace of the 
HTTP request?


	Andy

For a Graph Store Protocol request I see the request as being 9thisis 
from "fuseki1 -v"

GET http://localhost:3030/ds/data?default
    Accept 
text/turtle,application/n-triples;q=0.9,application/ld+json;q=0.8,application/rdf+xml;q=0.7,*/*;q=0.5
    Connection           keep-alive
    User-Agent           Apache-Jena-ARQ/3.0.1-SNAPSHOT
    Host                 localhost:3030
    Get: Content-Type=text/turtle, Charset=null => Turtle
    Content-Type         text/turtle
    Server               Fuseki (1.3.1-SNAPSHOT)
    Access-Control-Allow-Origin *
    Vary                 Accept,Accept-Encoding,Accept-Charset