firebug / firebug.next

Next Firebug generation built on top of native Firefox developer tools
Other
229 stars 37 forks source link

Copy as cURL with JSON data lacks parameters in cURL #400

Closed AlexHaaniWink closed 8 years ago

AlexHaaniWink commented 9 years ago

When I do an Ajax (jQuery) request with content-type application/json and JSON data, the option 'Copy as cURL' on the POST request results in a cURL request without the data parameter. With a normal application/x-www-form-urlencoded request the data parameter is added just fine.

Fiddle: http://jsfiddle.net/s99tuemp/ Or source: (jQuery 1.7.2 required, optionally add '<div id="log"></div>' in the HTML section):

$.ajax({
    data: '{data: 1, status: true}',
    dataType: 'json',
    contentType: 'application/json',
    type: 'POST',
    url: 'http://ip.jsontest.com/',
    success: function(data, status, xhr) {
        console.log([data, status, xhr]);
        $('#log').text(JSON.stringify([data, status, xhr]));
    },
    error: function(data) {
        console.log(data);
        $('#log').text(JSON.stringify(data));
    }
});

Resulting cURL strings:

application/json: BAD

curl 'http://ip.jsontest.com/' -X POST -H 'Host: ip.jsontest.com' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate' -H 'Content-Type: application/json; charset=UTF-8' -H 'Referer: http://fiddle.jshell.net/s99tuemp/show/' -H 'Content-Length: 23' -H 'Origin: http://fiddle.jshell.net' -H 'Connection: keep-alive' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache'

application/x-www-form-urlencoded: OK

curl 'http://ip.jsontest.com/' -H 'Accept: */*' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.5' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Host: ip.jsontest.com' -H 'Origin: http://fiddle.jshell.net' -H 'Pragma: no-cache' -H 'Referer: http://fiddle.jshell.net/_display/' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0' --data 'data=1&status=true'

Chrome; application/json: OK

curl 'http://ip.jsontest.com/' -H 'Origin: http://fiddle.jshell.net' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: nl,en-US;q=0.8,en;q=0.6' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36' -H 'Content-Type: application/json' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Referer: http://fiddle.jshell.net/s99tuemp/show/' -H 'Connection: keep-alive' --data-binary '{data: 1, status: true}' --compressed

yankopetrov commented 8 years ago

I have the same problem.

janodvarko commented 8 years ago

This is platform problem and there are already some bugs reported.

https://bugzilla.mozilla.org/show_bug.cgi?id=1085481 https://bugzilla.mozilla.org/show_bug.cgi?id=1097836 https://bugzilla.mozilla.org/show_bug.cgi?id=1097908 https://bugzilla.mozilla.org/show_bug.cgi?id=1253487

Please follow these reports

Honza