summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTax <paultax@gmail.com>2012-10-02 13:25:47 +0200
committerTax <paultax@gmail.com>2012-10-02 13:25:47 +0200
commit1ff9b0bd70626d0131eed530b723ac269dd99f5d (patch)
treecd797299890fc3247eea78d888f688159a7bebae
parent73415743f77e499077c725016931de0d0a00933a (diff)
downloadpython-requests-aws-1ff9b0bd70626d0131eed530b723ac269dd99f5d.tar.gz
A little shorter
Testing travis again
-rw-r--r--awsauth.py13
-rw-r--r--test.py5
2 files changed, 4 insertions, 14 deletions
diff --git a/awsauth.py b/awsauth.py
index 8ab5e5f..3d69bfc 100644
--- a/awsauth.py
+++ b/awsauth.py
@@ -54,21 +54,13 @@ class S3Auth(AuthBase):
# remove last dot
bucket = bucket[:-1]
- interesting_headers = {}
- ok_keys = ['content-md5', 'content-type', 'date']
+ interesting_headers = {'content-md5':'', 'content-type':'', 'date':''}
for key in headers:
lk = key.lower()
- if headers[key] is not None and (lk in ok_keys or lk.startswith('x-amz-')):
+ if headers[key] and (lk in interesting_headers.keys() or lk.startswith('x-amz-')):
interesting_headers[lk] = headers[key].strip()
- # these keys get empty strings if they don't exist
- if not interesting_headers.has_key('content-type'):
- interesting_headers['content-type'] = ''
-
- if not interesting_headers.has_key('content-md5'):
- interesting_headers['content-md5'] = ''
-
# If x-amz-date is used it supersedes the date header.
if interesting_headers.has_key('x-amz-date'):
interesting_headers['date'] = ''
@@ -76,7 +68,6 @@ class S3Auth(AuthBase):
buf = '%s\n' % method
for key in sorted(interesting_headers.keys()):
val = interesting_headers[key]
-
if key.startswith('x-amz-'):
buf += '%s:%s\n' % (key, val)
else:
diff --git a/test.py b/test.py
index f4c5a9f..8569bd9 100644
--- a/test.py
+++ b/test.py
@@ -15,7 +15,6 @@ if 'AWS_SECRET_KEY' in os.environ:
class TestAWS(unittest.TestCase):
def setUp(self):
print os.environ
- print ACCESS_KEY[:3], SECRET_KEY[:3]
self.auth=S3Auth(ACCESS_KEY, SECRET_KEY)
def test_put_get_delete(self):
@@ -28,8 +27,8 @@ class TestAWS(unittest.TestCase):
self.assertEqual(r.content, 'Sam is sweet')
# Removing a file
r = requests.delete('http://'+ TEST_BUCKET + '.s3.amazonaws.com/myfile.txt', auth=self.auth)
- self.assertEqual(r.status_code, 204)
-
+ self.assertEqual(r.status_code, 204)
+
def test_put_get_delete_filnamehasplus(self):
testdata = 'Sam is sweet'
filename = 'my+file.txt'