Esempio n. 1
0
def main():
    client = Client()
    request = Request(b"GET", b"https://www.google.com")
    transfer = client.send(request)
    response = transfer.wait()
    print(response)
    print(response.body)
Esempio n. 2
0
 def test_repr(self):
     request = Request(b"GET",
                       b"http://example.com/foo",
                       headers=[
                           (b"Accept", b"*"),
                       ])
     text = repr(request)
     assert text == ("Request(method=b'GET', "
                     "url=b'http://example.com/foo', "
                     "headers=[(b'Accept', b'*')], body=None)")
Esempio n. 3
0
 def test_repr_round_trip(self):
     request = Request(b"GET", b"/foo", body=b"fnar")
     text = repr(request)
     print("eval'ing {0!r}".format(text))
     clone = eval(text)
     assert clone == request
Esempio n. 4
0
 def test_equal_false(self):
     requests = [
         Request(b"GET", b"/foo"),
         Request(b"GET", b"/bar"),
     ]
     assert requests[1] != requests[0]
Esempio n. 5
0
 def test_equal_true(self):
     requests = [
         Request(b"GET", b"/foo"),
         Request(b"GET", b"/foo"),
     ]
     assert requests[1] == requests[0]
Esempio n. 6
0
 def test_init_body_unexpected(self, value):
     with pytest.raises(InvalidRequest):
         Request(b"GET", b"/foo", body=value)
Esempio n. 7
0
 def test_init_url_unexpected(self, value):
     with pytest.raises(InvalidRequest):
         Request(b"GET", value, body=b"whee")
Esempio n. 8
0
 def test_init_method_unexpected(self, value):
     with pytest.raises(InvalidRequest):
         Request(value, b"/foo", body=b"whee")