Revision 6837f014 snf-astakos-client/astakosclient/utils.py
b/snf-astakos-client/astakosclient/utils.py | ||
---|---|---|
31 | 31 |
# interpreted as representing official policies, either expressed |
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
|
34 |
import httplib |
|
34 |
from httplib import HTTPConnection, HTTPSConnection |
|
35 |
from contextlib import closing |
|
35 | 36 |
|
36 |
import objpool.http
|
|
37 |
from objpool.http import PooledHTTPConnection
|
|
37 | 38 |
from astakosclient.errors import AstakosClientException |
38 | 39 |
|
39 | 40 |
|
... | ... | |
59 | 60 |
def scheme_to_class(scheme, use_pool, pool_size): |
60 | 61 |
"""Return the appropriate conn class for given scheme""" |
61 | 62 |
def _objpool(netloc): |
62 |
return objpool.http.get_http_connection(
|
|
63 |
return PooledHTTPConnection(
|
|
63 | 64 |
netloc=netloc, scheme=scheme, pool_size=pool_size) |
64 | 65 |
|
66 |
def _http_connection(netloc): |
|
67 |
return closing(HTTPConnection(netloc)) |
|
68 |
|
|
69 |
def _https_connection(netloc): |
|
70 |
return closing(HTTPSConnection(netloc)) |
|
71 |
|
|
65 | 72 |
if scheme == "http": |
66 | 73 |
if use_pool: |
67 | 74 |
return _objpool |
68 | 75 |
else: |
69 |
return httplib.HTTPConnection
|
|
76 |
return _http_connection
|
|
70 | 77 |
elif scheme == "https": |
71 | 78 |
if use_pool: |
72 | 79 |
return _objpool |
73 | 80 |
else: |
74 |
return httplib.HTTPSConnection
|
|
81 |
return _https_connection
|
|
75 | 82 |
else: |
76 | 83 |
return None |
Also available in: Unified diff