예제 #1
0
 def sess(self, server):
     self.etag_url = urljoin(server.application_url, '/etag')
     self.update_etag_url = urljoin(server.application_url, '/update_etag')
     self.cache = DictCache()
     sess = CacheControl(requests.Session(),
                         cache=self.cache,
                         cache_etags=False)
     return sess
예제 #2
0
 def sess(self, server):
     self.etag_url = urljoin(server.application_url, '/etag')
     self.update_etag_url = urljoin(server.application_url, '/update_etag')
     self.cache = DictCache()
     sess = CacheControl(requests.Session(),
                         cache=self.cache,
                         cache_etags=False)
     return sess
예제 #3
0
 def sess(self, server, url):
     self.etag_url = urljoin(url, '/etag')
     self.update_etag_url = urljoin(url, '/update_etag')
     self.cache = DictCache()
     sess = CacheControl(requests.Session(),
                         cache=self.cache,
                         cache_etags=False,
                         serializer=NullSerializer())
     return sess
예제 #4
0
 def sess(self, server, url):
     self.etag_url = urljoin(url, '/etag')
     self.update_etag_url = urljoin(url, '/update_etag')
     self.cache = DictCache()
     sess = CacheControl(requests.Session(),
                         cache=self.cache,
                         cache_etags=False,
                         serializer=NullSerializer())
     return sess
예제 #5
0
    def sess(self, url):
        self.etag_url = urljoin(url, "/etag")
        self.update_etag_url = urljoin(url, "/update_etag")
        self.cache = DictCache()
        sess = CacheControl(
            requests.Session(), cache=self.cache, serializer=NullSerializer()
        )
        yield sess

        # closing session object
        sess.close()
예제 #6
0
    def sess(self, url):
        self.etag_url = urljoin(url, "/etag")
        self.update_etag_url = urljoin(url, "/update_etag")
        self.cache = DictCache()
        sess = CacheControl(requests.Session(),
                            cache=self.cache,
                            serializer=NullSerializer())
        yield sess

        # closing session object
        sess.close()
예제 #7
0
    def test_not_modified_releases_connection(self, server):
        sess = CacheControl(requests.Session())
        etag_url = urljoin(server.application_url, '/etag')
        sess.get(etag_url)

        resp = Mock(status=304, headers={})

        # This is how the urllib3 response is created in
        # requests.adapters
        response_mod = 'requests.adapters.HTTPResponse.from_httplib'

        with patch(response_mod, Mock(return_value=resp)):
            sess.get(etag_url)
            assert resp.read.called
            assert resp.release_conn.called
예제 #8
0
    def test_not_modified_releases_connection(self, server):
        sess = CacheControl(requests.Session())
        etag_url = urljoin(server.application_url, "/etag")
        sess.get(etag_url)

        resp = Mock(status=304, headers={})

        # This is how the urllib3 response is created in
        # requests.adapters
        response_mod = "requests.adapters.HTTPResponse.from_httplib"

        with patch(response_mod, Mock(return_value=resp)):
            sess.get(etag_url)
            assert resp.read.called
            assert resp.release_conn.called
예제 #9
0
 def sess(self, server):
     self.url = urljoin(server.application_url, '/vary_accept')
     self.cache = DictCache()
     sess = CacheControl(requests.Session(), cache=self.cache)
     return sess
예제 #10
0
 def sess(self, server):
     self.url = urljoin(server.application_url, '/vary_accept')
     self.cache = DictCache()
     sess = CacheControl(requests.Session(), cache=self.cache)
     return sess
예제 #11
0
 def sess(self, url):
     self.url = urljoin(url, "/vary_accept")
     self.cache = DictCache()
     sess = CacheControl(requests.Session(), cache=self.cache)
     return sess
예제 #12
0
 def sess(self, server):
     self.etag_url = urljoin(server.application_url, "/etag")
     self.update_etag_url = urljoin(server.application_url, "/update_etag")
     self.cache = DictCache()
     sess = CacheControl(requests.Session(), cache=self.cache, cache_etags=False, serializer=NullSerializer())
     return sess
예제 #13
0
 def sess(self, url):
     self.url = urljoin(url, '/vary_accept')
     self.cache = DictCache()
     sess = CacheControl(requests.Session(), cache=self.cache)
     return sess