title: How to capture HTTP headers when invoking php-cgi as a subprocess?
body: <p>I'm trying to capture HTTP headers in subprocess of my application that acts as a web server. When i'm invoking php-cgi.exe from command line, HTTP headers are printed to STDOUT, but when I'm trying to catch process's output in QProcess, it returns only HTML. </p>
  
  <p>C++ code:</p>
  
  <pre><code>QProcess php_process;
  php_process.setProcessChannelMode(QProcess::MergedChannels);
  php_process.start( "cgi_get.bat" );
  php_process.waitForFinished();
  QString php_response(php_process.readAll());
  </code></pre>
  
  <p>cgi_get.bat:</p>
  
  <pre><code>@echo off
  set REDIRECT_STATUS=CGI
  set SCRIPT_FILENAME=index.php
  
  C:\application\php-cgi.exe  -f C:\application\app\webroot\index.php 
  </code></pre>
  
  <p>STDOUT after calling cgi_get.bat from command line: </p>
  
  <pre><code>Status: 404 Not Found
  X-Powered-By: PHP/5.3.13
  Set-Cookie: CAKEPHP=fdo35gsnp9hde6a7sufkkb7hj3; expires=Thu, 03-Apr-2014 19:46:06 GMT; path=/; HttpOnly
  Content-Length: 24844
  Content-Type: text/html; charset=UTF-8
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt; ... blah blah blah
  </code></pre>
  
  <p>php_response contents after running this c++ code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;        &lt;title&gt; blah blah blah
  </code></pre>