Repository: thrift
Updated Branches:
  refs/heads/master 55c3abcb6 -> eec445ef8


THRIFT-2674 JavaScript: declare Accept: and Content-Type: in request


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/eec445ef
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/eec445ef
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/eec445ef

Branch: refs/heads/master
Commit: eec445ef8ac88d94049bd7ad1a3d203f34c6f5c8
Parents: 55c3abc
Author: henrique <[email protected]>
Authored: Mon May 4 21:37:51 2015 +1000
Committer: henrique <[email protected]>
Committed: Mon May 4 21:37:51 2015 +1000

----------------------------------------------------------------------
 lib/js/src/thrift.js | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/eec445ef/lib/js/src/thrift.js
----------------------------------------------------------------------
diff --git a/lib/js/src/thrift.js b/lib/js/src/thrift.js
index 35f679c..af45d9c 100644
--- a/lib/js/src/thrift.js
+++ b/lib/js/src/thrift.js
@@ -327,7 +327,7 @@ Thrift.TXHRTransport.prototype = {
         var xreq = this.getXmlHttpRequestObject();
 
         if (xreq.overrideMimeType) {
-            xreq.overrideMimeType('application/json');
+            xreq.overrideMimeType('application/vnd.apache.thrift.json; 
charset=utf-8');
         }
 
         if (callback) {
@@ -346,6 +346,12 @@ Thrift.TXHRTransport.prototype = {
         }
 
         xreq.open('POST', this.url, !!async);
+
+        if (xreq.setRequestHeader) {
+            xreq.setRequestHeader('Accept', 
'application/vnd.apache.thrift.json; charset=utf-8');
+            xreq.setRequestHeader('Content-Type', 
'application/vnd.apache.thrift.json; charset=utf-8');
+        }
+
         xreq.send(this.send_buf);
         if (async && callback) {
             return;
@@ -387,7 +393,7 @@ Thrift.TXHRTransport.prototype = {
             data: postData,
             type: 'POST',
             cache: false,
-            contentType: 'application/json',
+            contentType: 'application/vnd.apache.thrift.json; charset=utf-8',
             dataType: 'text thrift',
             converters: {
                 'text thrift' : function(responseData) {

Reply via email to