in reply to file back to the user

The magic word remains the same ... Content-Type in the header.

Request a file from someplace and use, say, Firebug to observe the HTML ... headers and content.   Then, do the same with your app, and find what the differences are.