title: How to access wsgi params from a request inside a middleware and a flask request without side effect?
body: <p>I need to read some values from the wsgi request before my flask app is loaded. If I read the url from the wsgi request I can access the file without any issues once the flask app is loaded (after the middleware runs).</p>
  
  <p>But if I attempt to access the params it seems to remove the post data once the flask app is loaded. I even went to the extreme of wrapping the wsgi request with a special Webob Request to prevent this "read once" problem.</p>
  
  <p>Does anyone know how to access values from the wsgi request in middleware without doing any sort of side effect harm to the request so you can get post data / file data in a flask app?</p>
  
  <pre><code>from webob import Request
  
  class SomeMiddleware(object):
  
      def __init__(self, environ):
          self.request = Request(environ)
          self.orig_environ = environ
  
      def apply_middleware(self):
          print self.request.url #will not do any harm
          print self.request.params #will cause me to lose data
  </code></pre>
  
  <p>Here is my flask view</p>
  
  <pre><code>    @app.route('/')
      def hello_world():
          from flask import request
          the_file = request.files['file']
          print "and the file is", the_file
  </code></pre>