Commit 7c21aaf4 7c21aaf43efb6d6674e0bc3a8100ff759d7cb770 by Nicolas Perriault

Merge pull request #452 from EndangeredMassa/endangeredmassa/method-casing

allow uppercase http methods
2 parents 80f55a14 57f8ed97
......@@ -1357,7 +1357,7 @@ Casper.prototype.open = function open(location, settings) {
// http method
// taken from https://github.com/ariya/phantomjs/blob/master/src/webpage.cpp#L302
var methods = ["get", "head", "put", "post", "delete"];
if (settings.method && (!utils.isString(settings.method) || methods.indexOf(settings.method) === -1)) {
if (settings.method && (!utils.isString(settings.method) || methods.indexOf(settings.method.toLowerCase()) === -1)) {
throw new CasperError("open(): settings.method must be part of " + methods.join(', '));
}
// http data
......
......@@ -32,6 +32,25 @@ casper.test.begin('open() GET tests', 2, {
}
});
casper.test.begin('open() GET casing tests', 2, {
setUp: setUp,
tearDown: tearDown,
test: function(test) {
casper.open('tests/site/index.html', {
method: 'GET'
}).then(function() {
test.pass("Casper.open() can open and load a location using GET");
test.assertEquals(usedSettings, {
method: "GET"
}, "Casper.open() used the expected GET settings");
});
casper.run(function() {
test.done();
});
}
});
casper.test.begin('open() POST tests', 2, {
setUp: setUp,
tearDown: tearDown,
......@@ -56,6 +75,30 @@ casper.test.begin('open() POST tests', 2, {
}
});
casper.test.begin('open() POST casing tests', 2, {
setUp: setUp,
tearDown: tearDown,
test: function(test) {
casper.open('tests/site/index.html', {
method: 'POST',
data: {
plop: 42,
chuck: 'norris'
}
}).then(function() {
test.pass("Casper.open() can open and load a location using POST");
test.assertEquals(usedSettings, {
method: "POST",
data: "plop=42&chuck=norris"
}, "Casper.open() used the expected POST settings");
});
casper.run(function() {
test.done();
});
}
});
casper.test.begin('open() PUT tests', 2, {
setUp: setUp,
tearDown: tearDown,
......@@ -80,6 +123,30 @@ casper.test.begin('open() PUT tests', 2, {
}
});
casper.test.begin('open() PUT casing tests', 2, {
setUp: setUp,
tearDown: tearDown,
test: function(test) {
casper.thenOpen('tests/site/index.html', {
method: 'PUT',
data: {
plop: 42,
chuck: 'norris'
}
}).then(function() {
test.pass("Casper.open() can open and load a location using PUT");
test.assertEquals(usedSettings, {
method: "PUT",
data: "plop=42&chuck=norris"
}, "Casper.open() used the expected PUT settings");
});
casper.run(function() {
test.done();
});
}
});
casper.test.begin('open() PUT tests', 2, {
setUp: setUp,
tearDown: tearDown,
......