Enforce text/html Content-Type for Custom 404 Page Responses Regardless of Requested URI Extension
TwinIsland opened this issue · comments
- My goal is: Enable the server to respond with a custom 404 page specified in
opts
when a request is made to an unknown resource. - My actions were: I configured opts with
page404
to a custom HTML page. I then attempted to access a non-existent resource via http://localhost:1146/unknownstuff. - My expectation was: I expected the server to respond with the custom 404 page, including setting the
Content-Type
header totext/html
. - The result I saw: The
Content-Type
header of the response is determined by the extension of the requested URI, not the MIME type of the custom 404 page itself. Finally cause the html respond to be "plain text" and not rendered - My question is: Shouldn't the Content-Type for the 404 response be consistent and reflect that the resource is an HTML page, especially given that the option is named page404? Would it be advisable to enforce a Content-Type of text/html for the 404 page to ensure proper rendering by browsers?
Environment
- mongoose version: 7.12
- Compiler/IDE and SDK: gcc 11.4.0/vscode
- Target hardware/board: x64
- Connectivity chip/module: i5 12th 12600k
- Target RTOS/OS (if applicable): null
I think the order of 2790 and 2791 has to be reversed, and you'll get what you want (and probably what the dev intended, there is no point in serving image/png when a requested image fails, for example)
Can you please test ?
I think the order of 2790 and 2791 has to be reversed, and you'll get what you want (and probably what the dev intended, there is no point in serving image/png when a requested image fails, for example) Can you please test ?
Yea it works as expected, thanks!