Module Expr Str Import alias Import alias Import alias Import alias Import alias Assign NameStore Str Assign NameStore BinOpAdd NameLoad Str Assign NameStore BinOpAdd NameLoad Str Assign NameStore BinOpAdd NameLoad Str Assign NameStore Str FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Num Assign NameStore Str Assign NameStore ListLoad TupleLoad Str Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Return Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad decorator_list ClassDef bases NameLoad body FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr ListLoad TupleLoad NameLoad AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body If UnaryOpNot Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr body TryExcept body Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad body Expr Call AttributeLoad NameLoad attr Str AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr NameLoad If AttributeLoad NameLoad attr body Assign AttributeStore NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad AttributeLoad NameLoad attr attr TupleLoad NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str For TupleStore NameStore NameStore AttributeLoad NameLoad attr body If Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad body Return Call NameLoad NameLoad SubscriptLoad AttributeLoad NameLoad attr Slice Call NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Delete NameDel TryExcept body Assign NameStore Call NameLoad NameLoad Return Call NameLoad NameLoad handlers ExceptHandler type NameLoad body Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore NameLoad If UnaryOpNot NameLoad body Return NameLoad Assign NameStore AttributeLoad NameLoad attr If UnaryOpNot Call AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad NameLoad attr Str NameLoad Return Call NameLoad Num Assign NameStore SubscriptLoad NameLoad Slice Call NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr BinOpMod Str TupleLoad AttributeLoad NameLoad attr NameLoad If UnaryOpNot Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr Str NameLoad Return Call NameLoad Num With Call NameLoad NameLoad Str NameStore body Expr Call AttributeLoad NameLoad attr NameLoad Return Call NameLoad Num decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr TupleLoad NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore NameLoad If CompareEq NameLoad Str body Expr Call AttributeLoad AttributeLoad NameLoad attr attr Return Call NameLoad Num orelse If CompareEq NameLoad Str body Expr Call AttributeLoad AttributeLoad NameLoad attr attr Return Call NameLoad Num orelse If CompareEq NameLoad Str body Assign NameStore Dict Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Assign SubscriptStore NameLoad Index Str NameLoad Assign SubscriptStore NameLoad Index Str Call AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr If NameLoad body Assign SubscriptStore NameLoad Index Str Call AttributeLoad NameLoad attr NameLoad Return Call NameLoad NameLoad orelse If CompareEq NameLoad Str body Assign AttributeStore AttributeLoad NameLoad attr attr NameLoad Return Call NameLoad Num orelse If CompareEq NameLoad Str body Expr Call AttributeLoad NameLoad attr Str SubscriptLoad Call NameLoad AttributeLoad NameLoad attr Slice Num Return Call NameLoad Num Return NameLoad decorator_list decorator_list
N/A N/A Handle special HTTP requests.

/web-page-replay-generate-[RESPONSE_CODE]
  - Return the given RESPONSE_CODE.
/web-page-replay-post-image-[FILENAME]
  - Save the posted image to local disk.
