erlyaws / yaws

Yaws webserver
https://erlyaws.github.io
BSD 3-Clause "New" or "Revised" License
1.28k stars 267 forks source link

Fix #394 set content type charset when returning 404 page #397

Closed etnt closed 4 years ago

etnt commented 4 years ago

When returning the default '404 Not Found' page, the content type was hardcoded to 'text/html', i.e with no charset information.

Now we make use of the 'mime_types' module to get the proper content type (which takes into account what charset that has been configured).

vinoski commented 4 years ago

Thanks for submitting this.

In trying to add a unit test for it, I found it doesn't work as it should, since mime_types:t/1 is implemented to always return global settings, but this PR should honor per-server settings. The fix is easy: pass the #sconf{} from out404/3 through to mime_types:t/2. I'll add this fix before I merge the PR.

vinoski commented 4 years ago

Rebased to master at 64cc8cd.