laurentj / slimerjs

A scriptable browser like PhantomJS, based on Firefox
http://slimerjs.org
Other
3k stars 259 forks source link

PUT request are send as POST #70

Open damienalexandre opened 11 years ago

damienalexandre commented 11 years ago

I use SlimerJS inside CasperJS for tests, both as an HTTP Client for API's and a browser for webpages.

When trying to run a PUT HTTP request, but the server receive a POST, here is a script to test it:

casperjs test --engine=slimerjs /full/path/to/failer.js

casper.options.verbose = true;
casper.options.logLevel = 'debug';

casper.test.begin('Look at me', 2, function(test) {

    casper.start('http://httpbin.org');

    casper.thenOpen('http://httpbin.org/put', {
            method:     'put',
            data:       "Coucou"
        }, function(data) {
            require('utils').dump(data);

            test.assertHttpStatus(200);
        }
    );

    casper.run();
});

The result will be:

"statusText": "METHOD NOT ALLOWED" The method POST is not allowed for the requested URL.

With PhantomJS I get the expected result:

"statusText": "OK"

I run CasperJS version 1.1.0-DEV and SlimerJS 0.8.2.

laurentj commented 11 years ago

Unfortunately, it is not possible to indicate the method to the Mozilla API called by SlimerJS... We should patch Gecko.

laurentj commented 11 years ago

Note that Firefox nor Chrome don't support <form method="put">, so it does not make sens to open a webpage with the "put" method. Probably it's better to do your tests with xmlHttpRequest instead.

damienalexandre commented 11 years ago

Sad

Too bad :( Thank for the XmlHttpRequest idea anyway.