title: Multipart response in Ruby/Rack
body: <p>I want my server to send a multipart response (multipart/x-mixed-replace). I'd prefer some kind of solution using the Sinatra framework or a generic Rack app, but any example in ruby would be nice. Here's the equivalent of what I'm trying to do, in PHP:</p>
  
  <pre><code>&lt;?php
    header('Content-type: multipart/x-mixed-replace;boundary="rn9012"');
  
    print "--rn9012\n";
    print "Content-type: application/xml\n\n";
    print "&lt;?xml version='1.0'?&gt;\n";
    print "&lt;content&gt;First Part&lt;/content&gt;\n";
    print "--rn9012\n";
    flush();
  
    sleep(5);
    print "Content-type: application/xml\n\n";
    print "&lt;?xml version='1.0'?&gt;\n";
    print "&lt;content&gt;Second Part&lt;/content&gt;\n";
    print "--rn9012--\n";
  
  ?&gt;
  </code></pre>