iipsrv icon indicating copy to clipboard operation
iipsrv copied to clipboard

Wrong 'Content-Type' returned when 'Accept' type not specified

Open bseeger opened this issue 7 years ago • 2 comments

First off, I just want to say I consider this very, very minor... but figured I'd mention it.

In my reading of the IIIF API 2.0 spec, JSON-LD should be returned, which is done correctly. But unless the 'Accept' type was specified as 'application/ld+json', the 'Content-Type' should be listed as 'application/json'.

IIPServer version 1.0 seems to only return 'application/ld+json' in the 'Content-Type' field.

curl https://mydomain.com/iiif/PalaisDuLouvre.tif/info.json -i HTTP/1.1 200 OK Date: Tue, 12 Dec 2017 15:45:15 GMT Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips mod_fcgid/2.3.9 PHP/7.1.7 Cache-Control: max-age=86400 Last-Modified: Thu, 07 Dec 2017 20:44:15 GMT Content-Type: application/ld+json Transfer-Encoding: chunked ...

^^ that should probably be 'application/json'

curl -H "Accept: application/json" https://mydomain.com/iiif/PalaisDuLouvre.tif/info.json -i HTTP/1.1 200 OK Date: Tue, 12 Dec 2017 15:43:19 GMT Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips mod_fcgid/2.3.9 PHP/7.1.7 Cache-Control: max-age=86400 Last-Modified: Thu, 07 Dec 2017 20:44:15 GMT Content-Type: application/ld+json Transfer-Encoding: chunked ...

^^ that should also be 'application/json'

Honestly, though, as I write this, I can't say I really understand what the spec is trying to do here. Maybe it's trying to be friendly to clients who don't understand JSON-LD?

bseeger avatar Dec 12 '17 15:12 bseeger

Sorry for all the noise here -- this is really, really minor and I could see an argument for keeping the content type the way it is. The spec is a little bit ambiguous.

bseeger avatar Dec 12 '17 15:12 bseeger

Looking at the latest version of the image API, it says:

If the client explicitly wants the JSON-LD content-type, then it must specify this in an Accept header, otherwise the server must return the regular JSON content-type.

So, technically you are right. In order to make this work as it should, iipsrv would need to parse the Accept header and change the the content-type whenever the Accept header is set. But as you say, this is very very minor, so I'm not sure it's worth the extra complication. I'll leave this issue open for now unless there's a real use-case where this causes problems.

ruven avatar Dec 12 '17 17:12 ruven