Closed kyusu closed 6 years ago
Hi @smollweide,
you're welcome. Credit has to go to @dypsilon for finding the bug in the first place. And thanks again for implementing node-mock-server. Despite the two little bugs I really like it.
Regards, Christian
@kyusu thank you for creating the pull request! Regards, Tim
Hi @smollweide,
sorry, but it's me again. So my colleagues had some fun with another interesting and very subtle bug today. After they added a custom header to the response one of our mocked paths they noticed that this custom headers is now suddenly appearing on all other responses as well. After some digging around they found the issue: In line 177 of the
_handleMockRequest
method ofMockController.js
there is the following expression:So far not a problem. But in line 211 of the very same method there is the following expression:
Since
headers
is only a reference tothis.options.headers
the custom response headers for this particular response are actually copied to the global headers object (via theextend
call).Our solution was to clone the global headers object via
Best regards, Christian