This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit e24edc0cb9cc21ee243d3cfc81114c95a96736ea Author: Yannick Martel <martel@©odelutin.com> Date: Thu Jan 15 18:09:26 2015 +0100 review data encoding with POST method --- coselmar-ui/src/main/webapp/index.html | 2 ++ .../src/main/webapp/js/coselmar-questions-services.js | 14 ++++---------- coselmar-ui/src/main/webapp/js/coselmar-services.js | 8 ++++---- coselmar-ui/src/main/webapp/js/coselmar-user-services.js | 13 ++++--------- coselmar-ui/src/main/webapp/js/coselmar.js | 3 +++ 5 files changed, 17 insertions(+), 23 deletions(-) diff --git a/coselmar-ui/src/main/webapp/index.html b/coselmar-ui/src/main/webapp/index.html index 0493c56..bd194a0 100644 --- a/coselmar-ui/src/main/webapp/index.html +++ b/coselmar-ui/src/main/webapp/index.html @@ -24,6 +24,8 @@ <html ng-app="coselmarApp" ng-controller="HomeCtrl"> <head> + <meta charset="utf-8" /> + <link rel="stylesheet" href="webjars/bootstrap/3.3.1/css/bootstrap.css"> <link rel="stylesheet" href="webjars/font-awesome/4.2.0/css/font-awesome.css"> <link rel="stylesheet" href="css/coselmar.css"> diff --git a/coselmar-ui/src/main/webapp/js/coselmar-questions-services.js b/coselmar-ui/src/main/webapp/js/coselmar-questions-services.js index 31a05ff..f5f4d1e 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-questions-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-questions-services.js @@ -37,6 +37,7 @@ function Question(resource, config){ var formData = new FormData(); formData.append("question", JSON.stringify(question)); + var questionParam = $.param({'question' : JSON.stringify(question)}); // Save the Question var serviceURl = baseURL; @@ -46,13 +47,9 @@ function Question(resource, config){ var questionResource = resource(serviceURl, null, { 'save': { method:'POST', - transformRequest: angular.identity, - headers:{ - 'Content-Type': undefined - } } }); - questionResource.save(null, formData, successFunction, failFunction); + questionResource.save(null, questionParam, successFunction, failFunction); }; this.findUsers = function(example, successFunction) { @@ -90,19 +87,16 @@ function Question(resource, config){ var formData = new FormData(); formData.append("documents", JSON.stringify(documents)); + var documentsParam = $.param({'documents': JSON.stringify(documents)}) var serviceURl = baseURL + "/" + questionId + "/documents"; var questionResource = resource(serviceURl, null, { 'save': { method:'POST', - transformRequest: angular.identity, isArray: true, - headers:{ - 'Content-Type': undefined - } } }); - questionResource.save(null, formData, successFunction, failFunction); + questionResource.save(null, documentsParam, successFunction, failFunction); }; this.findAllTypes = function(successFunction){ diff --git a/coselmar-ui/src/main/webapp/js/coselmar-services.js b/coselmar-ui/src/main/webapp/js/coselmar-services.js index 7ba27db..c205a04 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-services.js @@ -45,10 +45,10 @@ function Document(resource, config){ var docResource = resource(baseURL, null, { 'upload': { method:'POST', - transformRequest: angular.identity, - headers:{ - 'Content-Type':undefined - } + transformRequest: function (data, headersGetterFunction) { + return data; + }, + headers: {'Content-Type': undefined, 'Content-Transfer-Encoding': 'utf-8'} } }); docResource.upload(null, formData, successFunction, failFunction); diff --git a/coselmar-ui/src/main/webapp/js/coselmar-user-services.js b/coselmar-ui/src/main/webapp/js/coselmar-user-services.js index 309e67a..efd0c70 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-user-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-user-services.js @@ -34,8 +34,7 @@ function User(resource, config){ this.saveUser = function(user, successFunction, failFunction){ - var formData = new FormData(); - formData.append("user", JSON.stringify(user)); + var param = $.param({ 'user': JSON.stringify(user)}); // Save the User var serviceURl = baseURL; @@ -44,14 +43,10 @@ function User(resource, config){ } var userResource = resource(serviceURl, null, { 'save': { - method:'POST', - transformRequest: angular.identity, - headers:{ - 'Content-Type': undefined - } + method:'POST' } }); - userResource.save(null, formData, successFunction, failFunction); + userResource.save(null, param, successFunction, failFunction); } this.getUser = function(id, scope){ @@ -91,7 +86,7 @@ function User(resource, config){ 'post' : { method: 'POST', headers : { - 'Content-Type' : 'application/x-www-form-urlencoded' + 'Content-Type' : 'application/x-www-form-urlencoded;charset=utf-8' }, }}); userResource.post(credentials, successFunction, failFunction); diff --git a/coselmar-ui/src/main/webapp/js/coselmar.js b/coselmar-ui/src/main/webapp/js/coselmar.js index f10805e..12e3435 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar.js +++ b/coselmar-ui/src/main/webapp/js/coselmar.js @@ -126,4 +126,7 @@ coselmarApp.config(function($httpProvider) { } }; }); + + // edit content-type for send data to the server + $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8'; }); \ No newline at end of file -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.