Repository: node-nock/nock (js)

Issue:
`content-length: 0` is not matched correctly
The problem is this line

https://github.com/node-nock/nock/blob/8c7cf84a42a77ef4066bfd89208357493b9fb59c/lib/interceptor.js#L166

We check above if either `reqHeader` or `header` is undefined so we don’t need the `if (reqHeader && header) {` anymore. As both `reqHeader` and `header` are `0` the condition will not be fulfilled and the `reqheaderMatches` method returns false, although the values are exactly the same.

I’ll add a pull request with a test case to resolve it

Pull request description:
match headers with falsy values
closes #966

Patch:
diff --git a/lib/interceptor.js b/lib/interceptor.js
index 5de6e2e..426263f 100755
--- a/lib/interceptor.js
+++ b/lib/interceptor.js
@@ -163,7 +163,7 @@ Interceptor.prototype.reqheaderMatches = function reqheaderMatches(options, key)
         return true;
     }
 
-    if (reqHeader && header) {
+    if (!_.isUndefined(reqHeader) && !_.isUndefined(header)) {
         if (_.isFunction(reqHeader)) {
             return reqHeader(header);
         } else if (common.matchStringOrRegexp(header, reqHeader)) {


Test patch:
diff --git a/tests/test_intercept.js b/tests/test_intercept.js
index 20113fa..9866eac 100755
--- a/tests/test_intercept.js
+++ b/tests/test_intercept.js
@@ -4129,6 +4129,29 @@ test('mocking succeeds even when mocked and specified request header names have
 
 });
 
+test('mocking succeeds when mocked and specified request headers have falsy values (#966)', function(t) {
+  var scope = nock('http://example.com', {
+    reqheaders: {
+      "x-foo": 0
+    }
+  })
+    .post('/resource')
+    .reply(200, { status: "ok" });
+
+  mikealRequest({
+    method: 'POST',
+    uri: 'http://example.com/resource',
+    headers: {
+      "X-Foo": 0
+    }
+  }, function(err, res, body) {
+    t.error(err);
+    t.equal(res.statusCode, 200);
+    t.end();
+  });
+
+});
+
 test('mocking succeeds even when host request header is not specified', function(t) {
   var scope = nock('http://example.com')
     .post('/resource')