Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .platform/nginx/conf.d/accepts.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion .platform/nginx/conf.d/elasticbeanstalk/00_application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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/ {
Expand Down
19 changes: 18 additions & 1 deletion tests/TestJsonLD.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down