Skip to content

Commit

Permalink
make sure we set application/octet-stream as the default object conte…
Browse files Browse the repository at this point in the history
…nt-type in responses

relying in the framework to fill it in is wrong...
  • Loading branch information
karlcz committed Nov 1, 2023
1 parent a7c37c2 commit 74fd11b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions hatrac/rest/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 74fd11b

Please sign in to comment.