def request(self, method, url, **kwargs):
        _log.info("{0} - {1}".format(method.upper(), url))

        # apply global timeout
        timeout = kwargs.pop('timeout', self.timeout)

        if self._header_func:
            headers = requests.structures.CaseInsensitiveDict(self._header_func(url))
        else:
            headers = {}

        kwarg_headers = kwargs.pop('headers', {})
        headers = requests.sessions.merge_setting(
            headers, self.headers,
            dict_class=requests.structures.CaseInsensitiveDict)
        headers = requests.sessions.merge_setting(
            kwarg_headers, headers,
            dict_class=requests.structures.CaseInsensitiveDict)

        _start_time = time.time()

        resp = super(Scraper, self).request(method, url, timeout=timeout, headers=headers,
                                            **kwargs)
        self.stats['total_requests'] += 1
        self.stats['total_time'] += (time.time() - _start_time)
        self.stats['average_time'] = self.stats['total_time'] / self.stats['total_requests']

        if self.raise_errors and not self.accept_response(resp):
            raise HTTPError(resp)
        return resp
dataset/ETHPy150Open jamesturk/scrapelib/scrapelib/__init__.py/Scraper.request/original