def __call__(self, env, start_response):
        """
        Accepts a standard WSGI application call.
        There are 2 types of requests that this middleware will affect.
        1. Requests to CDN 'database' that will enable, list, etc. containers
           for the CDN.
        2. Requests (GETs, HEADs) from CDN provider to publicly available
           containers.
        The types of requests can be determined by looking at the hostname of
        the incoming call.
        Wraps env in swob.Request object and passes it down.

        :param env: WSGI environment dictionary
        :param start_response: WSGI callable
        """
        env['sos.start_time'] = time()
        host = env.get('HTTP_HOST', '').split(':')[0]
        try:
            handler = None
            request_type = 'SOS_LOG'
            if host in self.origin_db_hosts:
                handler = OriginDbHandler(self.app, self.conf, self.logger)
                request_type = 'SOS_DB'
            for cdn_host_suffix in self.origin_cdn_host_suffixes:
                if host.endswith(cdn_host_suffix) and \
                        host not in self.ignore_hosts:
                    handler = CdnHandler(self.app, self.conf, self.logger)
                    request_type = 'SOS_ORIGIN'
                    break
            if env['PATH_INFO'].startswith(self.origin_prefix):
                handler = AdminHandler(self.app, self.conf, self.logger)
                request_type = 'SOS_ADMIN'
            if handler:
                req = Request(env)
                resp = handler.handle_request(env, req)
                if request_type != 'SOS_ORIGIN':
                    self._log_request(env, resp, request_type)
                return resp(env, start_response)

        except InvalidConfiguration, e:
            self.logger.exception(e)
            return HTTPInternalServerError(body=str(e))(env, start_response)
        except InvalidUtf8:
            return HTTPPreconditionFailed(
                body='Invalid UTF8')(env, start_response)
        except OriginRequestNotAllowed, e:
            self.logger.debug(e)
        return self.app(env, start_response)
dataset/ETHPy150Open dpgoetz/sos/sos/origin.py/OriginServer.__call__/original