MCPcopy Create free account
hub / github.com/aws/aws-cli / _convert_header_value

Method _convert_header_value

awscli/botocore/serialize.py:949–982  ·  view source on GitHub ↗
(self, shape, value)

Source from the content-addressed store, hash-verified

947 raise NotImplementedError('_serialize_body_params')
948
949 def _convert_header_value(self, shape, value):
950 if shape.type_name == 'timestamp':
951 datetime_obj = parse_to_aware_datetime(value)
952 timestamp = calendar.timegm(datetime_obj.utctimetuple())
953 timestamp_format = shape.serialization.get(
954 'timestampFormat', self.HEADER_TIMESTAMP_FORMAT
955 )
956 return str(
957 self._convert_timestamp_to_str(timestamp, timestamp_format)
958 )
959 elif shape.type_name == 'list':
960 if shape.member.type_name == "string":
961 converted_value = [
962 self._escape_header_list_string(v)
963 for v in value
964 if v is not None
965 ]
966 else:
967 converted_value = [
968 self._convert_header_value(shape.member, v)
969 for v in value
970 if v is not None
971 ]
972 return ",".join(converted_value)
973 elif is_json_value_header(shape):
974 # Serialize with no spaces after separators to save space in
975 # the header.
976 return self._get_base64(json.dumps(value, separators=(',', ':')))
977 elif shape.type_name == 'boolean':
978 return str(value).lower()
979 elif shape.type_name in ['float', 'double']:
980 return str(self._handle_float(value))
981 else:
982 return str(value)
983
984 def _escape_header_list_string(self, value):
985 # Escapes a header list string by wrapping it in double quotes if it contains

Callers 1

_partition_parametersMethod · 0.95

Calls 6

parse_to_aware_datetimeFunction · 0.90
is_json_value_headerFunction · 0.90
_get_base64Method · 0.80
_handle_floatMethod · 0.45

Tested by

no test coverage detected