reqheaders ignored
See original GitHub issueJust hit my head against my monitor for a few minutes on this one… the documented way to match headers seems to have no effect. Whether my request has a header or not, it is matched by this:
nock('http://www.example.com', {
reqheaders: {
'authorization': 'Bearer TOKEN'
}
})
.get('/users/52')
.query(true)
.reply(200);
But this (which I only found by digging into historical issues) works as I would expect, failing to match when the header is not provided
nock('http://www.example.com')
.matchHeader('authorization', 'Bearer TOKEN')
.get('/users/52')
.query(true)
.reply(200)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:22 (7 by maintainers)
Top Results From Across the Web
How to ignore headers when running a mocked request with ...
Aaccording to the docs, if reqHeaders is not specified, it will skip them. If no request headers are specified for mocking then Nock...
Read more >Trying to use custom HTTP Request headers is ignored ... - IBM
Trying to use custom HTTP Request headers is ignored for some header Types in HTTP Client Adapter.
Read more >HTTP | Node.js v19.3.0 Documentation
Ignored when the keepAlive option is false or undefined . Default: 1000 . maxSockets <number> Maximum number of sockets to allow per host....
Read more >next.config.js: Custom Headers
Headers allow you to set custom HTTP headers on the response to an incoming request on a given path. To set custom HTTP...
Read more >1138137 – Undefined req.headers.host when using SSL on ...
Moreover, it uses req.path which will ignore query parameters. I have noticed that node.js applications created from Openshift use an old ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m not sure if it is due to SuperAgent, but that wouldn’t surprise me. Although the strange thing is that the headers are sent. Let me investigate a bit more tonight, I might be missing something.
Here you go https://runkit.com/callaars/nock-748