Commit 25ad1e79 25ad1e791868d82a6c9e67176f8cdae085cfd336 by Sean Massa

allow uppercase http methods

1 parent 80f55a14
......@@ -1357,7 +1357,8 @@ 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)) {
var lowerCaseMethod = settings.method.toLowerCase();
if (settings.method && (!utils.isString(settings.method) || methods.indexOf(lowerCaseMethod) === -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,
......