Skip to content

Commit

Permalink
Adding and modifying test to ensure query string in non GET method. i…
Browse files Browse the repository at this point in the history
…nParams is ambiguious whether it should be used as body or query with POST/PUT like methods. I recommend letting inParams translate as query string, and enforce postBody use to send like data
  • Loading branch information
nicolas-rempulski committed Nov 13, 2012
1 parent d9c0d70 commit 5b878f0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
9 changes: 7 additions & 2 deletions tools/test/ajax/php/test2.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@ function get() {
function post() {
$q = @$_POST['query'];
if ($q) {
$result = array('response' => $q);
$result = array('response' => "post.".$q);
} else {
$result = array('response' => file_get_contents('php://input'));
$q = @$_GET['query'];
if ($q) {
$result = array('response' => "query.".$q);
}else{
$result = array('response' => file_get_contents('php://input'));
}
}
$requested_with = @$_SERVER['HTTP_X_REQUESTED_WITH'];
if ($requested_with == 'XMLHttpRequest') {
Expand Down
20 changes: 15 additions & 5 deletions tools/test/ajax/tests/AjaxTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,21 @@ enyo.kind({
return inValue == "hello";
});
},
testPostRequest: function() {
this._testAjax({url: "php/test2.php", method: "POST"}, {query: "enyo"}, function(inValue) {
return inValue.response == "enyo";
});
},
testPostRequestQuery: function() {
this._testAjax({url: "php/test2.php", method: "POST"}, {query: "enyo"}, function(inValue) {
return inValue.response == "query.enyo";
});
},
testPostRequestQueryWithPayload: function() {
this._testAjax({url: "php/test2.php", method: "POST", postBody:"data"}, {query: "enyo"}, function(inValue) {
return inValue.response == "query.enyo";
});
},
testPostRequestPayload: function() {
this._testAjax({url: "php/test2.php", method: "POST", postBody:"query=enyo"}, null, function(inValue) {
return inValue.response == "post.enyo";
});
},
testPutRequest: function() {
this._testAjax({url: "php/test2.php", method: "PUT"}, null, function(inValue) {
return inValue.status == "put";
Expand Down

0 comments on commit 5b878f0

Please sign in to comment.