Skip to content

HTTP headers name case for extensions #566

Closed

Description

@Elvecent

It seems that HTTP.toEvent, at least in BINARY mode, looks up extensions in header names starting with "ce-" prefix, however, it looks among original headers supplied in unknown case rather than sanitized headers which are lowercase.

So e. g. "Ce-myext: val" is ignored and doesn't make it into final event's "myext" field.

Activity

  1. lholmquist commented on Sep 27, 2023

    @lholmquist
    Contributor

    I'm not following what the bug is here? do you have a reproducible example you could post?

  2. Elvecent commented on Sep 28, 2023

    @Elvecent
    Author
    $ node
    Welcome to Node.js v20.5.0.
    Type ".help" for more information.
    > const { HTTP, httpTransport } = await import('cloudevents');
    undefined
    > const headers = {"Accept":"*/*","Ce-Id":"e2a8d1cb-7ef0-4efb-a24f-608c1715b196","Ce-Myext":"val","Ce-Source":"local","Ce-Specversion":"1.0","Ce-Type":"sometype","Content-Length":"82","Content-Type":"application/json","User-Agent":"curl/7.68.0"}
    undefined
    > HTTP.toEvent({ headers, body: "body"})
    Sanitized headers: {"accept":"*/*","ce-id":"e2a8d1cb-7ef0-4efb-a24f-608c1715b196","ce-myext":"val","ce-source":"local","ce-specversion":"1.0","ce-type":"sometype","content-length":"82","content-type":"application/json","user-agent":"curl/7.68.0"}
    Leftover sanitized headers: {"accept":"*/*","ce-myext":"val","content-length":"82","user-agent":"curl/7.68.0"}
    {"id":"e2a8d1cb-7ef0-4efb-a24f-608c1715b196","time":"2023-09-28T08:25:48.053Z","type":"sometype","source":"local","specversion":"1.0","datacontenttype":"application/json","data":"body"}
    

    Here, I expect that the resulting object contains value "val" at key "myext". Logs show the value of sanitizedHeaders, and I believe this is exactly where the .startsWith(__1.CONSTANTS.EXTENSIONS_PREFIX) check should happen, but instead it happens in headers, which is the original input headers in mixed case rather than lower case. So the "ce-" prefix check fails, because the actual prefix is "Ce-", and the extension is dropped.

  3. github-actions commented on Oct 29, 2023

    @github-actions
    Contributor

    This issue is stale because it has been open 30 days with no 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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions