Skip to content

Commit

Permalink
fix RESTClient response handling, we were not collecting all chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
robotdan committed Nov 5, 2018
1 parent 212899a commit 1f4ed8c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.savant
Expand Up @@ -15,7 +15,7 @@
*/
savantVersion = "1.0.0"

project(group: "io.fusionauth", name: "fusionauth-node-client", version: "1.0.18", licenses: ["ApacheV2_0"]) {
project(group: "io.fusionauth", name: "fusionauth-node-client", version: "1.0.19", licenses: ["ApacheV2_0"]) {
workflow {
standard()
}
Expand Down
3 changes: 2 additions & 1 deletion fusionauth-node-client.iml
Expand Up @@ -10,4 +10,5 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Groovy 2.2" level="application" />
</component>
</module>
</module>

17 changes: 10 additions & 7 deletions lib/RESTClient.js
Expand Up @@ -166,24 +166,27 @@ RESTClient.prototype = {
}

const clientResponse = new ClientResponse();
let streamData = '';
const request = myHttp.request(options, function(response) {
clientResponse.statusCode = response.statusCode;
response.on('data', function(data) {
let json = data;
streamData += data;
}).on('error', function(error) {
clientResponse.exception = error;
}).on('exception', function(exception) {
clientResponse.exception = exception;
}).on('end', function() {
let json = streamData;
try {
json = JSON.parse(data);
json = JSON.parse(streamData);
} catch (err) {
console.error(err);
}
if (clientResponse.wasSuccessful()) {
clientResponse.successResponse = json;
} else {
clientResponse.errorResponse = json;
}
}).on('error', function(error) {
clientResponse.exception = error;
}).on('exception', function(exception) {
clientResponse.exception = exception;
}).on('end', function() {
responseHandler(clientResponse);
});
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "fusionauth-node-client",
"version": "1.0.18",
"version": "1.0.19",
"description": "FusionAuth Client written in Node.js",
"private": false,
"contributors": [
Expand Down

0 comments on commit 1f4ed8c

Please sign in to comment.