def buffer_input_stream(self):
        """
        Buffer the input stream in a StringIO instance.  This is done
        to have a known/consistent way of accessing incomming data.
        For example the input stream passed by mod_python does not
        offer the same functionallity as ``sys.stdin``.
        """
        # TODO: tests on memory consumption when uploading huge files
        pyhttp = self.get_http()
        winput = pyhttp['wsgi.input']
        method = pyhttp['REQUEST_METHOD']

        # there's no data on stdin for a GET request.  douglas
        # will block indefinitely on the read for a GET request with
        # thttpd.
        if method != 'GET':
            try:
                length = int(pyhttp.get('CONTENT_LENGTH', 0))
            except ValueError:
                length = 0

            if length > 0:
                self._in.write(winput.read(length))
                # rewind to start
                self._in.seek(0)