It keeps bugging me that plain-text APT/Deb repository metadata is served as application/octet-stream
instead of text/plain
(especially if you just want to check the content in your browser).
I tried adding the files to python’s mimetypes by doing the following in /pulp_deb/settings.py
:
import mimetypes
mimetypes.add_type("text/plain", "Release", True)
mimetypes.add_type("text/plain", "InRelease", True)
mimetypes.add_type("text/plain", "Packages", True)
This adds the mime-types, but python chooses to ignore them. Probably because it only looks at file-extensions and not at full filenames.
So the second thing I tried was to add this to the pulpcore content handler.
/pulpcore/content/handler.py
:
@staticmethod
def response_headers(path):
content_type, encoding = mimetypes.guess_type(path)
# new-code start
if (not content_type) and (path.endswith("/Release") or path.endswith("/InRelease") or path.endswith("Packages")):
content_type = "text/plain"
# new-code end
headers = {}
if content_type:
headers["Content-Type"] = content_type
return headers
This works and the files are then served correctly, but it just feels wrong to do this in pulpcore.
Is there a way to add this into pulp_deb?