Skip to content

Commit

Permalink
Allow lowercase method names in requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
brianloveswords committed Apr 11, 2012
1 parent e3d2f1b commit 1ae82f3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/scope.js
Expand Up @@ -119,7 +119,7 @@ function startScope(basePath, options) {
return false;
}

var matchKey = method + ' ' + proto + '://' + options.host;
var matchKey = method.toUpperCase() + ' ' + proto + '://' + options.host;
if (
options.port && options.host.indexOf(':') < 0 &&
(options.port !== 80 || options.proto !== 'http') &&
Expand Down
31 changes: 31 additions & 0 deletions tests/test_intercept.js
Expand Up @@ -107,6 +107,37 @@ tap.test("post", function(t) {
req.end();
});

tap.test("post, lowercase", function(t) {
var dataCalled = false;

var scope = nock('http://www.google.com')
.post('/form')
.reply(201, "OK!");

var req = http.request({
host: "www.google.com"
, method: 'post'
, path: '/form'
, port: 80
}, function(res) {

t.equal(res.statusCode, 201);
res.on('end', function() {
t.ok(dataCalled);
scope.done();
t.end();
});
res.on('data', function(data) {
dataCalled = true;
t.ok(data instanceof Buffer, "data should be buffer");
t.equal(data.toString(), "OK!", "response should match");
});

});

req.end();
});

tap.test("get with reply callback", function(t) {
var scope = nock('http://www.google.com')
.get('/')
Expand Down

0 comments on commit 1ae82f3

Please sign in to comment.