API¶
revproxy.views¶
revproxy.response¶
revproxy.transformer¶
revproxy.utils¶
-
revproxy.utils.
DEFAULT_CHARSET
= 'latin-1'¶ Variable that represent the default charset used
-
revproxy.utils.
HTML_CONTENT_TYPES
= ('text/html', 'application/xhtml+xml')¶ List containing string constants that represents possible html content type
-
revproxy.utils.
IGNORE_HEADERS
= ('HTTP_ACCEPT_ENCODING', 'HTTP_HOST', 'HTTP_REMOTE_USER')¶ List containing string constant that are used to represent headers that can be ignored in the required_header function
-
revproxy.utils.
MIN_STREAMING_LENGTH
= 4096¶ Variable used to represent a minimal content size required for response to be turned into stream
Parser for HTTP header set-cookie The return from this function will be used as parameters for django’s response.set_cookie method. Because set_cookie doesn’t have parameter comment, this cookie attribute will be ignored.
Parameters: - cookie_string – A string representing a valid cookie
- strict_cookies – Whether to only accept RFC-compliant cookies
Returns: A dictionary containing the cookie_string attributes
-
revproxy.utils.
encode_items
(items)[source]¶ Function that encode all elements in the list of items passed as a parameter
Parameters: items – A list of tuple Returns: A list of tuple with all items encoded in ‘utf-8’
-
revproxy.utils.
get_charset
(content_type)[source]¶ Function used to retrieve the charset from a content-type.If there is no charset in the content type then the charset defined on DEFAULT_CHARSET will be returned
Parameters: content_type – A string containing a Content-Type header Returns: A string containing the charset
-
revproxy.utils.
is_html_content_type
(content_type)[source]¶ Function used to verify if the parameter is a proper html content type
Parameters: content_type – String variable that represent a content-type Returns: A boolean value stating if the content_type is a valid html content type
-
revproxy.utils.
normalize_request_headers
(request)[source]¶ Function used to transform header, replacing ‘HTTP_’ to ‘’ and replace ‘_’ to ‘-’
Parameters: request – A HttpRequest that will be transformed Returns: A dictionary with the normalized headers
-
revproxy.utils.
required_header
(header)[source]¶ Function that verify if the header parameter is a essential header
Parameters: header – A string represented a header Returns: A boolean value that represent if the header is required
-
revproxy.utils.
should_stream
(proxy_response)[source]¶ Function to verify if the proxy_response must be converted into a stream.This will be done by checking the proxy_response content-length and verify if its length is bigger than one stipulated by MIN_STREAMING_LENGTH.
Parameters: proxy_response – An Instance of urllib3.response.HTTPResponse Returns: A boolean stating if the proxy_response should be treated as a stream