A HTTP library featuring file post capability and a connection pooling system that ensures thread safety.
So why choose urllib3 over Python's standard libraries urllib and urllib2? There are two main reasons: connection re-using/pooling and file posting. These features are missing from the standard libraries, making it much easier to use a module like urllib3 instead of implementing these functionalities yourself. Moreover, the standard libraries were designed to be independent and standalone, whereas urllib3 follows in a similar vein, meaning you can use it for a variety of situations where being able to post files, handle redirection, and retrying is useful.
One key benefit of re-using connections is improved performance. When you use a separate socket connection for each urllib call, you significantly increase the amount of resources required on the server's end, and decrease response times at the client's end. However, by reusing existing sockets (supported since HTTP 1.1), you can reduce the number of requests and use resources more efficiently. With some simple benchmarks conducted in the test/benchmark.py script, you can see that downloading 15 URLs from Google.com is about twice as fast when using HTTPConnectionPool with 1 connection, compared to using plain urllib with 15 connections.
Overall, this library is perfect for anyone who needs to talk to an API, crawl a website, or any situation where reusing connections, handling file posting, redirections, and retries is useful. It's also relatively lightweight, so it can be used for anything you need! If you need help getting started, you can go to the Examples wiki for even more syntax-highlighted examples. But to give you a taste, here's a short snippet:
from urllib3 import HTTPConnectionPool
API_URL = ''
http_pool = HTTPConnectionPool.from_url(API_URL)
fields = {'v': '1.0', 'q': 'urllib3'}
r = http_pool.get_url(API_URL, fields)
print(r.status, r.data)
This code shows you how easy it is to make a request to an API with urllib3. By creating an HTTPConnectionPool with the desired URL, you can then specify fields to send to the server and retrieve a response. It's that simple!
Version 0.2: N/A