def test_get_304_last_modified(): # Test that we can still handle a 304 # by only using the last-modified cache validator. http = httplib2.Http(cache=tests.get_cache_path()) date = email.utils.formatdate() def handler(read): read() yield tests.http_response_bytes(status=200, body=b"something", headers={ "date": date, "last-modified": date }) request2 = read() assert request2.headers["if-modified-since"] == date yield tests.http_response_bytes(status=304) with tests.server_yield(handler, request_count=2) as uri: response, content = http.request(uri, "GET") assert response.get("last-modified") == date response, content = http.request(uri, "GET") assert response.status == 200 assert response.fromcache
def test_get_304_last_modified(): # Test that we can still handle a 304 # by only using the last-modified cache validator. http = httplib2.Http(cache=tests.get_cache_path()) date = email.utils.formatdate() def handler(read): read() yield tests.http_response_bytes( status=200, body=b'something', headers={ 'date': date, 'last-modified': date, }, ) request2 = read() assert request2.headers['if-modified-since'] == date yield tests.http_response_bytes(status=304) with tests.server_yield(handler, request_count=2) as uri: response, content = http.request(uri, 'GET') assert response.get('last-modified') == date response, content = http.request(uri, 'GET') assert response.status == 200 assert response.fromcache