Exemplo n.º 1
0
    def _do_get(url, headers, **kwargs):
        # More time please
        if 'timeout' not in kwargs:
            kwargs['timeout'] = 60

        if 'allow_redirects' not in kwargs:
            kwargs['allow_redirects'] = True

        response = HTTP.get_with_timeout(url, headers=headers, **kwargs)
        return response.status_code, response.headers, response.content
Exemplo n.º 2
0
    def _get(self, url, headers):
        """Make the sort of HTTP request that's normal for an OPDS feed.

        Long timeout, raise error on anything but 2xx or 3xx.
        """
        headers = dict(headers or {})

        types = dict(
            opds_acquisition=OPDSFeed.ACQUISITION_FEED_TYPE,
            atom="application/atom+xml",
            xml="application/xml",
            anything="*/*",
        )
        headers['Accept'] = "%(opds_acquisition)s, %(atom)s;q=0.9, %(xml)s;q=0.8, %(anything)s;q=0.1" % types
        kwargs = dict(timeout=120, allowed_response_codes=['2xx', '3xx'])
        response = HTTP.get_with_timeout(url, headers=headers, **kwargs)
        return response.status_code, response.headers, response.content
Exemplo n.º 3
0
 def _get(self, url, **kwargs):
     """Make an HTTP request. This method is overridden in the mock class."""
     return HTTP.get_with_timeout(url, **kwargs)