title: Opening connection to HTTP server with PHP
body: <p>I'm trying to open a connection to a webserver I have hosted on an Amazon EC2 instance. I can access the port with a GET request from my browser which gives me the following:</p>
  
  <pre><code>Started HTTP server...
  - &lt;IP redacted&gt; [19/Jul/2013 13:49:24] code 501, message Unsupported method ('GET')
  - &lt;IP redacted&gt; [19/Jul/2013 13:49:24] "GET / HTTP/1.1" 501 -
  </code></pre>
  
  <p>This is as expected as I haven't implemented GET on the webserver - but I get no response at all using the following snippet to POST to the same port.</p>
  
  <pre><code>&lt;?php
  $req = 'verify=true'; 
  
  $header = "POST / HTTP/1.1\r\n"; 
  $header .= "Host: ec2-55-555-555-555.compute-1.amazonaws.com\r\n"; 
  $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; 
  $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; 
  $fp = fsockopen ("ec2-55-555-555-555.compute-1.amazonaws.com", 8080, $errno, $errstr, 30); 
  
  fputs ($fp, $header . $req); 
  
  fclose ($fp);
  ?&gt;
  </code></pre>
  
  <p>It definitely runs and reaches the end but the <code>fsockopen</code> call is timing out. What's missing or is there but shouldn't be?</p>