fix: changed content-type to a valid attribute

Signed-off-by: vivjd <vivjdeng@hotmail.com>
This commit is contained in:
vivjd 2024-01-06 12:45:25 -05:00
parent 21572afb57
commit 86437b9d2d
1 changed files with 5 additions and 5 deletions

View File

@ -87,10 +87,10 @@ def to_binary(
) )
headers = {} headers = {}
if event["content-type"]: if event["datacontenttype"]:
headers["content-type"] = event["content-type"].encode("utf-8") headers["datacontenttype"] = event["datacontenttype"].encode("utf-8")
for attr, value in event.get_attributes().items(): for attr, value in event.get_attributes().items():
if attr not in ["data", "partitionkey", "content-type"]: if attr not in ["data", "partitionkey", "datacontenttype"]:
if value is not None: if value is not None:
headers["ce_{0}".format(attr)] = value.encode("utf-8") headers["ce_{0}".format(attr)] = value.encode("utf-8")
@ -189,8 +189,8 @@ def to_structured(
attrs["data"] = data attrs["data"] = data
headers = {} headers = {}
if "content-type" in attrs: if "datacontenttype" in attrs:
headers["content-type"] = attrs.pop("content-type").encode("utf-8") headers["datacontenttype"] = attrs.pop("datacontenttype").encode("utf-8")
try: try:
value = envelope_marshaller(attrs) value = envelope_marshaller(attrs)