You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2017/12/03 01:02:51 UTC
[21/50] [abbrv] thrift git commit: THRIFT-2998: Set Content-Type for
HTTP request in Node.js wrapper. Client: nodejs
THRIFT-2998: Set Content-Type for HTTP request in Node.js wrapper.
Client: nodejs
This closes #378
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/5a4f7382
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/5a4f7382
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/5a4f7382
Branch: refs/heads/0.11.0
Commit: 5a4f7382d2c37231693890be11c6faaec495194a
Parents: 43f4bf2
Author: stanevt <tr...@autodesk.com>
Authored: Fri Feb 13 10:45:59 2015 -0500
Committer: James E. King, III <jk...@apache.org>
Committed: Sat Oct 28 17:54:17 2017 -0400
----------------------------------------------------------------------
lib/nodejs/lib/thrift/http_connection.js | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/5a4f7382/lib/nodejs/lib/thrift/http_connection.js
----------------------------------------------------------------------
diff --git a/lib/nodejs/lib/thrift/http_connection.js b/lib/nodejs/lib/thrift/http_connection.js
index 163e5b7..5085538 100644
--- a/lib/nodejs/lib/thrift/http_connection.js
+++ b/lib/nodejs/lib/thrift/http_connection.js
@@ -214,10 +214,13 @@ util.inherits(HttpConnection, EventEmitter);
*/
HttpConnection.prototype.write = function(data) {
var self = this;
- self.nodeOptions.headers["Content-length"] = data.length;
+ var opts = self.nodeOptions;
+ opts.headers["Content-length"] = data.length;
+ if (!opts.headers["Content-Type"])
+ opts.headers["Content-Type"] = "application/x-thrift";
var req = (self.https) ?
- https.request(self.nodeOptions, self.responseCallback) :
- http.request(self.nodeOptions, self.responseCallback);
+ https.request(opts, self.responseCallback) :
+ http.request(opts, self.responseCallback);
req.on('error', function(err) {
self.emit("error", err);
});