Lines Matching +full:cache +full:- +full:from
12 # Test that can do a GET with cache and 'only-if-cached'
13 http = httplib2.Http(cache=tests.get_cache_path())
17 uri, "GET", headers={"cache-control": "only-if-cached"}
24 # Test that can do a GET with no cache with 'only-if-cached'
25 http = httplib2.Http(cache=tests.get_cache_path())
28 uri, "GET", headers={"cache-control": "only-if-cached"}
35 # Test that can do a GET with no cache with 'only-if-cached'
37 # that responds to the 'only-if-cached', so this
42 uri, "GET", headers={"cache-control": "only-if-cached"}
52 # impact if the cache is used
54 # uri = urllib.parse.urljoin(base, "vary/no-vary.asis")
61 # assert response.fromcache, "Should be from cache"
65 # assert response.fromcache, "Should be from cache"
70 # See https://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html.
71 http = httplib2.Http(cache=tests.get_cache_path())
73 headers={"vary": "Accept", "cache-control": "max-age=300"}, add_date=True
80 # get the resource again, from the cache since accept header in this
84 assert response.fromcache, "Should be from cache"
86 # get the resource again, not from cache since Accept headers does not match
89 assert not response.fromcache, "Should not be from cache"
94 assert not response.fromcache, "Should not be from cache"
98 http = httplib2.Http(cache=tests.get_cache_path())
100 headers={"vary": "Accept, Accept-Language", "cache-control": "max-age=300"},
109 "Accept-Language": "da, en-gb;q=0.8, en;q=0.7",
115 # we are from cache
121 "Accept-Language": "da, en-gb;q=0.8, en;q=0.7",
124 assert response.fromcache, "Should be from cache"
130 # get the resource again, not from cache, varied headers don't match exact
131 response, content = http.request(uri, "GET", headers={"Accept-Language": "da"})
133 assert not response.fromcache, "Should not be from cache"
137 http = httplib2.Http(cache=tests.get_cache_path())
139 headers={"vary": "X-No-Such-Header", "cache-control": "max-age=300"},
148 # we are from cache
150 assert response.fromcache, "Should be from cache"
154 # Test Cache-Control: no-cache on requests
155 http = httplib2.Http(cache=tests.get_cache_path())
159 headers={"cache-control": "max-age=300"},
162 response, _ = http.request(uri, "GET", headers={"accept-encoding": "identity"})
166 response, _ = http.request(uri, "GET", headers={"accept-encoding": "identity"})
172 headers={"accept-encoding": "identity", "Cache-Control": "no-cache"},
179 # Test Pragma: no-cache on requests
180 http = httplib2.Http(cache=tests.get_cache_path())
184 headers={"cache-control": "max-age=300"},
187 response, _ = http.request(uri, "GET", headers={"accept-encoding": "identity"})
189 response, _ = http.request(uri, "GET", headers={"accept-encoding": "identity"})
193 uri, "GET", headers={"accept-encoding": "identity", "Pragma": "no-cache"}
200 # A no-store request means that the response should not be stored.
201 http = httplib2.Http(cache=tests.get_cache_path())
205 headers={"cache-control": "max-age=300"},
208 response, _ = http.request(uri, "GET", headers={"Cache-Control": "no-store"})
211 response, _ = http.request(uri, "GET", headers={"Cache-Control": "no-store"})
217 # A no-store response means that the response should not be stored.
218 http = httplib2.Http(cache=tests.get_cache_path())
222 headers={"cache-control": "max-age=300, no-store"},
234 # Test that a no-store, no-cache clears the entry from the cache
236 http = httplib2.Http(cache=tests.get_cache_path())
240 headers={"cache-control": "max-age=300"},
247 uri, "GET", headers={"Cache-Control": "no-store, no-cache"}
252 uri, "GET", headers={"Cache-Control": "no-store, no-cache"}
260 # URI that is cache invalidates that cache.
261 http = httplib2.Http(cache=tests.get_cache_path())
267 add_date=True, add_etag=True, headers={"cache-control": "max-age=300"}
284 if request.headers.get("if-none-match", "") == "12345":
287 add_date=True, headers={"etag": "12345", "cache-control": "max-age=300"}
290 if request.headers.get("if-match", "") == "12345":
299 http = httplib2.Http(cache=tests.get_cache_path())
315 http = httplib2.Http(cache=tests.get_cache_path())
330 http = httplib2.Http(cache=tests.get_cache_path())
339 uri, "PUT", body=b"foo", headers={"if-match": "fred"}
348 ({"cache-control": " no-cache"}, {"no-cache": 1}),
350 {"cache-control": " no-store, max-age = 7200"},
351 {"no-store": 1, "max-age": "7200"},
353 ({"cache-control": " , "}, {"": 1}), # FIXME
355 {"cache-control": "Max-age=3600;post-check=1800,pre-check=3600"},
356 {"max-age": "3600;post-check=1800", "pre-check": "3600"},
368 h = httplib2._normalize_headers({"Cache-Control": "no-cache", "Other": "Stuff"})
369 assert "cache-control" in h
378 {"cache-control": "no-cache"},
379 {"cache-control": "max-age=7200"},
382 ({}, {"cache-control": "max-age=fred, min-fresh=barney"}, "STALE"),
386 {"date": "{now}", "expires": "{now+3}", "cache-control": "no-cache"},
389 ({"cache-control": "must-revalidate"}, {}, "STALE"),
390 ({}, {"cache-control": "must-revalidate"}, "STALE"),
391 ({}, {"date": "{now}", "cache-control": "max-age=0"}, "STALE"),
392 ({"cache-control": "only-if-cached"}, {}, "FRESH"),
396 {"cache-control": "max-age=0"},
397 {"date": "{now}", "cache-control": "max-age=2"},
401 {"cache-control": "min-fresh=2"},
406 {"cache-control": "min-fresh=2"},
415 nowre = re.compile(r"{now([\+\-]\d+)?}")
433 "cache-control": "max-age=2",
452 # TODO: Repeat all cache tests with memcache. pytest.mark.parametrize
453 # cache = memcache.Client(['127.0.0.1:11211'], debug=0)
454 # #cache = memcache.Client(['10.0.0.4:11211'], debug=1)
455 # http = httplib2.Http(cache)