title: URL request emulating curl --data-binary
body: <p>I want to send a URL request equivalent to using to json objects in the post data, separated by newline.
  This is for indexing two items in bulk for Elasticsearch.</p>
  
  <p>This works fine:</p>
  
  <pre><code>curl -XPOST 'localhost:9200/myindex/mydoc?pretty=true' --data-binary @myfile.json
  </code></pre>
  
  <p>where myfile.json:</p>
  
  <pre><code>{"index": {"_parent": "btaCovzjQhqrP4s3iPjZKQ"}}    
  {"title": "hello"}
  {"index": {"_parent": "btaCovzjQhqrP4s3iPjZKQ"}}
  {"title": "world"}
  </code></pre>
  
  <p>When I try it using:</p>
  
  <pre><code>req = urllib2.Request(url,data=
  json.dumps({"index": {"_parent": "btaCovzjQhqrP4s3iPjZKQ"}}) + "\n" +
  json.dumps({"title":"hello"}) + "\n" + 
  json.dumps({"index": {"_parent": "btaCovzjQhqrP4s3iPjZKQ"}}) + "\n" +
  json.dumps({"title":"world"})
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>HTTP Error 500: Internal Server Error
  </code></pre>