Lines Matching +full:get +full:- +full:content
23 response, content = http.request(
26 assert response["content-location"] == tests.DUMMY_URL
27 assert content == b"the body"
36 response, content = http.request(
49 http.request("http://no-such-hostname./")
53 response, content = http.request("http://no-such-hostname./")
54 assert response["content-type"] == "text/plain"
55 assert content.startswith(b"Unable to find")
60 os.environ.get("TRAVIS_PYTHON_VERSION") in ("2.7", "pypy"),
62 "See https://travis-ci.org/httplib2/httplib2/jobs/408769880.",
74 os.environ.get("TRAVIS_PYTHON_VERSION") in ("2.7", "pypy"),
76 "See https://travis-ci.org/httplib2/httplib2/jobs/408769880.",
83 response, content = http.request(tests.DUMMY_URL)
84 content = content.lower()
85 assert response["content-type"] == "text/plain"
87 b"connection refused" in content
88 or b"actively refused" in content
89 or b"socket is not connected" in content
98 response, content = http.request(uri + query, "GET")
100 reflected = tests.HttpRequest.from_bytes(content)
105 # Test that GET is the default method
108 response, content = http.request(uri)
110 reflected = tests.HttpRequest.from_bytes(content)
111 assert reflected.method == "GET"
117 methods = ["GET", "PUT", "DELETE", "POST", "unknown"]
120 response, content = http.request(uri, method, body=b" ")
122 reflected = tests.HttpRequest.from_bytes(content)
130 respond_with = b"HTTP/1.0 200 OK\r\ncontent-length: " b"14\r\n\r\nnon-empty-body"
132 response, content = http.request(uri, "HEAD")
134 assert content == b""
138 # Test that can do a GET w/o the cache turned on.
141 response, content = http.request(uri, "GET")
147 # Test that we provide a default user-agent
150 response, content = http.request(uri, "GET")
152 reflected = tests.HttpRequest.from_bytes(content)
153 assert reflected.headers.get("user-agent", "").startswith("Python-httplib2/")
157 # Test that the default user-agent can be over-ridden
160 response, content = http.request(uri, "GET", headers={"User-Agent": "fred/1.0"})
162 reflected = tests.HttpRequest.from_bytes(content)
163 assert reflected.headers.get("user-agent") == "fred/1.0"
177 response, content = http.request(uri, "GET")
179 assert content == final_content
185 response, content = http.request(uri, "GET")
187 assert content == final_content
202 response, content = http.request(uri, "GET")
213 response, content = http.request(uri, "GET")
216 assert content == b"redirect body"
234 response1, content1 = http.request(uri, "GET")
235 response2, content2 = http.request(uri, "GET")
237 assert "content-location" in response2
238 assert response1["content-location"] == destination
244 assert response2["content-location"] == destination
251 not os.environ.get("httplib2_test_still_run_skipped")
252 and os.environ.get("TRAVIS_PYTHON_VERSION") in ("2.7", "pypy"),
269 response, content = http.request(uri, "HEAD")
271 assert response["content-location"] == destination
287 headers={"location": "/final", "cache-control": "max-age=300"},
292 response, _ = http.request(uri, "GET")
295 response, _ = http.request(uri, "GET")
317 response1, content1 = http.request(second_url, "GET")
318 response2, content2 = http.request(second_url, "GET")
319 response3, content3 = http.request(uri, "GET")
321 assert response1["content-location"] == final_url
329 assert response2["content-location"] == final_url
333 assert response2.previous["content-location"] == second_url
359 http.request(uri, "GET", redirections=1)
366 # Re-run the test with out the exceptions
368 response, content = http.request(uri, "GET", redirections=1)
373 assert content == b"second redirect"
378 # Test that we throw an exception when we get
384 http.request(uri, "GET")
391 # Re-run the test with out the exceptions
393 response, content = http.request(uri, "GET")
398 assert content == b""
402 not os.environ.get("httplib2_test_still_run_skipped")
403 and os.environ.get("TRAVIS_PYTHON_VERSION") in ("2.7", "pypy"),
407 # Do a follow-up GET on a Location: header
417 response, content = http.request(uri, "POST", " ")
419 reflected = tests.HttpRequest.from_bytes(content)
423 # Skip follow-up GET
427 response, content = http.request(uri, "POST", " ")
432 cases = "DELETE GET HEAD POST PUT EVEN_NEW_ONES".split(" ")
435 response, content = http.request(uri, method, body=b"q q")
437 reflected = tests.HttpRequest.from_bytes(content)
438 assert reflected.method == "GET"
449 headers={"cache-control": "public,max-age=300"},
453 if request.headers.get("range"):
458 response, _ = http.request(uri, "GET", headers={"accept-encoding": "identity"})
461 http.request(uri, "GET", headers={"accept-encoding": "identity"})
464 "GET",
465 headers={"accept-encoding": "identity", "cache-control": "must-revalidate"},
472 cache_path, httplib2.safename(httplib2.urlnorm(uri)[-1])
478 response, content = http.request(
479 uri, "HEAD", headers={"accept-encoding": "identity"}
484 response, content = http.request(
485 uri, "GET", headers={"accept-encoding": "identity", "range": "bytes=0-0"}
496 response, content = http.request(
497 uri, "GET", headers={"accept-encoding": "identity"}
502 response, content = http.request(
504 "GET",
505 headers={"accept-encoding": "identity", "cache-control": "max-age=0"},
507 reflected = tests.HttpRequest.from_bytes(content)
508 assert reflected.headers.get("if-none-match")
511 response, content = http.request(
513 "GET",
514 headers={"accept-encoding": "identity", "cache-control": "max-age=0"},
517 reflected = tests.HttpRequest.from_bytes(content)
518 assert not reflected.headers.get("if-none-match")
526 response, _ = http.request(uri, "GET", headers={"accept-encoding": "identity"})
530 response, content = http.request(
532 "GET",
533 headers={"accept-encoding": "identity", "cache-control": "max-age=0"},
536 reflected = tests.HttpRequest.from_bytes(content)
537 assert reflected.headers.get("if-none-match")
538 assert reflected.headers.get("if-none-match") != "fred"
540 response, content = http.request(
542 "GET",
544 "accept-encoding": "identity",
545 "cache-control": "max-age=0",
546 "if-none-match": "fred",
550 reflected = tests.HttpRequest.from_bytes(content)
551 assert reflected.headers.get("if-none-match") == "fred"
557 # Test that end to end headers get overwritten in the cache
559 # response, content = http.request(uri, 'GET')
564 # response, content = http.request(uri, 'GET', headers = {'Cache-Control': 'max-age=0'})
574 # by only using the last-modified cache validator.
581 status=200, body=b"something", headers={"date": date, "last-modified": date}
585 assert request2.headers["if-modified-since"] == date
589 response, content = http.request(uri, "GET")
590 assert response.get("last-modified") == date
592 response, content = http.request(uri, "GET")
605 body=b"final content\n",
606 headers={"cache-control": "max-age=300"},
610 response, content = http.request(uri, "GET")
615 assert content == b"final content\n"
617 response, content = http.request(uri, "GET")
622 assert content == b"final content\n"
630 r200 = tests.http_response_bytes(status=200, body=b"final content\n")
633 response, content = http.request(uri, "POST")
638 assert content == b"final content\n"
640 response, content = http.request(uri, "POST")
645 assert content == b"final content\n"
656 headers={"cache-control": "max-age=300", "location": "/final"},
661 response, content = http.request(uri, "CHANGE", body=b"hello308")
666 assert content.startswith(b"CHANGE /final HTTP")
668 response, content = http.request(uri, "CHANGE")
673 assert content.startswith(b"CHANGE /final HTTP")
680 response, content = http.request(uri, "GET")
685 # Test that duplicate headers get concatenated via ','
689 Content-Length: 7\r\n\
691 content"""
693 response, content = http.request(uri, "GET")
695 assert content == b"content"
703 response, content = http.request(uri, "GET")
710 # GET /?q= HTTP/1.1 <- injected "HTTP/1.1" from attacker
712 # ignore-http: HTTP/1.1 <- nominal "HTTP/1.1" from library
717 uri, "?q= HTTP/1.1\r\ninjected: attack\r\nignore-http:"
719 response, content = http.request(danger_url, "GET")
721 req = tests.HttpRequest.from_bytes(content)
722 assert req.headers.get("injected") is None
726 # Injecting space into request line is precursor to CWE-93 and possibly other injections
729 # "\r\nignore-http:" suffix is nuance for current server implementation
731 danger_url = urllib.parse.urljoin(uri, "?q= HTTP/1.1\r\nignore-http:")
732 response, content = http.request(danger_url, "GET")
734 req = tests.HttpRequest.from_bytes(content)
735 assert req.uri == "/?q=%20HTTP/1.1%0D%0Aignore-http:"