/web-page-replay-command-[record|replay|status]
  - Optional. Enable by calling custom_handlers.add_server_manager_handler(...).
  - Change the server mode to either record or replay.
    + When switching to record, the http_archive is cleared.
    + When switching to replay, the http_archive is maintained.
 N/A base64 N/A httparchive N/A json N/A logging N/A os N/A COMMON_URL_PREFIX /web-page-replay- N/A COMMAND_URL_PREFIX N/A COMMON_URL_PREFIX command- N/A GENERATOR_URL_PREFIX N/A COMMON_URL_PREFIX generate- N/A POST_IMAGE_URL_PREFIX N/A COMMON_URL_PREFIX post-image- N/A IMAGE_DATA_PREFIX data:image/png;base64, SimpleResponse N/A N/A status N/A N/A N/A Return a ArchivedHttpResponse with |status| code and a simple text body. N/A N/A N/A httparchive create_response status N/A JsonResponse N/A N/A data N/A N/A N/A Return a ArchivedHttpResponse with |data| encoded as json in the body. N/A status 200 N/A reason OK N/A headers N/A N/A content-type application/json N/A body N/A N/A json dumps data N/A N/A N/A httparchive create_response status reason headers body N/A CustomHandlers N/A object N/A __init__ N/A N/A self options http_archive N/A N/A N/A Initialize CustomHandlers.

    Args:
      options: original options passed to the server.
      http_archive: reference to the HttpArchive object.
     N/A N/A self server_manager None N/A N/A self options options N/A N/A self http_archive http_archive N/A N/A self handlers N/A N/A GENERATOR_URL_PREFIX N/A self get_generator_url_response_code N/A N/A options screenshot_dir N/A N/A N/A N/A N/A N/A os path exists N/A options screenshot_dir N/A N/A N/A N/A N/A N/A os makedirs N/A options screenshot_dir N/A N/A N/A IOError N/A N/A N/A N/A logging error Unable to create screenshot dir: %s N/A options screenshot_dir N/A N/A options screenshot_dir None N/A N/A options screenshot_dir N/A N/A N/A self screenshot_dir N/A options screenshot_dir N/A N/A N/A N/A self handlers append N/A POST_IMAGE_URL_PREFIX N/A self handle_possible_post_image N/A handle N/A N/A self request N/A N/A N/A Dispatches requests to matching handlers.

    Args:
      request: an http request
    Returns:
      ArchivedHttpResponse or None.
     N/A N/A prefix handler N/A self handlers N/A N/A N/A N/A N/A request full_path startswith prefix N/A N/A N/A handler request N/A N/A request full_path N/A N/A len prefix N/A None N/A get_generator_url_response_code N/A N/A self request url_suffix N/A N/A N/A Parse special generator URLs for the embedded response code.

    Args:
      request: an ArchivedHttpRequest instance
      url_suffix: string that is after the handler prefix (e.g. 304)
    Returns:
      On a match, an ArchivedHttpResponse.
      Otherwise, None.
     N/A request N/A N/A N/A response_code N/A int url_suffix N/A N/A SimpleResponse response_code N/A N/A N/A ValueError N/A N/A None N/A handle_possible_post_image N/A N/A self request url_suffix N/A N/A N/A If sent, saves embedded image to local directory.

    Expects a special url containing the filename. If sent, saves the base64
    encoded request body as a PNG image locally. This feature is enabled by
    passing in screenshot_dir to the initializer for this class.

    Args:
      request: an ArchivedHttpRequest instance
      url_suffix: string that is after the handler prefix (e.g. 'foo.png')
    Returns:
      On a match, an ArchivedHttpResponse.
      Otherwise, None.
     N/A basename url_suffix N/A N/A basename N/A N/A None N/A data N/A request request_body N/A N/A N/A N/A data startswith IMAGE_DATA_PREFIX N/A N/A N/A N/A logging error Unexpected image format for: %s basename N/A N/A SimpleResponse 400 N/A data N/A data N/A N/A len IMAGE_DATA_PREFIX N/A png N/A N/A base64 b64decode data N/A filename N/A N/A N/A os path join N/A self screenshot_dir N/A %s-%s.png N/A N/A request host basename N/A N/A N/A N/A os access N/A self screenshot_dir N/A os W_OK N/A N/A N/A N/A logging error Unable to write to: %s filename N/A N/A SimpleResponse 400 N/A N/A file filename w f N/A N/A N/A N/A f write png N/A N/A SimpleResponse 200 N/A add_server_manager_handler N/A N/A self server_manager N/A N/A N/A Add the ability to change the server mode (e.g. to record mode).
    Args:
      server_manager: a servermanager.ServerManager instance.
     N/A N/A self server_manager server_manager N/A N/A N/A N/A self handlers append N/A COMMAND_URL_PREFIX N/A self handle_server_manager_command N/A handle_server_manager_command N/A N/A self request url_suffix N/A N/A N/A Parse special URLs for the embedded server manager command.

    Clients like webpagetest.org can use URLs of this form to change
    the replay server from record mode to replay mode.

    This handler is not in the default list of handlers. Call
    add_server_manager_handler to add it.

    In the future, this could be expanded to save or serve archive files.

    Args:
      request: an ArchivedHttpRequest instance
      url_suffix: string that is after the handler prefix (e.g. 'record')
    Returns:
      On a match, an ArchivedHttpResponse.
      Otherwise, None.
     N/A command url_suffix N/A N/A command record N/A N/A N/A N/A N/A self server_manager SetRecordMode N/A N/A SimpleResponse 200 N/A N/A N/A command replay N/A N/A N/A N/A N/A self server_manager SetReplayMode N/A N/A SimpleResponse 200 N/A N/A N/A command status N/A N/A status N/A N/A is_record_mode N/A N/A N/A self server_manager IsRecordMode N/A N/A status N/A is_record_mode is_record_mode N/A N/A status N/A options N/A N/A json loads N/A str N/A self options N/A archive_stats N/A N/A N/A self http_archive stats N/A archive_stats N/A N/A N/A status N/A archive_stats N/A N/A json loads archive_stats N/A N/A JsonResponse status N/A N/A N/A command exit N/A N/A N/A N/A self server_manager should_exit True N/A N/A SimpleResponse 200 N/A N/A N/A command log N/A N/A N/A N/A logging info log command: %s N/A N/A str N/A request request_body N/A 1000000 N/A N/A SimpleResponse 200 N/A None N/A N/A