title: Slow HTTP POST request in php
body: <p>I'm trying to POSTing some data (a JSON string) from a php script to a java server (all written by myself) and getting the response back.
  I tried the following code:</p>
  
  <pre><code>$url="http://localhost:8000/hashmap";
  $opts = array('http' =&gt; array('method' =&gt; 'POST', 'content' =&gt; $JSONDATA,'header'=&gt;"Content-Type: application/x-www-form-urlencoded"));
  $st = stream_context_create($opts);
  echo file_get_contents($url, false,$st);
  </code></pre>
  
  <p>Now, this code actually works (I get back as result the right answer), but file_get_contents hangs everytime 20 seconds while being executed (I printed the time before and after the instruction). The operations performed by the server are executed in a small amount of time, and I'm sure it's not normal to wait all this time to get the response.
  Am I missing something?</p>