<?php

header
('Content-Type: multipart/mixed; boundary=outer');

echo 
implode("\r\n", array(
  
'--outer',
  
'  Content-Type: text/html; charset=UTF-8',
  
'  Content-Disposition: inline',
)) . 
"\r\n\r\n";

?><!DOCTYPE html>
<html>
  <head>
    <title>Download example</title>
    <meta charset="UTF-8">
  </head>
  <body>
    Lorem ipsum dolor sit amet
  </body>
</html>
<?php

echo "\r\n" implode("\r\n", array(
  
'--outer',
  
'  Content-Type: application/octet-stream',
  
'  Content-Disposition: '
  
. (@$_GET['disposition'] === 'inline' 'inline' 'attachment')
  . 
'; filename="foo.js"',
)) . 
"\r\n\r\n";

readfile($_SERVER['DOCUMENT_ROOT'] . '/tmp/proto.js');