W3C home > Mailing lists > Public > public-linked-json@w3.org > August 2015

JSON-LD Accept Header

From: Haag, Jason <jason.haag.ctr@adlnet.gov>
Date: Thu, 6 Aug 2015 12:44:35 -0500
Message-ID: <CAHjqjnJ-XHPM4GM=E=my1WEWPws+DUO-PcsRpGv447W7_yf0rA@mail.gmail.com>
To: public-linked-json@w3.org

I'm currently testing content negotiation on Apache 2.4.7 on ubuntu. I have
enabled htaccess and added the mime types below in htaccess. I also added
application/ld+json to the mime.types config file in apache. The header
requests all seem to be working fine except JSON-LD. Is there anything I
need to add to the JSON-LD header accept? When I try to test this out with
curl the server returns HTML, RDF/XML, and Turtle content types as
expected. But when I try the Accept: application/ld+json" header it returns
RDF/XML. Do I need to explicitly set up some type of content-type match or
 use MultiviewsMatch? I know this question is specific to apache, but I
can't seem to find any modern examples of the best way to do this for
JSON-LD. Thanks in advance for any suggestions or tips.

Here are the curl examples:

curl --header "Accept: application/rdf+xml" -L

curl --header "Accept: text/turtle" -L http://xapi.vocab.pub/ontology
curl --header "Accept: application/ld+json" -L


# Turn off MultiViews
Options -MultiViews

# Rewrite engine setup
RewriteEngine On

# Directive to allow Cross origin requests
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with,
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
# Directive to ensure *.rdf files served as appropriate content type,
# if not present in main apache config
AddType text/html .html
AddType application/rdf+xml .rdf
AddType  text/turtle   .ttl
AddType application/ld+json .jsonld

# Rewrite rule to serve HTML content from the vocabulary URI if requested
RewriteCond %{HTTP_ACCEPT}
RewriteCond %{HTTP_ACCEPT} text/html [OR]
RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/.*
RewriteRule ^ontology$ http://xapi.vocab.pub/ontology/index.html [R=303]

# Rewrite rule to serve RDF/XML content from the vocabulary URI if requested
RewriteCond %{HTTP_ACCEPT} application/rdf\+xml
RewriteRule ^ontology$ http://xapi.vocab.pub/ontology.rdf [R=303]

# Rewrite rule to serve Turtle content from the vocabulary URI if requested
RewriteCond %{HTTP_ACCEPT} text/turtle
RewriteRule ^ontology$ http://xapi.vocab.pub/ontology.ttl [R=303]

# Rewrite rule to serve JSON-LD content from the vocabulary URI if requested
RewriteCond %{HTTP_ACCEPT} application/ld+json
RewriteRule ^ontology$ http://xapi.vocab.pub/ontology.jsonld [R=303]

# Choose the default response
# ---------------------------

# Rewrite rule to serve the RDF/XML content from the vocabulary URI by
RewriteRule ^ontology$ http://xapi.vocab.pub/ontology.rdf [R=303]
Received on Thursday, 6 August 2015 17:45:45 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:18:45 UTC