title: EventMachine::HttpRequest and Keep-alive connection
body: <p>I'm using the following code to run a couple of HTTP requests, but the second request (req2) always returns to errback.</p>
  
  <p>Am I missing something obvious here?</p>
  
  <pre><code>request_options = {
    :body =&gt; " ",
    :keepalive =&gt; true,
    :head =&gt; {
      'content-type' =&gt; 'application/json',
      'accept' =&gt; 'application/json',
      'Accept-Encoding' =&gt; 'gzip,deflate,sdch'
    }
  }
  
  EM.run do
    request_options[:path] = '/default/path'
  
    conn = EM::HttpRequest.new 'https://www.example.com'
  
    req1 = conn.post request_options
    req1.errback { p 'Uh, oh'; EM.stop }
    req1.callback do
      doc = JSON.parse req1.response
  
      # do stuff with doc
  
      request_options[:body] = 'post-data'
      request_options[:path] = '/new/path'
  
      req2 = conn.post request_options
      req2.errback { p 'Uh, oh'; EM.stop }
      req2.callback do
         puts req2.response
         EM.stop
      end
    end
  end
  </code></pre>