MCPcopy
hub / github.com/pallets/werkzeug / from_environ

Method from_environ

src/werkzeug/test.py:397–427  ·  view source on GitHub ↗

Turn an environ dict back into a builder. Any extra kwargs override the args extracted from the environ. .. versionchanged:: 2.0 Path and query values are passed through the WSGI decoding dance to avoid double encoding. .. versionadded:: 0.15

(cls, environ: WSGIEnvironment, **kwargs: t.Any)

Source from the content-addressed store, hash-verified

395
396 @classmethod
397 def from_environ(cls, environ: WSGIEnvironment, **kwargs: t.Any) -> EnvironBuilder:
398 """Turn an environ dict back into a builder. Any extra kwargs
399 override the args extracted from the environ.
400
401 .. versionchanged:: 2.0
402 Path and query values are passed through the WSGI decoding
403 dance to avoid double encoding.
404
405 .. versionadded:: 0.15
406 """
407 headers = Headers(EnvironHeaders(environ))
408 out = {
409 "path": _wsgi_decoding_dance(environ["PATH_INFO"]),
410 "base_url": cls._make_base_url(
411 environ["wsgi.url_scheme"],
412 headers.pop("Host"),
413 _wsgi_decoding_dance(environ["SCRIPT_NAME"]),
414 ),
415 "query_string": _wsgi_decoding_dance(environ["QUERY_STRING"]),
416 "method": environ["REQUEST_METHOD"],
417 "input_stream": environ["wsgi.input"],
418 "content_type": headers.pop("Content-Type", None),
419 "content_length": headers.pop("Content-Length", None),
420 "errors_stream": environ["wsgi.errors"],
421 "multithread": environ["wsgi.multithread"],
422 "multiprocess": environ["wsgi.multiprocess"],
423 "run_once": environ["wsgi.run_once"],
424 "headers": headers,
425 }
426 out.update(kwargs)
427 return cls(**out)
428
429 def _add_file_from_data(
430 self,

Callers 3

resolve_redirectMethod · 0.80
openMethod · 0.80

Calls 6

popMethod · 0.95
HeadersClass · 0.85
EnvironHeadersClass · 0.85
_wsgi_decoding_danceFunction · 0.85
_make_base_urlMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected