The fact that you want to set the Accept header implies to me that this
code is in some sort of HTTP server or servlet?  I'm struggling to
understand why you need to set an Accept header at all here?

As I already said the write() method does not do any trickery regarding
Accept headers because Accept headers are a HTTP feature and the write()
code is distinct from any HTTP functionality.

If you are using say the Java servlets API you can fairly easily set a
HTTP response header should you need to, see
http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletResponse.
html

It may be worth you looking at some of the Fuseki utility code for some
pointers, see ResponseModel.java
(http://svn.apache.org/viewvc/jena/trunk/jena-fuseki/src/main/java/org/apac
he/jena/fuseki/servlets/ResponseModel.java?view=markup) and
ResponseResultSet.java
(http://svn.apache.org/viewvc/jena/trunk/jena-fuseki/src/main/java/org/apac
he/jena/fuseki/servlets/ResponseResultSet.java?view=markup)

You really need to clarify what exactly you are doing here?  It sounds
like you are trying to send back some sort of response over HTTP in which
case the relevant header would be Content-Type not Accept anyway.

Rob


On 1/9/13 12:22 PM, "Olivier Rossel" <[email protected]> wrote:

>Ok, thanks for that information.
>So back to my initial concern.
>In this code:
>QueryExecution exec =
>QueryExecutionFactory.create(QueryFactory.create(queryString,
>Syntax.syntaxSPARQL_11), new
>DatasetImpl(ModelFactory.createDefaultModel()));
>exec.execConstruct().write(byteArrayOutputStream);
>
>Is there a way to set the Accept header?
>(and not rely on some Jena trickery in the write(...,...) method)
>
>Envoyé de mon iPhone
>
>Le 9 janv. 2013 à 12:19, Rob Vesse <[email protected]> a écrit :
>
>> No the write() methods do not set any kind of HTTP header, it is
>>separate
>> infrastructure from any HTTP request/response machinery
>> 
>> 
>> Fuseki has separate machinery that determines the appropriate writer to
>>be
>> used based on the users Accept header and then sets the appropriate
>> Content-Type header before writing out the response
>> 
>> Rob
>> 
>> On 1/9/13 11:01 AM, "Olivier Rossel" <[email protected]> wrote:
>> 
>>>> The current accept negotiation in Fuseki is based on
>>>> 
>>>> application/rdf+xml, text/turtle, application/turtle,
>>>> application/x-turtle,
>>>> application/n-triples, text/plain
>>> 
>>> Interesting, thanks for that list!
>>> 
>>> 
>>>> "Accept: text/turtle" is to be preferred.
>>>> 
>>>>    r.write(byteArrayOutputStream, "TTL");
>>> 
>>> So the r.write(..., ...) method effectively set an Accept header, true?
>> 

Reply via email to