Skip to content

Passing custom headers through to http.request() #223

Closed

Description

@c-pius

When using HttpEmitter.send() method, how can I pass additional header arguments (e.g. meant for our infrastructure) that are passed through to the http.request() call?

I tried to use

const emitter = new HTTPEmitter({
    url: "https://foo.bar"
})

const event = ...

emitter.send(event, {
  headers: {
    customheader: "...",
    authorization: "Bearer ...."
  }
})

When debugging, it seemed like the passed headers are overwritten by the default headers.

const config = { ...options, ...defaults };

translated to

const config = Object.assign(Object.assign({}, options), defaults);

Activity

  1. added
    type/bugSomething isn't working
    and removed on Jun 15, 2020
  2. lance commented on Jun 15, 2020

    @lance
    Member

    @c-pius it looks like the spread operator assignment is a bug. Thanks for reporting this.

  3. lholmquist commented on Jun 15, 2020

    @lholmquist
    Contributor

    I wonder if there are other places that are like this?

  4. lholmquist commented on Jun 15, 2020

    @lholmquist
    Contributor

    To answer my own question. It looks like that is the only spot that the ordering was incorrect

  5. added a commit that references this issue on Jun 15, 2020
    5562a32
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

    type/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions