Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Returning an API response on 'data' rather than 'end' #2

Closed
wants to merge 2 commits into from

2 participants

@harborhoffer

Node is pretty buggy when it comes to the "end" event on an httpS response object. See this bug report:
joyent/node#728

I think we can always safely return a response on the "data" event as we won't be chunking the response.

@mheadd

Changes pulled.

@mheadd mheadd closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 11, 2011
  1. @harborhoffer

    Node V0.5.0 has a bug where the 'end' event on an https response obje…

    harborhoffer authored
    …ct does not fire. We can always safely respond on the 'data' event
  2. @harborhoffer

    Remove log statement

    harborhoffer authored
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 5 deletions.
  1. +2 −5 lib/smsified.js
View
7 lib/smsified.js
@@ -94,12 +94,9 @@ SMSified.prototype.makeApiCall = function(method, path, callback) {
else {
self.responseBody = "";
response.setEncoding('utf8');
- response.on('data', function(chunk) {
- self.responseBody += chunk;
+ response.on('data', function(data) {
+ callback(JSON.parse(data));
});
- response.on('end', function() {
- callback(JSON.parse(self.responseBody));
- });
}
});
apiCall.end();
Something went wrong with that request. Please try again.