title: cherrypy - serve static files and force content-type
body: <p>I'm building a small web-app with cherrypy.</p>
  
  <p>In this app, I need to serve files in two different ways:</p>
  
  <ol>
  <li>serve it with the correct mime type, to embed it in a webpage,</li>
  <li>serve it with <code>application/octet-stream</code> mime type, to force the download.</li>
  </ol>
  
  <p>Currently, I added an exposed method to stream files, one at <code>/document/xx</code>, returning the correct mime type, the other one at <code>/download/xx</code> with the octet-stream mime type.</p>
  
  <p>But I want to avoid coding this myself. It can only bring bugs and security issues.</p>
  
  <p>tl;dr: <strong>How can I force cherrypy's <code>tools.staticdir</code> to force download?</strong></p>
  
  <p>See the full code of the app on github: <a href="https://github.com/aspyct/docrepo" rel="nofollow">https://github.com/aspyct/docrepo</a> (note that it's still using the old 'config.ini' file, no config dictionary).</p>