openlink / virtuoso-opensource

Virtuoso is a high-performance and scalable Multi-Model RDBMS, Data Integration Middleware, Linked Data Deployment, and HTTP Application Server Platform
https://vos.openlinksw.com
Other
867 stars 210 forks source link

Accept header isn't being respected if an unexpected alias is provided in the URL parameter "format" #715

Open dayures opened 6 years ago

dayures commented 6 years ago

It looks like the the Accept header isn't being respected

curl -I "http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=SELECT+%3Flabel%0D%0AWHERE+%7B%0D%0A<http%3A%2F%2Fdbpedia.org%2Fresource%2FAsturias>+rdfs%3Alabel+%3Flabel+.%0D%0A%7D&format=tsv" returns Content-Type: application/sparql-results+xml; charset=UTF-8

curl -H "Accept: text/tab-separated-values" -I "http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=SELECT+%3Flabel%0D%0AWHERE+%7B%0D%0A<http%3A%2F%2Fdbpedia.org%2Fresource%2FAsturias>+rdfs%3Alabel+%3Flabel+.%0D%0A%7D&format=tsv" returns HTTP/1.1 406 Unacceptable

Related to #713

TallTed commented 6 years ago

Looks like we could add better error handling for some edge-cases, like this one. The bad &format value seems to divert handling of the Accept: header value.

Meanwhile, I suggest you use the Accept: header (where I think you'll agree that a MIME type is the correct value, rather than tsv or any other alias) and leave the &format out of the URI, as --

curl -I -H "Accept: text/tab-separated-values" "http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=SELECT+%3Flabel%0D%0AWHERE+%7B%0D%0A<http%3A%2F%2Fdbpedia.org%2Fresource%2FAsturias>+rdfs%3Alabel+%3Flabel+.%0D%0A%7D"

-- which gets me --

HTTP/1.1 200 OK
Date: Fri, 23 Feb 2018 17:12:54 GMT
Content-Type: text/tab-separated-values; charset=UTF-8