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
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)
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
from StringIO import StringIO
from hashlib import new as newhasher
from binascii import hexlify
+
import json
import unittest
import time as _time
self.client.publish_object('c', 'o')
meta = self.client.retrieve_object_metadata('c', 'o')
self.assertTrue('x-object-public' in meta)
- url = '/public/%s/c/o' % get_user()
- self.assertEqual(meta['x-object-public'], url)
+ url = meta['x-object-public']
public_client = Pithos_Client(get_server(), get_auth(), get_user(), api='')
data = public_client.get(url)[2]
self.assertEqual(o_data, data)