title: Why can php://input be read more than once despite the documentation saying otherwise?
body: <p>The PHP documentation <a href="http://php.net/manual/en/wrappers.php.php" rel="noreferrer">states</a> that <code>php://input</code> can only be read once.</p>
  
  <p>In my application I need to read it twice, once for authentication purposes and once for actually processing the content, and both functions are handled by different, independent modules. The crazy thing is: <strong>it works</strong>.</p>
  
  <p>Can I count on this working everywhere, or is this a fluke in my version of PHP (5.2.10)? The only documentation I can find about this is the one that states that it shouldn't work, with no version limitation mentioned.</p>
  
  <hr>
  
  <p>Following Dennis' hunch, I did this test:</p>
  
  <pre><code>$in = fopen('php://input', 'r');
  echo fread($in, 1024) . "\n";
  fseek($in, 0);
  echo fread($in, 1024) . "\n";
  fclose($in);
  echo file_get_contents('php://input') . "\n";
  </code></pre>
  
  <p>Curling:</p>
  
  <pre><code>$ curl http://localhost:8888/tests/test.php -d "This is a test"
  This is a test
  
  This is a test
  </code></pre>
  
  <p>Apparently it's limited to one read <strong>per open handle</strong>.</p>
  
  <hr>
  
  <p>A little more digging revealed that indeed <code>php://input</code> can only be read once, ever, <strong>for PUT requests</strong>. The above example used a POST request.</p>