title: PHP Stream - Get all HTTP request headers
body: <p>I do a post request with the following code:</p>
  
  <pre><code>&lt;?php
  $url = 'http://www.example.com/';
  $data = array('first-post-data' =&gt; 'data', 'second-post-data' =&gt; 'another-data');
  
  $options = array(
      'http' =&gt; array(
          'header'  =&gt; "Content-type: application/x-www-form-urlencoded\r\n",
          'method'  =&gt; 'POST',
          'content' =&gt; http_build_query($data),
          'user_agent' =&gt; 'Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0',
  
          // corporate proxy thing ...
          'proxy' =&gt; 'proxy-ip:proxy-port',
          'request_fulluri' =&gt; true,
      ),
  );
  $context  = stream_context_create($options);
  $file = fopen($url, 'r', null, $context);
  $content = stream_get_contents($file);
  
  // Response headers:
  echo '&lt;pre&gt;' . print_r(stream_get_meta_data($file), true) . '&lt;/pre&gt;';
  
  fclose($file);
  echo $content;
  </code></pre>
  
  <p>I can easily get <strong>response headers</strong> from my handmade HTTP request with the function stream_get_meta_data. Is it possible to get all <strong>request headers</strong>? Are there any built-in function?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I got the raw response headers with tcpflow: <a href="https://superuser.com/a/23187">https://superuser.com/a/23187</a>
  Thanks!</p>