diff --git a/.platform/nginx/conf.d/accepts.conf b/.platform/nginx/conf.d/accepts.conf index 93aafa3..a9380de 100644 --- a/.platform/nginx/conf.d/accepts.conf +++ b/.platform/nginx/conf.d/accepts.conf @@ -8,9 +8,9 @@ map $uri $custom_content_type { } map $http_accept $version { - default "v3"; - "~http://iiif.io/api/presentation/2/context.json" "v2"; - "~http://iiif.io/api/presentation/3/context.json" "v3"; + default "3"; + "~http://iiif.io/api/presentation/2/context.json" "2"; + "~http://iiif.io/api/presentation/3/context.json" "3"; } map $http_accept $webp_suffix { diff --git a/.platform/nginx/conf.d/elasticbeanstalk/00_application.conf b/.platform/nginx/conf.d/elasticbeanstalk/00_application.conf index 880a287..538b581 100644 --- a/.platform/nginx/conf.d/elasticbeanstalk/00_application.conf +++ b/.platform/nginx/conf.d/elasticbeanstalk/00_application.conf @@ -83,10 +83,12 @@ location /api/cookbook/recipe/0057-publishing-v2-and-v3/manifest.json { proxy_hide_header x-amz-id-2; proxy_hide_header x-amz-request-id; proxy_intercept_errors on; - proxy_pass https://preview.iiif.io:443/cookbook/0057-conneg/recipe/0057-publishing-v2-and-v3/manifest-$version.json; + proxy_pass https://preview.iiif.io:443/cookbook/0057-conneg/recipe/0057-publishing-v2-and-v3/manifest-v$version.json; # add_header 'Access-Control-Allow-Origin' '*'; + proxy_hide_header 'Content-Type'; add_header 'Cache-Control' 'public, no-transform, max-age=300'; add_header "X-UA-Compatible" "IE=Edge,chrome=1"; + add_header 'Content-Type' "application/ld+json;profile=http://iiif.io/api/presentation/$version/context.json"; } location ^~ /api/ { diff --git a/tests/TestJsonLD.py b/tests/TestJsonLD.py index 43a7be2..f0f42dd 100755 --- a/tests/TestJsonLD.py +++ b/tests/TestJsonLD.py @@ -30,20 +30,37 @@ def test_jsonldmimetype(self): def test_cookbook_manifest(self): url = '%s/%s' % (self.baseurl, 'api/cookbook/recipe/0057-publishing-v2-and-v3/manifest.json') - print (url) with urlopen(url) as urlPointer: + content_type = urlPointer.getheader('Content-Type') + self.assertEqual(content_type, "application/ld+json;profile=http://iiif.io/api/presentation/3/context.json", "Response should give the IIIF version") + + cors = urlPointer.getheader('access-control-allow-origin') + #self.assertEqual(cors, "*", "Cors header set incorrectly") + manifest = json.loads(urlPointer.read().decode()) self.assertEqual(manifest['@context'], 'http://iiif.io/api/presentation/3/context.json', 'Expected default retrieval of manifest to be version 3') opener = request.build_opener() opener.addheaders = [('Accept', "application/ld+json;profile=http://iiif.io/api/presentation/3/context.json")] with opener.open(url) as urlPointer: + content_type = urlPointer.getheader('Content-Type') + self.assertEqual(content_type, "application/ld+json;profile=http://iiif.io/api/presentation/3/context.json", "Response should give the IIIF version") + + cors = urlPointer.getheader('access-control-allow-origin') + #self.assertEqual(cors, "*", "Cors header set incorrectly") + manifest = json.loads(urlPointer.read().decode()) self.assertEqual(manifest['@context'], 'http://iiif.io/api/presentation/3/context.json', 'Passing the 3 accept header should get version 3 but got version 2') opener = request.build_opener() opener.addheaders = [('Accept', "application/ld+json;profile=http://iiif.io/api/presentation/2/context.json")] with opener.open(url) as urlPointer: + content_type = urlPointer.getheader('Content-Type') + self.assertEqual(content_type, "application/ld+json;profile=http://iiif.io/api/presentation/2/context.json", "Response should give the IIIF version") + + cors = urlPointer.getheader('access-control-allow-origin') + #self.assertEqual(cors, "*", "Cors header set incorrectly") + manifest = json.loads(urlPointer.read().decode()) self.assertEqual(manifest['@context'], 'http://iiif.io/api/presentation/2/context.json', 'Passing the 2 accept header should get version 2 manifest')