import httplib import mimetypes import os import os.path import re import zlib from google.appengine.api import appinfo from google.appengine.tools import augment_mimetypes from google.appengine.tools.devappserver2 import errors from google.appengine.tools.devappserver2 import url_handler _FILE_MISSING_ERRNO_CONSTANTS = frozenset([errno.ENOENT, errno.ENOTDIR]) # Run at import time so we only do this once. augment_mimetypes.init() class StaticContentHandler(url_handler.UserConfiguredURLHandler): """Abstract base class for subclasses serving static content.""" # Associate the full path of a static file with a 2-tuple containing the: # - mtime at which the file was last read from disk # - a etag constructed from a hash of the file's contents # Statting a small file to retrieve its mtime is approximately 20x faster than # reading it to generate a hash of its contents. _filename_to_mtime_and_etag = {} def __init__(self, root_path, url_map, url_pattern): """Initializer for StaticContentHandler.