diff --git a/lib/nodejs/lib/thrift/xhr_connection.js b/lib/nodejs/lib/thrift/xhr_connection.js index 6459c900c2a..7b52e9793c8 100644 --- a/lib/nodejs/lib/thrift/xhr_connection.js +++ b/lib/nodejs/lib/thrift/xhr_connection.js @@ -22,6 +22,7 @@ var thrift = require('./thrift'); var TBufferedTransport = require('./buffered_transport'); var TJSONProtocol = require('./json_protocol'); +var TBinaryProtocol = require('./binary_protocol'); var InputBufferUnderrunError = require('./input_buffer_underrun_error'); var createClient = require('./create_client'); @@ -102,13 +103,17 @@ XHRConnection.prototype.flush = function() { var xreq = this.getXmlHttpRequestObject(); + if (this.protocol == TBinaryProtocol) { + xreq.responseType = 'arraybuffer'; + } + if (xreq.overrideMimeType) { xreq.overrideMimeType('application/json'); } xreq.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { - self.setRecvBuffer(this.responseText); + self.setRecvBuffer(this.response); } };