title: PHP fsockopen post redirect issue
body: <p>I want to use fsockopen in my script to pass some post data to another php script on my server. I've already tested it and it is pretty simple to implement unless you have a routing on your website.</p>
  
  <p>Here is my working example (w/o routing on the server):</p>
  
  <p><strong>socket_post.php</strong></p>
  
  <pre><code>&lt;?php
  header('Content-type: text/plain');
  
  $fp = fsockopen('example.com', 80, $errno, $errstr, 30);
  
  $vars = array(
     'filename' =&gt; 'article.txt',
     'data' =&gt; 'Hello world'
  );
  
  $content = http_build_query($vars);
  
  fwrite($fp, "POST /sockets/receive_data.php HTTP/1.1\r\n");
  fwrite($fp, "Host: example.com\r\n");
  fwrite($fp, "Content-Type: application/x-www-form-urlencoded\r\n");
  fwrite($fp, "Content-Length: ".strlen($content)."\r\n");
  fwrite($fp, "Connection: close\r\n");
  fwrite($fp, "\r\n");
  
  fwrite($fp, $content);
  //fclose($fp); // Closes socket immediately without waiting for response
  //echo "Done\r\n";
  
  while (!feof($fp)) {
     echo fgets($fp, 1024);
  }
  </code></pre>
  
  <p><strong>receive_data.php</strong></p>
  
  <pre><code>&lt;?php
  
  extract($_POST);
  sleep(10);
  file_put_contents($filename, $data);
  </code></pre>
  
  <p>So, it works fine on my testing server, but when I'am trying to implement this script with OpenCart CMS it fails due to the OpenCart's controller routing.</p>
  
  <p>This is a version of a script for OpenCart:</p>
  
  <p><strong>socket_post.php</strong></p>
  
  <pre><code>&lt;?php
  class ControllerSocketsSocketPost extends Controller {
     public function index() {
        header('Content-type: text/plain');
  
        $fp = fsockopen("example.com", 80, $errno, $errstr, 30);
  
        $vars = array(
           'filename' =&gt; 'article.txt',
           'data' =&gt; 'Hello world'
        );
  
        $content = http_build_query($vars);
  
        fwrite($fp, "POST https://example.com/index.php?route=sockets/receive_data HTTP/1.1\r\n"); // !!!THE MAIN PROBLEM HERE!!!
        fwrite($fp, "Host: example.com\r\n");
        fwrite($fp, "Content-Type: application/x-www-form-urlencoded\r\n");
        fwrite($fp, "Content-Length: ".strlen($content)."\r\n");
        fwrite($fp, "Connection: close\r\n");
        fwrite($fp, "\r\n");
  
        fwrite($fp, $content);
  
        //fclose($fp); // Closes socket immediately without waiting for response
        //echo 'Done';
  
        while (!feof($fp)) {
           echo fgets($fp, 1024);
        }
     }
  }
  </code></pre>
  
  <p><strong>receive_data.php</strong></p>
  
  <pre><code>&lt;?php
  class ControllerSocketsReceiveData extends Controller {
     public function index() {
        extract($this-&gt;request-&gt;post);
        sleep(10);
        file_put_contents($filename, $data);
     }
  }
  </code></pre>
  
  <p>As a result it should create <code>"article.txt"</code> file in the same directory and render <code>HTTP/1.1 200 OK</code> status on the page, but it gets <code>HTTP/1.1 302 Found</code> status due to the routing and html output <code>&lt;p&gt;The document has moved &lt;a href="https://www.example.com/index.php?route=sockets/receive_data"&gt;here&lt;/a&gt;.&lt;/p&gt;</code>.</p>
  
  <p>How to handle OpenCart's routing in this case? Any advice will be appreciated, thanks!</p>