diff options
| author | jason | 2009-12-18 12:07:58 -0700 |
|---|---|---|
| committer | jason | 2009-12-18 12:07:58 -0700 |
| commit | f5f678a8cd51d434c55efdaecaaddf2b32f25bb1 (patch) | |
| tree | 0ceef9dc30e538a3ad8fffcd7833ff1b6a127aa6 | |
| parent | f8c6036648d91abe1c3d07256c2690e56fdff8cd (diff) | |
| download | amazons3-py-f5f678a8cd51d434c55efdaecaaddf2b32f25bb1.tar.gz amazons3-py-f5f678a8cd51d434c55efdaecaaddf2b32f25bb1.zip | |
Fixed the sha warning
| -rw-r--r-- | S3.py | 12 |
1 files changed, 7 insertions, 5 deletions
| @@ -13,7 +13,7 @@ import base64 | |||
| 13 | import hmac | 13 | import hmac |
| 14 | import httplib | 14 | import httplib |
| 15 | import re | 15 | import re |
| 16 | import sha | 16 | from hashlib import sha1 |
| 17 | import sys | 17 | import sys |
| 18 | import time | 18 | import time |
| 19 | import urllib | 19 | import urllib |
| @@ -81,7 +81,7 @@ def canonical_string(method, bucket="", key="", query_args={}, headers={}, expir | |||
| 81 | # computes the base64'ed hmac-sha hash of the canonical string and the secret | 81 | # computes the base64'ed hmac-sha hash of the canonical string and the secret |
| 82 | # access key, optionally urlencoding the result | 82 | # access key, optionally urlencoding the result |
| 83 | def encode(aws_secret_access_key, str, urlencode=False): | 83 | def encode(aws_secret_access_key, str, urlencode=False): |
| 84 | b64_hmac = base64.encodestring(hmac.new(aws_secret_access_key, str, sha).digest()).strip() | 84 | b64_hmac = base64.encodestring(hmac.new(aws_secret_access_key, str, sha1).digest()).strip() |
| 85 | if urlencode: | 85 | if urlencode: |
| 86 | return urllib.quote_plus(b64_hmac) | 86 | return urllib.quote_plus(b64_hmac) |
| 87 | else: | 87 | else: |
| @@ -268,7 +268,7 @@ class AWSAuthConnection: | |||
| 268 | else: | 268 | else: |
| 269 | connection = httplib.HTTPConnection(host) | 269 | connection = httplib.HTTPConnection(host) |
| 270 | 270 | ||
| 271 | final_headers = merge_meta(headers, metadata); | 271 | final_headers = merge_meta(headers, metadata) |
| 272 | # add auth header | 272 | # add auth header |
| 273 | self._add_aws_auth_header(final_headers, method, bucket, key, query_args) | 273 | self._add_aws_auth_header(final_headers, method, bucket, key, query_args) |
| 274 | 274 | ||
| @@ -284,10 +284,12 @@ class AWSAuthConnection: | |||
| 284 | resp.read() | 284 | resp.read() |
| 285 | scheme, host, path, params, query, fragment \ | 285 | scheme, host, path, params, query, fragment \ |
| 286 | = urlparse.urlparse(location) | 286 | = urlparse.urlparse(location) |
| 287 | if scheme == "http": is_secure = True | 287 | if scheme == "http": |
| 288 | is_secure = True | ||
| 288 | elif scheme == "https": is_secure = False | 289 | elif scheme == "https": is_secure = False |
| 289 | else: raise invalidURL("Not http/https: " + location) | 290 | else: raise invalidURL("Not http/https: " + location) |
| 290 | if query: path += "?" + query | 291 | if query: |
| 292 | path += "?" + query | ||
| 291 | # retry with redirect | 293 | # retry with redirect |
| 292 | 294 | ||
| 293 | def _add_aws_auth_header(self, headers, method, bucket, key, query_args): | 295 | def _add_aws_auth_header(self, headers, method, bucket, key, query_args): |