Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions lib/nodejs/lib/thrift/xhr_connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ var util = require("util");
var EventEmitter = require("events").EventEmitter;
var thrift = require("./thrift");

var TBufferedTransport = require("./buffered_transport");
var TJSONProtocol = require("./json_protocol");
var InputBufferUnderrunError = require("./input_buffer_underrun_error");
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");

Expand Down Expand Up @@ -108,13 +109,22 @@ XHRConnection.prototype.flush = function () {

var xreq = this.getXmlHttpRequestObject();

if (this.protocol == TBinaryProtocol) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which binary protocol is this referring to?
databricks thrift uses Http Thrift protocol not Binary thrift protocol. Is this referring to the same conectp?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya, each connection within thrift has an associated protocol for encoding as well as a transport type. We use an HTTP connection within the nodeconnector, and we encode that information with a binary protocol and send it in chunks (bufffered transport).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of terminology: HTTP is a transport which can of course be combined with a binary protocol.

xreq.responseType = 'arraybuffer';
}

if (xreq.overrideMimeType) {
xreq.overrideMimeType("application/json");
}

xreq.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
self.setRecvBuffer(this.responseText);
if(self.protocol == TBinaryProtocol) {
self.setRecvBuffer(this.response);
}
else {
self.setRecvBuffer(this.responseText);
}
}
};

Expand Down
Loading