Skip to content

Invalid Content-type for log and text files

Summary

When I wan to see a text file from pages, the browser downloads it instead of displaying it.

Steps to reproduce

Click here: https://ribalda.gitlab.io/-/test/-/jobs/6584156876/artifacts/out/kk.txt

$ curl -i https://ribalda.gitlab.io/-/test/-/jobs/6584156876/artifacts/out/kk.txt
HTTP/2 200 
cache-control: max-age=3600
content-type: application/octet-stream
permissions-policy: interest-cohort=()
vary: Origin
content-length: 998
date: Tue, 09 Apr 2024 15:49:44 GMT

Other extensions, like csv, htm or `html are displayed without any issue, with the right Content-type

Example Project

https://gitlab.com/ribalda/test/-/jobs/6584156876/artifacts/browse/out/

What is the current bug behavior?

Download .txt file

What is the expected correct behavior?

Diplay the .txt file in the browser

Relevant logs and/or screenshots

image

Output of checks

This bug happens on GitLab.com

Implementation guide:

Possible fix around this code: https://gitlab.com/gitlab-org/gitlab-pages/-/blame/master/internal/serving/disk/helpers.go#L53

Edited by Naman Jagdish Gala