Module Expr Str Import alias Import alias Import alias Import alias Import alias Import alias Import alias ImportFrom alias ImportFrom alias FunctionDef arguments args NameParam defaults body Expr Str For NameStore AttributeLoad NameLoad attr body Assign NameStore BinOpAdd Str Call AttributeLoad Call AttributeLoad NameLoad attr Str Str attr TryExcept body Delete SubscriptDel NameLoad Index NameLoad handlers ExceptHandler type NameLoad body Pass decorator_list Assign NameStore ListLoad NameLoad ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Expr Str Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call NameLoad SubscriptLoad Call AttributeLoad AttributeLoad NameLoad attr attr Str Num Index Num decorator_list NameLoad decorator_list Assign NameStore BinOpSub Call NameLoad ListComp Call NameLoad NameLoad comprehension NameStore Call NameLoad Num Num Call NameLoad ListLoad Str Assign NameStore Call NameLoad ListComp Call NameLoad NameLoad comprehension NameStore Call NameLoad Num Num FunctionDef arguments args NameParam NameParam defaults body Expr Str For TupleStore NameStore NameStore Call AttributeLoad AttributeLoad NameLoad attr attr body If CompareIn Call AttributeLoad NameLoad attr NameLoad body Delete SubscriptDel AttributeLoad NameLoad attr Index NameLoad TryExcept body If Call NameLoad NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Str If Call NameLoad NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Str handlers ExceptHandler type NameLoad body Delete SubscriptDel AttributeLoad NameLoad attr Index NameLoad If BoolOpOr BinOpSub Call NameLoad NameLoad NameLoad BinOpSub Call NameLoad NameLoad NameLoad body Delete SubscriptDel AttributeLoad NameLoad attr Index NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str If UnaryOpNot CompareIn Str AttributeLoad NameLoad attr body Assign SubscriptStore AttributeLoad NameLoad attr Index Str Str decorator_list FunctionDef arguments args NameParam defaults body Expr Str If CompareIn AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Return If UnaryOpNot CompareIn Str AttributeLoad NameLoad attr body Assign SubscriptStore AttributeLoad NameLoad attr Index Str Str If UnaryOpNot CompareIn Str AttributeLoad NameLoad attr body Assign SubscriptStore AttributeLoad NameLoad attr Index Str Str If CompareIn Str AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Str Assign NameStore NameLoad If NameLoad body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad If NameLoad body Assign NameStore CompareGtE Call AttributeLoad NameLoad attr NameLoad NameLoad If NameLoad body Assign SubscriptStore AttributeLoad NameLoad attr Index Str Call AttributeLoad NameLoad attr Str Call AttributeLoad NameLoad attr NameLoad Assign NameStore ListLoad For NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Str body Expr Call AttributeLoad NameLoad attr GeneratorExp Call AttributeLoad NameLoad attr comprehension NameStore Call AttributeLoad NameLoad attr Str Assign NameStore ListComp NameLoad comprehension NameStore NameLoad CompareNotEq NameLoad Str If UnaryOpNot Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad body Expr Call AttributeLoad NameLoad attr Str Assign SubscriptStore AttributeLoad NameLoad attr Index Str Call AttributeLoad Str attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign AttributeStore NameLoad attr Call NameLoad AttributeLoad NameLoad attr Assign NameStore Call NameLoad GeneratorExp Call NameLoad NameLoad comprehension NameStore AttributeLoad NameLoad attr If CompareIn AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Assign AttributeStore NameLoad attr ListLoad Delete SubscriptDel AttributeLoad NameLoad attr Index Str orelse If CompareEq Call AttributeLoad AttributeLoad NameLoad attr attr Str Str body If NameLoad body Expr Call AttributeLoad NameLoad attr Str Assign AttributeStore NameLoad attr ListLoad orelse If BoolOpAnd UnaryOpNot AttributeLoad NameLoad attr CompareGt NameLoad AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr Str NameLoad AttributeLoad NameLoad attr Assign NameStore BinOpMod Str TupleLoad NameLoad AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr Str Assign SubscriptStore AttributeLoad NameLoad attr Index Str Str Assign SubscriptStore AttributeLoad NameLoad attr Index Str Call NameLoad Call NameLoad NameLoad Assign AttributeStore NameLoad attr ListLoad NameLoad orelse Assign SubscriptStore AttributeLoad NameLoad attr Index Str Call NameLoad NameLoad decorator_list Assign NameStore ListLoad AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Assign NameStore ListLoad NameLoad Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Dict Str NameLoad Assign NameStore Call AttributeLoad NameLoad attr FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body If BoolOpAnd NameLoad SubscriptLoad NameLoad Index Str body Raise SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num Assign SubscriptStore NameLoad Index Str NameLoad Assign SubscriptStore NameLoad Index Str NameLoad Return AttributeLoad NameLoad attr decorator_list For NameStore NameLoad body Expr Call NameLoad NameLoad Assign NameStore Call NameLoad Call NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr While UnaryOpNot NameLoad body TryExcept body Assign NameStore Call AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad body Break Assign SubscriptStore NameLoad Index Str NameLoad TryExcept body Assign NameStore SubscriptLoad NameLoad Index Str Assign NameStore SubscriptLoad NameLoad Index Str handlers ExceptHandler type NameLoad body Raise Call NameLoad Str FunctionDef arguments args defaults body Expr Yield NameLoad For NameStore NameLoad body Expr Yield NameLoad decorator_list Assign NameStore Call NameLoad Assign NameStore Call NameLoad NameLoad NameLoad NameLoad NameLoad For NameStore NameLoad body Expr Call NameLoad NameLoad Expr Call NameLoad AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr Return AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad decorator_list
N/A N/A Provides WSGI middleware for rewriting HTTP responses from the runtime.

