Skip to content

Redesign content headers recognision

Now, when Rails sets a Content-Type, Workhorse will compare it with the one it detects. If it's too different, ie application vs text, Workhorse will return the detected one, otherwise it will return the existing one.

We change this because the content type detected by Rails is more accurate than the one detected by Workhorse.

Examples 1:

  • Rails is sending the blob file.docx which is a real Word document.
  • Rails will set the content type application/vnd.openxmlformats-officedocument.wordprocessingml.document
  • Workhorse will detect the content type for the file which it will be application/octet-stream
  • Since both content types has the same primary mime type, application, the returned content type will be application/vnd.openxmlformats-officedocument.wordprocessingml.document

Example 2:

  • Rails is sending the blob file.txt, which in reality is a Word document but with the wrong extension
  • Rails will set the content type to text/plain
  • Workhorse will detect that the content type is application/octet-stream
  • Since both primary mime types are different, application vs text, Workhorse will return application/octet-stream.

At the moment, with the existing changes from the MR, the behavior will be the same as it is now. Only when Rails starts sending the content type, the new behavior will work.

As a plus, we also added the type audio/* as allowed to be inlined.

Refs #208 (moved)

Merge request reports