ciaranj / node-oauth

OAuth wrapper for node.js
MIT License
2.44k stars 660 forks source link

Unable to process stream response with _performSecureRequest #228

Open cvng opened 9 years ago

cvng commented 9 years ago

Hi there, and thanks for this great oAuth implementation.

However, i found myself unable to work with stream response with actual implementation, because _performSecureRequest wait for the end / close event before returning data.

A simple fix would be passBackControl immediately, when response is a stream, and let the user collect the chunk:

if ( response.headers["transfer-encoding"] == "chunked")
    passBackControl( response );

Hoping that helps :-)

hhamilto commented 7 years ago

Not sure that I agree with the fix suggested here, but this library does need the ability to deal with streamed responses over a long lived connection. +1 eg: Twitter has a streaming API.

hhamilto commented 7 years ago

After taking a longer peek at the source, it looks like omitting a callback makes _performSecureRequest return the node request object, which you can then treat any way you want.

cvng commented 7 years ago

Yes I remember that was for the Twitter streaming API, but that was 2 years now, no PR was merged in the meanwhile?

hhamilto commented 7 years ago

@ciaranj Would you accept a PR that contained a new example of how to interact with Twitter's streaming API?