本文整理匯總了Python中botocore.compat.ensure_unicode方法的典型用法代碼示例。如果您正苦於以下問題:Python compat.ensure_unicode方法的具體用法?Python compat.ensure_unicode怎麽用?Python compat.ensure_unicode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類botocore.compat
的用法示例。
在下文中一共展示了compat.ensure_unicode方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _get_user_agent
# 需要導入模塊: from botocore import compat [as 別名]
# 或者: from botocore.compat import ensure_unicode [as 別名]
def _get_user_agent(self, request_headers):
return self._truncate(
ensure_unicode(request_headers.get('User-Agent', '')),
self._MAX_USER_AGENT_LENGTH
)
示例2: _get_auth_value
# 需要導入模塊: from botocore import compat [as 別名]
# 或者: from botocore.compat import ensure_unicode [as 別名]
def _get_auth_value(self, request_headers):
return ensure_unicode(request_headers['Authorization'])
示例3: canonical_headers
# 需要導入模塊: from botocore import compat [as 別名]
# 或者: from botocore.compat import ensure_unicode [as 別名]
def canonical_headers(self, headers_to_sign):
"""
Return the headers that need to be included in the StringToSign
in their canonical form by converting all header keys to lower
case, sorting them in alphabetical order and then joining
them into a string, separated by newlines.
"""
headers = []
sorted_header_names = sorted(set(headers_to_sign))
for key in sorted_header_names:
value = ','.join(self._header_value(v) for v in
sorted(headers_to_sign.get_all(key)))
headers.append('%s:%s' % (key, ensure_unicode(value)))
return '\n'.join(headers)
示例4: _serialize_request_headers
# 需要導入模塊: from botocore import compat [as 別名]
# 或者: from botocore.compat import ensure_unicode [as 別名]
def _serialize_request_headers(self, request_headers, event_dict,
**kwargs):
if 'User-Agent' in request_headers:
event_dict['UserAgent'] = self._truncate(
ensure_unicode(request_headers['User-Agent']),
self._MAX_USER_AGENT_LENGTH
)
if self._is_signed(request_headers):
event_dict['AccessKey'] = self._get_access_key(request_headers)
region = self._get_region(request_headers)
if region is not None:
event_dict['Region'] = region
if 'X-Amz-Security-Token' in request_headers:
event_dict['SessionToken'] = request_headers[
'X-Amz-Security-Token']