docs/reference/adapter/wsgi/http_request.html
class WsgiHttpRequest (environ: Dict[str, Any])#Expand source code
class WsgiHttpRequest:
"""This Class uses the PEP 3333 standard to extract request information
from the WSGI web server running the application
PEP 3333: https://peps.python.org/pep-3333/
"""
__slots__ = ("method", "path", "query_string", "protocol", "environ")
def __init__ (self, environ: Dict[str, Any]):
self.method: str = environ.get("REQUEST_METHOD", "GET")
self.path: str = environ.get("PATH_INFO", "")
self.query_string: str = environ.get("QUERY_STRING", "")
self.protocol: str = environ.get("SERVER_PROTOCOL", "")
self.environ = environ
def get_headers(self) -> Dict[str, Union[str, Sequence[str]]]:
headers = {}
for key, value in self.environ.items():
if key in {"CONTENT_LENGTH", "CONTENT_TYPE"}:
name = key.lower().replace("_", "-")
headers[name] = value
if key.startswith("HTTP_"):
name = key[len("HTTP_"):].lower().replace("_", "-") # fmt: skip
headers[name] = value
return headers
def get_body(self) -> str:
if "wsgi.input" not in self.environ:
return ""
content_length = int(self.environ.get("CONTENT_LENGTH", 0))
return self.environ["wsgi.input"].read(content_length).decode(ENCODING)
This Class uses the PEP 3333 standard to extract request information from the WSGI web server running the application
PEP 3333: https://peps.python.org/pep-3333/
var environ#Expand source code
class WsgiHttpRequest:
"""This Class uses the PEP 3333 standard to extract request information
from the WSGI web server running the application
PEP 3333: https://peps.python.org/pep-3333/
"""
__slots__ = ("method", "path", "query_string", "protocol", "environ")
def __init__ (self, environ: Dict[str, Any]):
self.method: str = environ.get("REQUEST_METHOD", "GET")
self.path: str = environ.get("PATH_INFO", "")
self.query_string: str = environ.get("QUERY_STRING", "")
self.protocol: str = environ.get("SERVER_PROTOCOL", "")
self.environ = environ
def get_headers(self) -> Dict[str, Union[str, Sequence[str]]]:
headers = {}
for key, value in self.environ.items():
if key in {"CONTENT_LENGTH", "CONTENT_TYPE"}:
name = key.lower().replace("_", "-")
headers[name] = value
if key.startswith("HTTP_"):
name = key[len("HTTP_"):].lower().replace("_", "-") # fmt: skip
headers[name] = value
return headers
def get_body(self) -> str:
if "wsgi.input" not in self.environ:
return ""
content_length = int(self.environ.get("CONTENT_LENGTH", 0))
return self.environ["wsgi.input"].read(content_length).decode(ENCODING)
var method#Expand source code
class WsgiHttpRequest:
"""This Class uses the PEP 3333 standard to extract request information
from the WSGI web server running the application
PEP 3333: https://peps.python.org/pep-3333/
"""
__slots__ = ("method", "path", "query_string", "protocol", "environ")
def __init__ (self, environ: Dict[str, Any]):
self.method: str = environ.get("REQUEST_METHOD", "GET")
self.path: str = environ.get("PATH_INFO", "")
self.query_string: str = environ.get("QUERY_STRING", "")
self.protocol: str = environ.get("SERVER_PROTOCOL", "")
self.environ = environ
def get_headers(self) -> Dict[str, Union[str, Sequence[str]]]:
headers = {}
for key, value in self.environ.items():
if key in {"CONTENT_LENGTH", "CONTENT_TYPE"}:
name = key.lower().replace("_", "-")
headers[name] = value
if key.startswith("HTTP_"):
name = key[len("HTTP_"):].lower().replace("_", "-") # fmt: skip
headers[name] = value
return headers
def get_body(self) -> str:
if "wsgi.input" not in self.environ:
return ""
content_length = int(self.environ.get("CONTENT_LENGTH", 0))
return self.environ["wsgi.input"].read(content_length).decode(ENCODING)
var path#Expand source code
class WsgiHttpRequest:
"""This Class uses the PEP 3333 standard to extract request information
from the WSGI web server running the application
PEP 3333: https://peps.python.org/pep-3333/
"""
__slots__ = ("method", "path", "query_string", "protocol", "environ")
def __init__ (self, environ: Dict[str, Any]):
self.method: str = environ.get("REQUEST_METHOD", "GET")
self.path: str = environ.get("PATH_INFO", "")
self.query_string: str = environ.get("QUERY_STRING", "")
self.protocol: str = environ.get("SERVER_PROTOCOL", "")
self.environ = environ
def get_headers(self) -> Dict[str, Union[str, Sequence[str]]]:
headers = {}
for key, value in self.environ.items():
if key in {"CONTENT_LENGTH", "CONTENT_TYPE"}:
name = key.lower().replace("_", "-")
headers[name] = value
if key.startswith("HTTP_"):
name = key[len("HTTP_"):].lower().replace("_", "-") # fmt: skip
headers[name] = value
return headers
def get_body(self) -> str:
if "wsgi.input" not in self.environ:
return ""
content_length = int(self.environ.get("CONTENT_LENGTH", 0))
return self.environ["wsgi.input"].read(content_length).decode(ENCODING)
var protocol#Expand source code
class WsgiHttpRequest:
"""This Class uses the PEP 3333 standard to extract request information
from the WSGI web server running the application
PEP 3333: https://peps.python.org/pep-3333/
"""
__slots__ = ("method", "path", "query_string", "protocol", "environ")
def __init__ (self, environ: Dict[str, Any]):
self.method: str = environ.get("REQUEST_METHOD", "GET")
self.path: str = environ.get("PATH_INFO", "")
self.query_string: str = environ.get("QUERY_STRING", "")
self.protocol: str = environ.get("SERVER_PROTOCOL", "")
self.environ = environ
def get_headers(self) -> Dict[str, Union[str, Sequence[str]]]:
headers = {}
for key, value in self.environ.items():
if key in {"CONTENT_LENGTH", "CONTENT_TYPE"}:
name = key.lower().replace("_", "-")
headers[name] = value
if key.startswith("HTTP_"):
name = key[len("HTTP_"):].lower().replace("_", "-") # fmt: skip
headers[name] = value
return headers
def get_body(self) -> str:
if "wsgi.input" not in self.environ:
return ""
content_length = int(self.environ.get("CONTENT_LENGTH", 0))
return self.environ["wsgi.input"].read(content_length).decode(ENCODING)
var query_string#Expand source code
class WsgiHttpRequest:
"""This Class uses the PEP 3333 standard to extract request information
from the WSGI web server running the application
PEP 3333: https://peps.python.org/pep-3333/
"""
__slots__ = ("method", "path", "query_string", "protocol", "environ")
def __init__ (self, environ: Dict[str, Any]):
self.method: str = environ.get("REQUEST_METHOD", "GET")
self.path: str = environ.get("PATH_INFO", "")
self.query_string: str = environ.get("QUERY_STRING", "")
self.protocol: str = environ.get("SERVER_PROTOCOL", "")
self.environ = environ
def get_headers(self) -> Dict[str, Union[str, Sequence[str]]]:
headers = {}
for key, value in self.environ.items():
if key in {"CONTENT_LENGTH", "CONTENT_TYPE"}:
name = key.lower().replace("_", "-")
headers[name] = value
if key.startswith("HTTP_"):
name = key[len("HTTP_"):].lower().replace("_", "-") # fmt: skip
headers[name] = value
return headers
def get_body(self) -> str:
if "wsgi.input" not in self.environ:
return ""
content_length = int(self.environ.get("CONTENT_LENGTH", 0))
return self.environ["wsgi.input"].read(content_length).decode(ENCODING)
def get_body(self) ‑> str#Expand source code
def get_body(self) -> str:
if "wsgi.input" not in self.environ:
return ""
content_length = int(self.environ.get("CONTENT_LENGTH", 0))
return self.environ["wsgi.input"].read(content_length).decode(ENCODING)
def get_headers(self) ‑> Dict[str, str | Sequence[str]]#Expand source code
def get_headers(self) -> Dict[str, Union[str, Sequence[str]]]:
headers = {}
for key, value in self.environ.items():
if key in {"CONTENT_LENGTH", "CONTENT_TYPE"}:
name = key.lower().replace("_", "-")
headers[name] = value
if key.startswith("HTTP_"):
name = key[len("HTTP_"):].lower().replace("_", "-") # fmt: skip
headers[name] = value
return headers