The rewriting is used for various sanitisation and processing of the response
from the user's application, including:
  - Removing disallowed HTTP response headers.
  - Setting several response headers to their correct values (e.g.,
    Content-Length).
  - Rewriting responses with X-AppEngine-BlobKey with the full blob download.
  - Rewriting fatal response errors (such as a response that is too large) with
    a 500 error page.

The rewriter is runtime-agnostic. It can be applied to any WSGI application
representing an App Engine runtime.
 N/A calendar N/A cStringIO N/A email N/A functools N/A logging N/A time N/A wsgiref.headers google.appengine.tools.devappserver2 blob_download google.appengine.tools.devappserver2 constants _ignore_request_headers_rewriter N/A N/A environ N/A N/A N/A Ignore specific request headers.

  Certain request headers should not be sent to the application. This function
  removes those headers from the environment. For a complete list of these
  headers please see:

    https://developers.google.com/appengine/docs/python/runtime#Request_Headers

  Args:
    environ: An environ dict for the current request as defined in PEP-333.
   N/A h N/A constants IGNORED_REQUEST_HEADERS N/A N/A h N/A HTTP_ N/A N/A N/A N/A h replace - _ upper N/A N/A N/A N/A environ N/A h N/A N/A N/A KeyError N/A N/A N/A N/A _REQUEST_REWRITER_CHAIN N/A _ignore_request_headers_rewriter RewriterState N/A object N/A N/A The state of a WSGI response while it is being processed.

  Instances of this class hold various attributes that make it easier to pass
  data from one rewriter to another.

  A rewriter is a function that takes a RewriterState as an argument, and
  possibly modifies it.

  Attributes:
    environ: An environ dict for the current request as defined in PEP-333.
    status: A status code and message as a string. (e.g., '200 OK'.)
    headers: A wsgiref.headers.Headers containing the response headers.
    body: An iterable of strings containing the response body.
    allow_large_response: A Boolean value. If True, there is no limit to the
      size of the response body. Defaults to False.
   __init__ N/A N/A self environ status headers body N/A N/A N/A Create a new RewriterState.

    Args:
      environ: An environ dict for the current request as defined in PEP-333.
      status: A status code and message as a string. (e.g., '200 OK'.)
      headers: A list of tuples containing the response headers.
      body: An iterable of strings containing the response body.
     N/A N/A self environ environ N/A N/A self status status N/A N/A self headers N/A N/A N/A wsgiref headers Headers headers N/A N/A self body body N/A N/A self allow_large_response False N/A status_code N/A N/A self N/A N/A N/A The integer value of the response status. N/A N/A int N/A N/A N/A N/A self status split 1 N/A 0 N/A property N/A N/A ALLOWED_HEADER_NAME_CHARACTERS N/A N/A frozenset N/A N/A chr c N/A c N/A range 33 128 N/A frozenset N/A : N/A ALLOWED_HEADER_VALUE_CHARACTERS N/A frozenset N/A N/A chr c N/A c N/A range 32 128 _ignore_response_headers_rewriter N/A N/A ignored_response_headers state N/A N/A N/A Ignore specific response headers.

  Certain response headers cannot be modified by an application. For a complete
  list of these headers please see:

    https://developers.google.com/appengine/docs/python/runtime#Responses

  This rewriter simply removes those headers. It also removes non-printable
  ASCII characters and non-ASCII characters, which are disallowed according to
  RFC 2616.

  Args:
    ignored_response_headers: A list of header names to remove.
    state: A RewriterState to modify.
   N/A N/A name value N/A N/A N/A state headers items N/A N/A N/A N/A N/A name lower ignored_response_headers N/A N/A N/A N/A state headers N/A name N/A N/A N/A N/A isinstance name unicode N/A N/A name N/A N/A name encode ascii N/A N/A isinstance value unicode N/A N/A value N/A N/A value encode ascii N/A N/A N/A UnicodeEncodeError N/A N/A N/A N/A state headers N/A name N/A N/A N/A N/A set name ALLOWED_HEADER_NAME_CHARACTERS N/A N/A set value ALLOWED_HEADER_VALUE_CHARACTERS N/A N/A N/A N/A state headers N/A name N/A _default_content_type_rewriter N/A N/A state N/A N/A N/A Set the default Content-Type header.

  Args:
    state: A RewriterState to modify.
   N/A N/A N/A Content-Type N/A state headers N/A N/A N/A N/A state headers N/A Content-Type text/html N/A _cache_rewriter N/A N/A state N/A N/A N/A Set the default Cache-Control and Expires headers, and sanitize them.

  The default values are only set if the response status allows a body, and only
  if the headers have not been explicitly set by the application.

  If the Set-Cookie response header is set, sanitizes the Cache-Control and
  Expires headers to avoid public caching.

  Args:
    state: A RewriterState to modify.
   N/A N/A N/A state status_code N/A constants NO_BODY_RESPONSE_STATUSES N/A N/A N/A N/A N/A Cache-Control N/A state headers N/A N/A N/A N/A state headers N/A Cache-Control no-cache N/A N/A N/A Expires N/A state headers N/A N/A N/A N/A state headers N/A Expires Fri, 01 Jan 1990 00:00:00 GMT N/A N/A Set-Cookie N/A state headers N/A N/A current_date N/A N/A time time N/A expires N/A N/A N/A state headers get Expires N/A reset_expires True N/A expires N/A N/A expires_time N/A N/A N/A email Utils parsedate expires N/A expires_time N/A N/A reset_expires N/A N/A N/A calendar timegm expires_time current_date N/A reset_expires N/A N/A N/A N/A state headers N/A Expires N/A N/A time strftime %a, %d %b %Y %H:%M:%S GMT N/A N/A time gmtime current_date N/A cache_directives N/A N/A header N/A N/A N/A state headers get_all Cache-Control N/A N/A N/A N/A cache_directives extend N/A N/A N/A v strip N/A v N/A N/A header split , N/A cache_directives N/A d N/A d cache_directives N/A d public N/A N/A N/A N/A N/A constants NON_PUBLIC_CACHE_CONTROLS intersection cache_directives N/A N/A N/A N/A cache_directives append private N/A N/A N/A state headers N/A Cache-Control N/A N/A ,  join cache_directives N/A _content_length_rewriter N/A N/A state N/A N/A N/A Rewrite the Content-Length header.

  Even though Content-Length is not a user modifiable header, App Engine
  sends a correct Content-Length to the user based on the actual response.

  If the response status code indicates that the response is not allowed to
  contain a body, the body will be deleted instead. If the response body is
  longer than the maximum response length, the response will be turned into a
  500 Internal Server Error.

  Args:
    state: A RewriterState to modify.
   N/A N/A state body N/A list N/A state body N/A length N/A sum N/A N/A len block N/A block N/A state body N/A N/A N/A state status_code N/A constants NO_BODY_RESPONSE_STATUSES N/A N/A N/A state body N/A N/A N/A N/A state headers N/A Content-Length N/A N/A N/A N/A N/A N/A state environ get REQUEST_METHOD HEAD N/A N/A length N/A N/A N/A N/A logging warning Dropping unexpected body in response to HEAD request N/A N/A state body N/A N/A N/A N/A N/A N/A state allow_large_response N/A length N/A constants MAX_RUNTIME_RESPONSE_SIZE N/A N/A N/A N/A logging error Response too large: %d, max is %d length N/A constants MAX_RUNTIME_RESPONSE_SIZE N/A new_response N/A HTTP response was too large: %d. The limit is: %d.
 N/A length N/A constants MAX_RUNTIME_RESPONSE_SIZE N/A N/A state status 500 Internal Server Error N/A N/A N/A state headers N/A Content-Type text/html N/A N/A N/A state headers N/A Content-Length N/A str N/A len new_response N/A N/A state body N/A new_response N/A N/A N/A N/A state headers N/A Content-Length N/A str length N/A N/A _FRONTEND_RESPONSE_REWRITER_CHAIN N/A N/A blob_download blobstore_download_rewriter N/A N/A functools partial _ignore_response_headers_rewriter N/A constants FRONTEND_IGNORED_RESPONSE_HEADERS _default_content_type_rewriter _cache_rewriter _content_length_rewriter N/A _RUNTIME_RESPONSE_REWRITER_CHAIN N/A _content_length_rewriter N/A N/A functools partial _ignore_response_headers_rewriter N/A constants RUNTIME_IGNORED_RESPONSE_HEADERS _rewriter_middleware N/A N/A request_rewriter_chain response_rewriter_chain application environ start_response N/A N/A N/A Wraps an application and applies a chain of rewriters to its response.

  This first applies each function in request_rewriter_chain to the environ. It
  then executes the application, and applies each function in
  response_rewriter_chain to the response.

  Args:
    request_rewriter_chain: A chain of functions to apply to the environ.
    response_rewriter_chain: A chain of functions to apply to the response.
    application: The WSGI application to wrap as defined in PEP-333.
    environ: An environ dict for the current request as defined in PEP-333.
    start_response: A function with semantics defined in PEP-333.

  Returns:
    An iterable of strings containing the body of an HTTP response.
   N/A response_dict N/A headers_sent False N/A write_body N/A N/A cStringIO StringIO wrapped_start_response N/A N/A status response_headers exc_info N/A None N/A N/A N/A exc_info N/A response_dict N/A headers_sent N/A N/A N/A exc_info N/A 0 N/A exc_info N/A 1 N/A exc_info N/A 2 N/A N/A response_dict N/A status status N/A N/A response_dict N/A response_headers response_headers N/A N/A write_body write N/A N/A rewriter request_rewriter_chain N/A N/A N/A rewriter environ N/A response_body N/A iter N/A application environ wrapped_start_response N/A first N/A N/A write_body getvalue N/A N/A first N/A N/A N/A N/A first N/A N/A response_body next N/A N/A N/A StopIteration N/A N/A N/A N/A response_dict N/A headers_sent True N/A N/A N/A status N/A response_dict N/A status N/A response_headers N/A response_dict N/A response_headers N/A N/A N/A KeyError N/A N/A N/A AssertionError Application yielded before calling start_response. reconstructed_body N/A N/A N/A N/A N/A N/A first N/A string response_body N/A N/A N/A string N/A N/A body N/A reconstructed_body N/A state N/A RewriterState environ status response_headers body N/A rewriter response_rewriter_chain N/A N/A N/A rewriter state N/A N/A start_response N/A state status N/A N/A N/A state headers items N/A N/A state body N/A frontend_rewriter_middleware N/A N/A application N/A N/A N/A WSGI middleware application that applies a chain of response rewriters.

  Args:
    application: The WSGI application to wrap as defined in PEP-333.

  Returns:
    A WSGI application that applies the rewriter chain to the inner application.
   N/A N/A N/A functools partial _rewriter_middleware _REQUEST_REWRITER_CHAIN _FRONTEND_RESPONSE_REWRITER_CHAIN application N/A runtime_rewriter_middleware N/A N/A application N/A N/A N/A WSGI middleware application that applies a chain of response rewriters.

  Args:
    application: The WSGI application to wrap as defined in PEP-333.

  Returns:
    A WSGI application that applies the rewriter chain to the inner application.
   N/A N/A N/A functools partial _rewriter_middleware _REQUEST_REWRITER_CHAIN _RUNTIME_RESPONSE_REWRITER_CHAIN application N/A