Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding res.on('end') in order to receive all chunks of the body on da…

…ta callback
  • Loading branch information...
commit b3d5b597333a8149a6ad99fb142c3565c4a02693 1 parent 5f3d75f
@patprzybilla patprzybilla authored rui committed
Showing with 13 additions and 5 deletions.
  1. +13 −5 lib/client.js
View
18 lib/client.js
@@ -30,11 +30,11 @@ OO._.extend(OoyalaApiClient.prototype, {
get: function(headers, apiPath, params, statusCb, dataCb, errCb, context) {
this._curl('GET', headers, apiPath, params, null, statusCb, dataCb, errCb, context)
},
-
patch: function(headers, apiPath, params, body, statusCb, dataCb, errCb, context) {
this._curl('PATCH', headers, apiPath, params, body, statusCb, dataCb, errCb, context)
},
+
_curl: function(method, headers, apiPath, params, body, statusCb, dataCb, errCb, context) {
headers = headers || {};
headers['Content-length'] = body ? body.length : 0;
@@ -47,7 +47,7 @@ OO._.extend(OoyalaApiClient.prototype, {
});
params["signature"] = this._sign(params, method, apiPath, body).slice(0,43);
-
+ console.log('params',params)
var options = {
host: this.hostName,
port: this.hostPort,
@@ -55,13 +55,20 @@ OO._.extend(OoyalaApiClient.prototype, {
headers: headers,
method: method
};
-
+ console.log('options',options)
+ var data = '';
+ var ci = 0;
var req = httpClient.request(options, function(res) {
statusCb.apply(context, [res.statusCode, JSON.stringify(res.headers)]);
res.setEncoding('utf8');
- res.on('data', function() {
- if (dataCb) { dataCb.apply(context, arguments); }
+ res.on('data', function(chunk) {
+
+ data += chunk
});
+ res.on('end',function(){
+
+ if (dataCb) { dataCb.apply(context,[data]); }
+ });
});
if (errCb) {
req.on('error', function() {
@@ -69,6 +76,7 @@ OO._.extend(OoyalaApiClient.prototype, {
});
}
if (body) { req.write(body); }
+
req.end();
},
Please sign in to comment.
Something went wrong with that request. Please try again.