mhttpd should serve .css and .js files with correct type

Issue #19 resolved
Thomas Lindner created an issue

I may be missing something, but it seems that the MIDAS custom pages are not being served with the correct mime/type. If, for instance, I get MIDAS to serve a custom page called 'mystyle.css' it is returned with Content-Type of·'text/html', not 'text/css'.

I think this is a simple change; just need to change show_custom_page() in mhttpd.cxx to key the content type off the file extension. There is already a map of file types in mhttpd, so should be simple.

Comments (7)

  1. Stefan Ritt

    Actually this is not a bug, but an unimplemented feature. Custom pages were never meant to contain separate CSS files. I added that functionality, so now you can write

    <link rel="stylesheet" href="custom.css" type="text/css" />
    

    directly in your custom page and the system will search for that file in the path given under /Custom/Path. Note that this does NOT override the system-wide CSS file mhttpd.css. If you want all pages look differently, you have to edit mhttpd.css directly. A custom page being only a CSS file does not make sense (I guess that is what you asked originally).

    /Stefan

  2. Thomas Lindner reporter

    Sorry about empty message: need to figure out how to use bitbucket correctly.

    Thanks for adding ability to add separate css file to custom page. That is what I wanted; it seems useful to be able to have be able to separate out some style definitions into other files, without modifying mhttpd.css.

    I tested the change and it works for me now.

    However, as I said, I'd also like to separate out the javascript functionality into separate files, so having those files with right mime-type is also important. Re-opening.

  3. Stefan Ritt

    Ok, added some code which servers now all types of files in the list. Have however not yet tried with with JS. Can you do and close this issue if it works?

  4. Thomas Lindner reporter

    Seems to work. I think the type 'application/x-javascript' is somewhat obsolete. 'application/javascript' I think is better.

    But I'm not too worried. A little more testing reminded me that the css mime type was more important than the js. At least for me the css style sheet wouldn't load with the wrong mime type (Firefox 26.0). So your solution works for me.

  5. Log in to comment