Skip to content

Commit

Permalink
Merge pull request #2 from SkyLothar/header-none-bug
Browse files Browse the repository at this point in the history
Header none bug
  • Loading branch information
SkyLothar committed Mar 28, 2015
2 parents b9682d6 + 3cc4156 commit f6db2f1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from codecs import open

__version__ = "0.1.0"
__version__ = "0.1.2"
__author__ = "SkyLothar"
__email__ = "allothar@gmail.com"
__url__ = "http://github.com/skylothar/requests-ucloud"
Expand Down
2 changes: 1 addition & 1 deletion tests/test-ufile.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_headers_empty_md5(self):
"public-key", "private-key", allow_empty_md5=True
)
empty_md5_req = empty_md5_auth.fill_all_headers(request)
eq_(empty_md5_req.headers["Content-Md5"], None)
eq_(empty_md5_req.headers.get("Content-Md5"), None)

def test_header_no_md5(self):
request = self.request.prepare()
Expand Down
2 changes: 1 addition & 1 deletion ucloudauth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
This module contains the authentication handlers for UCloud Service
"""

__version__ = "0.1.0"
__version__ = "0.1.2"
__author__ = "SkyLothar"
__email__ = "allothar@gmail.com"
__url__ = "http://github.com/skylothar/requests-ucloud"
Expand Down
11 changes: 3 additions & 8 deletions ucloudauth/ufile.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def gen_str_to_sign(self, req):

str_to_sign = "\n".join([
req.method,
req.headers["content-md5"] or "",
req.headers.get("content-md5", ""),
req.headers["content-type"],
req.headers.get("date", self._expires),
canonicalized_headers + canonicalized_resource
Expand All @@ -147,15 +147,10 @@ def fill_all_headers(self, req):
logger.debug("calculating content-md5")
content, content_md5 = utils.cal_content_md5(req.body)
req.body = content
req.headers["content-md5"] = content_md5
logger.debug("new content-md5 is: {0}".format(content_md5))
else:
logger.debug("skip content-md5 calculation")
content_md5 = None
logger.debug(
"origin content-md5 is: {0}, new content-md5 is: {1}".format(
req.headers.get("content-md5"), content_md5
)
)
req.headers.setdefault("content-md5", content_md5)

if self._expires is None:
req.headers.setdefault(
Expand Down

0 comments on commit f6db2f1

Please sign in to comment.