Revision 4ab1af1a snf-pithos-app/pithos/api/delegate.py
b/snf-pithos-app/pithos/api/delegate.py | ||
---|---|---|
46 | 46 |
from pithos.api.settings import ( |
47 | 47 |
AUTHENTICATION_USERS, USER_LOGIN_URL, USER_FEEDBACK_URL, USER_CATALOG_URL) |
48 | 48 |
|
49 |
from synnefo.lib.pool.http import get_http_connection
|
|
49 |
from synnefo.lib.pool.http import PooledHTTPConnection
|
|
50 | 50 |
|
51 | 51 |
logger = logging.getLogger(__name__) |
52 | 52 |
|
... | ... | |
79 | 79 |
kwargs['headers'].setdefault('content-type', 'application/json') |
80 | 80 |
kwargs['headers'].setdefault('content-length', len(body) if body else 0) |
81 | 81 |
|
82 |
conn = get_http_connection(p.netloc, p.scheme) |
|
83 |
try: |
|
82 |
with PooledHTTPConnection(p.netloc, p.scheme) as conn: |
|
84 | 83 |
conn.request(request.method, p.path + '?' + p.query, **kwargs) |
85 | 84 |
response = conn.getresponse() |
86 | 85 |
length = response.getheader('content-length', None) |
87 | 86 |
data = response.read(length) |
88 | 87 |
status = int(response.status) |
89 | 88 |
return HttpResponse(data, status=status) |
90 |
finally: |
|
91 |
conn.close() |
|
92 | 89 |
|
93 | 90 |
@csrf_exempt |
94 | 91 |
def delegate_to_feedback_service(request): |
Also available in: Unified diff