Skip to content

matchHeader doesn't work in Node 8.x #925

Closed

Description

@panva

matchHeader no longer functions as expected, neither when providing value as a string or a function. The culprit seems to be options.getHeader returning undefined for every header name because request._headers (v9.0.13) is not set anymore.

Activity

  1. kevinoid commented on May 31, 2017

    @kevinoid

    I'm seeing this issue as well. It looks like this is a result of nodejs/node#10941 (nodejs/node@b377034359a specifically) which made the ._headers property of OutgoingMessage return a copy of the headers object. This copy is assigned to in setHeaders, which has no lasting effect.

    Is there a reason why request.setHeader (OutgoingMessage.prototype.setHeader) isn't being called here?

  2. added a commit that references this issue on Jun 5, 2017
  3. jhuliano commented on Jun 7, 2017

    @jhuliano

    Replacing the matchHeader function with nock(host, { reqheaders: {"header":"content"} }), seems to do the trick for now.
    I'm using Nock 9.0.13 and Node 8 (on Official Docker Image)

  4. jdx commented on Jun 7, 2017

    @jdx

    that requires you to specify all the headers though, right?

  5. jhuliano commented on Jun 7, 2017

    @jhuliano

    @dickeyxxx doesn't look like it does, I don't mock all my headers and the tests are working just fine with the mentioned change.
    Also the header assertions are working as expected (tests will fail if the supplied header content doesn't match the expectation).

  6. jdx commented on Jun 7, 2017

    @jdx

    good to know! thank you!

  7. acofer commented on Jun 8, 2017

    @acofer
  8. added a commit that references this issue on Jun 16, 2017
  9. added a commit that references this issue on Jun 17, 2017
  10. shahata commented on Jul 8, 2017

    @shahata

    any plans of fixing this soon?

  11. 0xcaff commented on Jul 14, 2017

    @0xcaff

    It looks like this is fixed in the latest commit to master: 35c76e3

  12. ianwsperber commented on Jul 14, 2017

    @ianwsperber
    Contributor

    Will be released end of weekend

  13. ianwsperber commented on Jul 17, 2017

    @ianwsperber
    Contributor

    v9.0.14 out with @martinkuba's fix. Huge thanks to him for doing the work. Closing this issue. Will re-open if we get reports that issue persists.

  14. panva commented on Jul 17, 2017

    @panva
    Author

    resolved, @ianwsperber @martinkuba thanks!

  15. added a commit that references this issue on Jun 29, 2018
  16. lock commented on Sep 13, 2018

    @lock

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue and add a reference to this one if it’s related. Thank you!

  17. locked as resolved and limited conversation to collaborators on Sep 13, 2018
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