title: PHP apache_request_headers() diagrees with reality (as confirmed by Firebug): why?
body: <p>I have written a web app in PHP which makes use of Ajax requests (made using YUI.util.Connect.asyncRequest).</p>
  
  <p>Most of the time, this works fine.  The request is sent with an <strong>X-Requested-With</strong> value of <strong>XMLHttpRequest</strong>.  My PHP controller code uses apache_request_headers() to check whether an incoming request is Ajax or not and all works well.</p>
  
  <p>But not always.  Intermittently, I'm getting a situation where the Ajax request is sent (and Firebug confirms for me that the headers on the request include an X-Requested-With of XMLHttpRequest) but apache_request_headers() is not returning that header in its list.</p>
  
  <p>The output from when I var_dump the apache_request_headers() is as follows (note the lack of X-</p>
  
  <pre><code>'Host' =&gt; string 'peterh.labs.example.com' (length=26)
  'User-Agent' =&gt; string 'Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.0.3) Gecko/2008101315 Ubuntu/8.10 (intrepid) Firefox/3.0.3' (length=105)
  'Accept' =&gt; string 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' (length=63)
  'Accept-Language' =&gt; string 'en-gb,en;q=0.5' (length=14)
  'Accept-Encoding' =&gt; string 'gzip,deflate' (length=12)
  'Accept-Charset' =&gt; string 'ISO-8859-1,utf-8;q=0.7,*;q=0.7' (length=30)
  'Keep-Alive' =&gt; string '300' (length=3)
  'Connection' =&gt; string 'keep-alive' (length=10)
  'Referer' =&gt; string 'http://peterh.labs.example.com/qmail/' (length=40)
  'Cookie' =&gt; string 'WORKFLOW_SESSION=55f9aff2051746851de453c1f776ad10745354f6' (length=57)
  'Pragma' =&gt; string 'no-cache' (length=8)
  'Cache-Control' =&gt; string 'no-cache' (length=8)
  </code></pre>
  
  <p>But Firebug tells me:</p>
  
  <pre><code>Request Headers:
  Host             peterh.labs.example.com
  User-Agent       Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.0.3) Gecko/2008101315 Ubuntu/8.10 (intrepid) Firefox/3.0.3
  Accept           text/html,application/xhtml+xml,application/xml;q=0.9,**;q=0.8
  Accept-Language  en-gb,en;q=0.5
  Accept-Encoding  gzip,deflate
  Accept-Charset   ISO-8859-1,utf-8;q=0.7,*;q=0.7
  Keep-Alive       300
  Connection       keep-alive
  X-Requested-With XMLHttpRequest
  Referer          http://peterh.labs.example.com/qmail/
  Cookie           WORKFLOW_SESSION=55f9aff2051746851de453c1f776ad10745354f6
  </code></pre>
  
  <p>This mismatch is (apparently) intermittent when executing the same code.  But I don't believe in "intermittent" when it comes to software!  Help!</p>