Revision 9a7efb0d kamaki/clients/__init__.py
b/kamaki/clients/__init__.py | ||
---|---|---|
80 | 80 |
def set_default_header(self, name, value): |
81 | 81 |
self.http_client.headers.setdefault(name, value) |
82 | 82 |
|
83 |
def request(self, method, path, **kwargs): |
|
83 |
def request(self, method, path, async_headers={}, async_params={}, **kwargs): |
|
84 |
"""In threaded/asynchronous requests, headers and params are not safe |
|
85 |
Therefore, the standard self.set_header/param system can be used only for |
|
86 |
headers and params that are common for all requests. All other params and |
|
87 |
headers should passes as |
|
88 |
@param async_headers |
|
89 |
@async_params |
|
90 |
E.g. in most queries the 'X-Auth-Token' header might be the same for all, but the |
|
91 |
'Range' header might be different from request to request. |
|
92 |
""" |
|
84 | 93 |
try: |
85 | 94 |
success = kwargs.pop('success', 200) |
86 | 95 |
|
87 |
binary = kwargs.pop('binary', False) |
|
88 | 96 |
data = kwargs.pop('data', None) |
89 | 97 |
self.set_default_header('X-Auth-Token', self.token) |
90 | 98 |
|
... | ... | |
95 | 103 |
self.set_default_header('Content-Length', unicode(len(data))) |
96 | 104 |
|
97 | 105 |
self.http_client.url = self.base_url + path |
98 |
r = self.http_client.perform_request(method=method, data=data)
|
|
106 |
r = self.http_client.perform_request(method, data, async_headers, async_params)
|
|
99 | 107 |
|
100 | 108 |
req = self.http_client |
101 | 109 |
sendlog.info('%s %s', method, req.url) |
... | ... | |
108 | 116 |
recvlog.info('%d %s', r.status_code, r.status) |
109 | 117 |
for key, val in r.headers.items(): |
110 | 118 |
recvlog.info('%s: %s', key, val) |
111 |
recvlog.info('') |
|
112 |
if r.content: |
|
113 |
recvlog.debug(r.content) |
|
119 |
#if r.content: |
|
120 |
# recvlog.debug(r.content) |
|
114 | 121 |
|
115 | 122 |
if success is not None: |
116 | 123 |
# Success can either be an in or a collection |
Also available in: Unified diff