improve decision for html or plain text sending of file

This is a fix for what @cmaeder mentioned at the end of a meeting (on top of #783):
`request.header` computes an accept request from the sent http headers. What we want to check is the plain request header how it is sent by browsers.

And of course, I put the check into a separate method to make the code more readable.