Skip to content

to_binary() generates unnecessary headers #137

Closed

Description

@xinydev

Expected Behavior

binary_headers, binary_body = to_binary(event)

For the binary mode, ce-datacontenttype HTTP header MUST NOT be present in the message. spec

Actual Behavior

in the binary_headers above, we have both content-type and ce-datacontenttype

Steps to Reproduce the Problem

import json

from cloudevents.http import from_http, to_binary

http_request_headers = {
    "Ce-Id": "dd5d82d7-eb8a-4ff8-8a57-514511192b7f",
    "Ce-Source": "source",
    "Ce-Specversion": '1.0',
    "Ce-Type": "http",
    "Content-Type": 'application/json;charset=UTF-8'
}

event = from_http(http_request_headers, json.dumps({}))
print(event)

binary_headers, binary_body = to_binary(event)
print(binary_headers)
print(binary_body )

output

{'attributes': {'specversion': '1.0', 'id': 'dd5d82d7-eb8a-4ff8-8a57-514511192b7f', 'source': 'source', 'type': 'http', 'datacontenttype': 'application/json;charset=UTF-8', 'time': '2021-05-26T02:22:05.769574+00:00'}, 'data': {}}

{'content-type': 'application/json;charset=UTF-8', 'ce-specversion': '1.0', 'ce-id': 'dd5d82d7-eb8a-4ff8-8a57-514511192b7f', 'ce-source': 'source', 'ce-type': 'http', 'ce-datacontenttype': 'application/json;charset=UTF-8', 'ce-time': '2021-05-26T02:22:05.769574+00:00'}

b'{}'

binary_headers has both ce-datacontenttype and content-type body

Specifications

  • Platform: Ubuntu 20.04
  • Python Version: 3.8.5
  • CloudEvent Sdk: 1.2.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions