soveran / cuba

Rum based microframework for web development.
http://cuba.is
MIT License
1.44k stars 249 forks source link

404 default Content-Type not set #69

Closed dkullmann closed 8 years ago

dkullmann commented 9 years ago

The Content-Type isn't being set when a 404 occurs on our application, which means that plain text is rendered: http://cl.ly/image/1f401k340S29

Is this the intended default behavior?

I believe that the way it works is all 200's have a default Content-Type of text/html if not otherwise set, but other status codes have no Content-Type at all (see here)

frodsan commented 9 years ago

Related to https://github.com/harmoni/hmote/commit/1e99537d0fb503d77fc57cb43722abcd3c1ee2d4

emancu commented 9 years ago

Related to https://github.com/soveran/cuba/commit/436c10c5e5fa783749902101dea04f98871d1f32

mkristian commented 8 years ago

@dkullmann the way I read the code is if status is set cuba does not touch the content-type or the otherway around if you set the status you also need to set the content-type

sounds fair to me.

soveran commented 8 years ago

There's an experimental feature in master that may alleviate this problem. Instead of only setting the status code to 404, Cuba calls the not_found method, which by default only sets the status code to 404. With this change, it is now possible to redefine not_found so it can set the headers and body in case of a 404.

soveran commented 8 years ago

Closing this issue as the not_found hook landed on version 3.5.0. Let me know if it needs to be reopened.