) # HTTP POST data only to string response. print( requests.post2dict("http://httpbin.org/post", """{"foo": "bar", "baz": true}""") ) # HTTP POST data only to dictionary response. print( requests.post2json( "http://httpbin.org/post", """{"foo": "bar", "baz": true}""")) # HTTP POST data to JSON response. print(requests.download("http://httpbin.org/image/jpeg", "foo.jpeg")) # HTTP GET Download 1 file. print(requests.get2str2(["http://httpbin.org/json", "http://httpbin.org/xml" ])) # HTTP GET body to string from a list. print( requests.download2([ ("http://httpbin.org/image/jpeg", "foo.jpg"), # HTTP GET Download a list of files. ("http://httpbin.org/image/svg", "bar.svg") ])) requests.set_headers([("key", "value")]) # Set HTTP Headers example. requests.debugConfig() # Debug the internal Configuration. print(requests.tuples2json([("key0", "value0"), ("key1", "value1")]))
def test_tuples2json(self): self.assertEqual(faster_than_requests.tuples2json([("key0", "value0"), ("key1", "value1")]), '{"key0":"value0","key1":"value1"}')