Skip to content

[SPARQLConnector] CONSTRUCT queries should use RDF media types in Accept header #3332

@smeckler

Description

@smeckler

Hi,
I would like to change the HTTP Accept header that the SPARQLConnector sends for SPARQL CONSTRUCT queries.

current behavior: SPARQLConnector sets the Accept header to the user-defined 'returnFormat' or default media types. The resulting Accept header uses media types for SPARQL results, e.g. application/sparql-results+json for returnFormat=json

desired behavior: SPARQLConnector selects only RDF graph media types, e.g. application/ld+json for CONSTRUCT or DESCRIBE queries which return a graph

I created a small PR for checking the query type and selecting the media types accordingly.

SPARQL 1.1 protocol

The response body of a successful query operation with a 2XX response is either:
    a SPARQL Results Document in [XML](https://www.w3.org/TR/rdf-sparql-XMLres/), [JSON](https://www.w3.org/TR/sparql11-results-json/), or [CSV/TSV](https://www.w3.org/TR/sparql11-results-csv-tsv/) format (for SPARQL Query forms [SELECT](https://www.w3.org/2001/sw/DataAccess/rq23/#select) and [ASK](https://www.w3.org/2001/sw/DataAccess/rq23/#ask)); or,
    an RDF graph [[RDF-CONCEPTS](https://www.w3.org/TR/sparql11-protocol/#rdf-concepts)] serialized, for example, in the [RDF/XML syntax](https://www.w3.org/TR/rdf-syntax-grammar/) [[RDF-XML](https://www.w3.org/TR/sparql11-protocol/#rdf-xml)], or an equivalent RDF graph serialization, for SPARQL Query forms [DESCRIBE](https://www.w3.org/2001/sw/DataAccess/rq23/#describe) and [CONSTRUCT](https://www.w3.org/2001/sw/DataAccess/rq23/#construct)).

In section 3.1.3, there is an example of an HTTP request with a construct query:

  • the request uses the HTTP header Accept: text/turtle, application/rdf+xml
  • the response has the HTTP header Content-Type: text/turtle

Thank you for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions