From d7784a40269fb7af8e925501db64d8374efed1d2 Mon Sep 17 00:00:00 2001 From: Vahe Arakelyan Date: Fri, 28 Sep 2018 16:14:50 +0400 Subject: [PATCH 1/4] Fixed XHR error on put requests when the query params are long --- src/service/request.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/service/request.js b/src/service/request.js index 6ebb66d..c2f24d9 100644 --- a/src/service/request.js +++ b/src/service/request.js @@ -46,11 +46,10 @@ module.exports = function(Api) { this.httpConfig.headers = this.httpConfig.headers || {}; - if( method === this.Methods.GET - && (( this.httpConfig.url + '?' + JSON.stringify(params)).length > 1500 + if((( this.httpConfig.url + '?' + JSON.stringify(params)).length > 1500 || path === 'batch' )) { this.httpConfig.method = this.Methods.POST; - params.method = this.Methods.GET; + params.method = (path === 'batch' ? this.Methods.GET : method); this.httpConfig.data = this.serializer(params); this.httpConfig.params = undefined; this.httpConfig.headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8'; From 249be8bc0665158b8f2aa294dbb5f115d4f25f6f Mon Sep 17 00:00:00 2001 From: Vahe Arakelyan Date: Fri, 28 Sep 2018 17:39:39 +0400 Subject: [PATCH 2/4] Changed the logic of creating post request for get and put methods in case of large query params. --- src/service/request.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/service/request.js b/src/service/request.js index c2f24d9..97442de 100644 --- a/src/service/request.js +++ b/src/service/request.js @@ -46,16 +46,21 @@ module.exports = function(Api) { this.httpConfig.headers = this.httpConfig.headers || {}; - if((( this.httpConfig.url + '?' + JSON.stringify(params)).length > 1500 - || path === 'batch' )) { - this.httpConfig.method = this.Methods.POST; - params.method = (path === 'batch' ? this.Methods.GET : method); - this.httpConfig.data = this.serializer(params); - this.httpConfig.params = undefined; - this.httpConfig.headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8'; - } else if(data) { + if(data) { this.httpConfig.data = data; this.httpConfig.headers['Content-Type'] = 'application/json;charset=utf-8'; + } else if( method === this.Methods.GET && (( this.httpConfig.url + '?' + JSON.stringify(params)).length > 1500 || path === 'batch' )) { + this.httpConfig.method = this.Methods.POST; + params.method = this.Methods.GET; + this.httpConfig.data = this.serializer(params); + this.httpConfig.params = undefined; + this.httpConfig.headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8'; + } else if (method === this.Methods.PUT && (this.httpConfig.url + '?' + JSON.stringify(params)).length > 1500 && !data) { + this.httpConfig.method = this.Methods.POST; + params.method = this.Methods.PUT; + this.httpConfig.data = this.serializer(params); + this.httpConfig.params = undefined; + this.httpConfig.headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8'; } return this.http(this.httpConfig); From 712faa81a69b3b54a2b33d567df3572796dec4cb Mon Sep 17 00:00:00 2001 From: Vahe Arakelyan Date: Fri, 28 Sep 2018 18:29:57 +0400 Subject: [PATCH 3/4] Removed redundant check --- src/service/request.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/service/request.js b/src/service/request.js index 97442de..0cab5ed 100644 --- a/src/service/request.js +++ b/src/service/request.js @@ -55,7 +55,7 @@ module.exports = function(Api) { this.httpConfig.data = this.serializer(params); this.httpConfig.params = undefined; this.httpConfig.headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8'; - } else if (method === this.Methods.PUT && (this.httpConfig.url + '?' + JSON.stringify(params)).length > 1500 && !data) { + } else if (method === this.Methods.PUT && (this.httpConfig.url + '?' + JSON.stringify(params)).length > 1500) { this.httpConfig.method = this.Methods.POST; params.method = this.Methods.PUT; this.httpConfig.data = this.serializer(params); From 1ce1a5271b6b7167cd5ef43c79098e633ec7b0ca Mon Sep 17 00:00:00 2001 From: Vahe Arakelyan Date: Fri, 28 Sep 2018 18:32:26 +0400 Subject: [PATCH 4/4] Added bowerrc file containing registry value. --- .bowerrc | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .bowerrc diff --git a/.bowerrc b/.bowerrc new file mode 100644 index 0000000..f2571d7 --- /dev/null +++ b/.bowerrc @@ -0,0 +1,3 @@ +{ + "registry": "https://registry.bower.io" +}