Skip to content

Commit

Permalink
ufile sign with url now calculate with no content-type
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyLothar committed Mar 28, 2015
1 parent f6db2f1 commit ce26c47
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/test-ufile.py
Expand Up @@ -35,7 +35,7 @@
AUTHORIZATION = "UCloud public-key:vex1mk5WI2fe/i5TzXm7QY19p64="
PARAMS = dict(
UCloudPublicKey="public-key",
Signature="JHrQ1u087Gv0ktLlBAyfYclnI/I=",
Signature="i85wNCWK1eotra5GWAF9WfHfjsY=",
Expires="1"
)

Expand Down
6 changes: 4 additions & 2 deletions ucloudauth/ufile.py
Expand Up @@ -123,7 +123,7 @@ def gen_str_to_sign(self, req):
str_to_sign = "\n".join([
req.method,
req.headers.get("content-md5", ""),
req.headers["content-type"],
req.headers.get("content-type", ""),
req.headers.get("date", self._expires),
canonicalized_headers + canonicalized_resource
])
Expand All @@ -137,7 +137,9 @@ def fill_all_headers(self, req):
if content_type is None:
content_type = self.DEFAULT_TYPE
logger.warn("can not determine mime-type for {0}".format(url.path))
req.headers.setdefault("content-type", content_type)
if self._expires is None:
# sign with url, no content-type for url
req.headers.setdefault("content-type", content_type)

if (
req.body is not None
Expand Down

0 comments on commit ce26c47

Please sign in to comment.