title: How to get php://input size?
body: <p>Building a stream implementation for my API by implementing the PSR-7 StreamInterface.  In my testing I use <code>php://input</code>but for some reason it will not calculate the correct size.  It is returning <code>null</code>.  It works correctly for other files, however.</p>
  
  <pre><code>class Stream implements StreamInterface
  {
      public function __construct($resource)
      {
          $this-&gt;resource = $resource;
  
          $this-&gt;meta = $this-&gt;getMetadata();
  
          $this-&gt;size = $this-&gt;calculateSize();
  
          $this-&gt;isReadable = $this-&gt;isModeable('readable');
          $this-&gt;isWritable = $this-&gt;isModeable('writable');
      }
  
      private function calculateSize()  // RETURNS NULL FOR PHP://INPUT??
      {
          $stats = fstat($this-&gt;resource);  // this is evaluating to false;
  
          return isset($stats['size']) ? $stats['size'] : null;
      }
  }
  </code></pre>
  
  <p>I'm thinking that maybe I cannot do this with <code>php://input</code> and what I will need to do is inherit from my <code>Stream</code> class and override these methods specifically for <code>php://input</code>.</p>