title: Display HTTP Response on Webpage using PHP
body: <p>I am looking to put together a website that displays the full <strong>HTTP Request Headers</strong> and <strong>HTTP Response Headers</strong> for the loading of the page itself.  For instance.  If someone browses to <a href="http://example.com/index.php" rel="nofollow">http://example.com/index.php</a> , I want the following to display:</p>
  
  <blockquote>
    <p><strong>HTTP Request</strong> <BR>
    GET /index.php HTTP/1.1 <br>
    Host: example.com <br>
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16 <br>
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,<em>/</em>;q=0.8 <br>
    Accept-Language: en-us,en;q=0.5 <br>
    Accept-Encoding: gzip,deflate <br>
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 <br>
    Keep-Alive: 115 <br>
    Connection: keep-alive <br></p>
    
    <p><strong>HTTP Response</strong> <BR>
    HTTP/1.1 200 OK <br>
    Date: Mon, 21 Dec 2011 10:20:46 GMT <br>
    Server: Apache/2.2.15 (Red Hat) <br>
    X-Powered-By: PHP/5.3.3 <br>
    Content-Length: 1169 <br>
    Connection: close <br>
    Content-Type: text/html; charset=UTF-8 <br></p>
  </blockquote>
  
  <p>We were able to get the Request header to display fairly simply using the following PHP code:</p>
  
  <pre><code>print $_SERVER['REQUEST_METHOD']." ".$_SERVER['REQUEST_URI']." ".$_SERVER['SERVER_PROTOCOL']."&lt;br&gt;";
  foreach (apache_request_headers() as $name =&gt; $value)
          echo "$name: $value&lt;br&gt;";
  </code></pre>
  
  <p>But are having some difficulties with the HTTP Response header.  Anyone have any ideas of how we can do this?  It does not have to be PHP if you have a method that works in Perle or CGI or whatever.</p>
  
  <p>To be clear, I don't mean to <em>set</em> the HTTP Response to anything specific, only <em>display</em> the response served by the web server to load the page.</p>