def test_get_307(): # Test that we do follow 307 redirects but # do not cache the 307 http = httplib2.Http(cache=tests.get_cache_path(), timeout=1) r307 = tests.http_response_bytes(status=307, headers={"location": "/final"}) r200 = tests.http_response_bytes( status=200, add_date=True, body=b"final content\n", headers={"cache-control": "max-age=300"}, ) with tests.server_list_http([r307, r200, r307]) as uri: response, content = http.request(uri, "GET") assert response.previous.status == 307 assert not response.previous.fromcache assert response.status == 200 assert not response.fromcache assert content == b"final content\n" response, content = http.request(uri, "GET") assert response.previous.status == 307 assert not response.previous.fromcache assert response.status == 200 assert response.fromcache assert content == b"final content\n"
def test_get_307(): # Test that we do follow 307 redirects but # do not cache the 307 http = httplib2.Http(cache=tests.get_cache_path(), timeout=1) r307 = tests.http_response_bytes( status=307, headers={'location': '/final'}, ) r200 = tests.http_response_bytes( status=200, add_date=True, body=b'final content\n', headers={'cache-control': 'max-age=300'}, ) with tests.server_list_http([r307, r200, r307]) as uri: response, content = http.request(uri, 'GET') assert response.previous.status == 307 assert not response.previous.fromcache assert response.status == 200 assert not response.fromcache assert content == b'final content\n' response, content = http.request(uri, 'GET') assert response.previous.status == 307 assert not response.previous.fromcache assert response.status == 200 assert response.fromcache assert content == b'final content\n'
def test_post_307(): # 307: follow with same method http = httplib2.Http(cache=tests.get_cache_path(), timeout=1) http.follow_all_redirects = True r307 = tests.http_response_bytes(status=307, headers={"location": "/final"}) r200 = tests.http_response_bytes(status=200, body=b"final content\n") with tests.server_list_http([r307, r200, r307, r200]) as uri: response, content = http.request(uri, "POST") assert response.previous.status == 307 assert not response.previous.fromcache assert response.status == 200 assert not response.fromcache assert content == b"final content\n" response, content = http.request(uri, "POST") assert response.previous.status == 307 assert not response.previous.fromcache assert response.status == 200 assert not response.fromcache assert content == b"final content\n"