The base environment for a request.
(self, **request)
| 399 | self.defaults["QUERY_STRING"] = urlencode(query_params, doseq=True) |
| 400 | |
| 401 | def _base_environ(self, **request): |
| 402 | """ |
| 403 | The base environment for a request. |
| 404 | """ |
| 405 | # This is a minimal valid WSGI environ dictionary, plus: |
| 406 | # - HTTP_COOKIE: for cookie support, |
| 407 | # - REMOTE_ADDR: often useful, see #8551. |
| 408 | # See https://www.python.org/dev/peps/pep-3333/#environ-variables |
| 409 | return { |
| 410 | "HTTP_COOKIE": "; ".join( |
| 411 | sorted( |
| 412 | "%s=%s" % (morsel.key, morsel.coded_value) |
| 413 | for morsel in self.cookies.values() |
| 414 | ) |
| 415 | ), |
| 416 | "PATH_INFO": "/", |
| 417 | "REMOTE_ADDR": "127.0.0.1", |
| 418 | "REQUEST_METHOD": "GET", |
| 419 | "SCRIPT_NAME": "", |
| 420 | "SERVER_NAME": "testserver", |
| 421 | "SERVER_PORT": "80", |
| 422 | "SERVER_PROTOCOL": "HTTP/1.1", |
| 423 | "wsgi.version": (1, 0), |
| 424 | "wsgi.url_scheme": "http", |
| 425 | "wsgi.input": FakePayload(b""), |
| 426 | "wsgi.errors": self.errors, |
| 427 | "wsgi.multiprocess": True, |
| 428 | "wsgi.multithread": False, |
| 429 | "wsgi.run_once": False, |
| 430 | **self.defaults, |
| 431 | **request, |
| 432 | } |
| 433 | |
| 434 | def request(self, **request): |
| 435 | "Construct a generic request object." |