API: aj.http¶
- class aj.http.CGIFieldStorage(fp=None, headers=None, outerboundary=b'', environ=environ({'READTHEDOCS_VIRTUALENV_PATH': '/home/docs/checkouts/readthedocs.org/user_builds/ajenti2/envs/latest', 'READTHEDOCS_CANONICAL_URL': 'http://docs.ajenti.org/en/latest/', 'HOSTNAME': 'build-32688872-project-27581-ajenti2', 'READTHEDOCS_GIT_CLONE_URL': 'https://github.com/ajenti/ajenti', 'HOME': '/home/docs', 'NO_COLOR': '1', 'READTHEDOCS': 'True', 'READTHEDOCS_PRODUCTION_DOMAIN': 'app.readthedocs.org', 'READTHEDOCS_REPOSITORY_PATH': '/home/docs/checkouts/readthedocs.org/user_builds/ajenti2/checkouts/latest', 'READTHEDOCS_PROJECT': 'ajenti2', 'READTHEDOCS_OUTPUT': '/home/docs/checkouts/readthedocs.org/user_builds/ajenti2/checkouts/latest/_readthedocs/', 'PATH': '/home/docs/checkouts/readthedocs.org/user_builds/ajenti2/envs/latest/bin:/home/docs/.asdf/shims:/home/docs/.asdf/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'READTHEDOCS_VERSION_TYPE': 'branch', 'LANG': 'C.UTF-8', 'READTHEDOCS_LANGUAGE': 'en', 'DEBIAN_FRONTEND': 'noninteractive', 'READTHEDOCS_GIT_COMMIT_HASH': '03187fe63182f1a84cfb2fb2b9f72c90c44c7131', 'READTHEDOCS_VERSION_NAME': 'latest', 'READTHEDOCS_VERSION': 'latest', 'PWD': '/home/docs/checkouts/readthedocs.org/user_builds/ajenti2/checkouts/latest/docs/source', 'READTHEDOCS_GIT_IDENTIFIER': 'master', 'DOCUTILSCONFIG': '/home/docs/checkouts/readthedocs.org/user_builds/ajenti2/checkouts/latest/docs/source/docutils.conf'}), keep_blank_values=0, strict_parsing=0, limit=None, encoding='utf-8', errors='replace', max_num_fields=None, separator='&')[source]¶
- class aj.http.HttpContext(env, start_response=None)[source]¶
Instance of
HttpContextis passed to all HTTP handler methods- env¶
WSGI environment dict
- path¶
Path segment of the URL
- method¶
Request method
- headers¶
List of HTTP response headers
- body¶
Request body
- response_ready¶
Indicates whether a HTTP response has already been submitted in this context
- query¶
HTTP query parameters
- add_header(key, value)[source]¶
Adds a given HTTP header to the response
- Parameters:
key (str) – header name
value (str) – header value
- file(path, stream=False, inline=False, name=None)[source]¶
Returns a GZip compressed response with content of file located in
pathand correct headers
- gzip(content, compression=6)[source]¶
Returns a GZip compressed response with given
contentand correct headers- Parameters:
compression (int) – compression level from 0 to 9
- Return type:
str
- class aj.http.HttpMiddlewareAggregator(stack)[source]¶
Stacks multiple HTTP handlers together in a middleware fashion.
- Parameters:
stack (list(
aj.api.http.BaseHttpHandler)) – handler list
- handle(http_context)[source]¶
Should create a HTTP response in the given
http_contextand return the plain output- Parameters:
http_context (
aj.http.HttpContext) – HTTP context
- class aj.http.HttpRoot(handler)[source]¶
A root WSGI middleware object that creates the
HttpContextand dispatches it to an HTTP handler.- Parameters:
handler (
aj.api.http.BaseHttpHandler) – next middleware handler