From 74fd11b87a4d34a243c0655b6c70a487601ca0f7 Mon Sep 17 00:00:00 2001 From: Karl Czajkowski Date: Wed, 1 Nov 2023 14:41:21 -0700 Subject: [PATCH] make sure we set application/octet-stream as the default object content-type in responses relying in the framework to fill it in is wrong... --- hatrac/rest/core.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hatrac/rest/core.py b/hatrac/rest/core.py index d6f925e..2a0694a 100644 --- a/hatrac/rest/core.py +++ b/hatrac/rest/core.py @@ -558,11 +558,12 @@ def intersects_resource(r): metadata = metadata.to_http() headers.update(metadata) - if resource.is_object() and resource.is_version(): - headers['content-location'] = resource.asurl() - if 'content-disposition' not in resource.metadata: - headers['content-disposition'] = "filename*=UTF-8''%s" % str(resource.object).split("/")[-1] - + if resource.is_object(): + headers.setdefault('content-type', 'application/octet-stream') + headers.setdefault('content-location', resource.asurl()) + basename = (str(resource.object) if resource.is_version() else str(resource)).split("/")[-1] + headers.setdefault('content-disposition', "filename*=UTF-8''%s" % basename) + if self.http_etag: headers['ETag'] = self.http_etag