diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 727c516..7f1d90d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,13 @@ The following is a summary of changes and improvements to .. New features in each version should be listed, with any necessary information about installation or upgrade notes. +1.8 (prelim) +------------ + +* Fix UTF-8 issue introduced in 1.5 (see discussion on + `PR #21 `_) +* Updated for compatibility with requests 2.11 + 1.7.1 ----- @@ -74,6 +81,7 @@ The following is a summary of changes and improvements to and better handling for large objects. * Upload API method (:meth:`eulfedoa.api.REST_API.upload`) now supports iterable content with known size. +* Updated to require requests 2.9 or greater. 1.4 --- diff --git a/eulfedora/api.py b/eulfedora/api.py index 29e096d..f665e40 100644 --- a/eulfedora/api.py +++ b/eulfedora/api.py @@ -84,11 +84,12 @@ def __init__(self, base_url, username=None, password=None, retries=None): # NOTE: only headers that will be common for *all* requests # to this fedora should be set in the session # (i.e., do NOT include auth information here) + + # NOTE: ssl verification is turned on by default + self.session.headers = { + # use requests-toolbelt user agent 'User-Agent': user_agent('eulfedora', eulfedora_version), - # 'user-agent': 'eulfedora/%s (python-requests/%s)' % \ - # (eulfedora_version, requests.__version__), - 'verify': True, # verify SSL certs by default } # no retries is requests current default behavior, so only # customize if a value is set @@ -865,7 +866,11 @@ def upload(self, data, callback=None, content_type=None, menc = MultipartEncoderMonitor(menc, callback) headers = {'Content-Type': menc.content_type} + if size: + # latest version of requests requires str or bytes, not int + if not isinstance(size, six.string_types): + size = str(size) headers['Content-Length'] = size try: diff --git a/test/test_fedora/test_api.py b/test/test_fedora/test_api.py index 7fa7dd0..aa24fbf 100644 --- a/test/test_fedora/test_api.py +++ b/test/test_fedora/test_api.py @@ -836,7 +836,8 @@ def data_generator(): content_md5 = md5sum(text_content) size = len(text_content) - upload_id = self.rest_api.upload(data_generator(), size=size, content_type='text/plain') + upload_id = self.rest_api.upload(data_generator(), size=size, + content_type='text/plain') pattern = re.compile('uploaded://[0-9]+') self.assertTrue(pattern.match(upload_id))