from sys import stdin
from xml.dom import minidom
from StringIO import StringIO
-from urllib import quote
+from urllib import quote, unquote
import json
import types
slash = '/' if self.api else ''
full_path = '%s%s%s?format=%s' % (slash, self.api, quote(path), format)
- for k,v in params.items:
+ for k,v in params.items():
if v:
- full_path = '%s&%s=%s' %(full_path, quote(k), quote(unicode(v)))
+ full_path = '%s&%s=%s' %(full_path, quote(k), quote(str(v)))
else:
full_path = '%s&%s=' %(full_path, k)
conn = HTTPConnection(self.host)
for k,v in headers.items():
headers.pop(k)
k = k.replace('_', '-')
- headers[k] = v
+ headers[k] = quote(v, safe='/=,:@ *"') if type(v) == types.StringType else v
kwargs['headers'] = headers
kwargs['headers']['X-Auth-Token'] = self.token
resp = conn.getresponse()
t2 = datetime.datetime.utcnow()
#print 'response time:', str(t2-t1)
- headers = dict(resp.getheaders())
+ headers = resp.getheaders()
+ headers = dict((unquote(h), unquote(v)) for h,v in headers)
if self.verbose:
print '%d %s' % (resp.status, resp.reason)
args = locals().copy()
for elem in ['self', 'container', 'object']:
args.pop(elem)
- data = self.retrieve_object(container, object, format='json', **args)
- return data['hashes']
+ return self.retrieve_object(container, object, format='json', **args)
def create_directory_marker(self, container, object, account=None):
"""creates a dierectory marker"""
action = 'read' if read else 'write'
sharing = '%s=%s' % (action, ','.join(l))
self.update_object(container, object, f=None, x_object_sharing=sharing)
-
-def _encode_headers(headers):
- h = {}
- for k, v in headers.items():
- k = urllib.quote(k)
- if v and type(v) == types.StringType:
- v = urllib.quote(v, '/=,-* :"')
- h[k] = v
- return h