node-oauth icon indicating copy to clipboard operation
node-oauth copied to clipboard

Unable to process stream response with _performSecureRequest

Open cvng opened this issue 10 years ago • 4 comments

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 :-)

cvng avatar Oct 27 '14 08:10 cvng

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 avatar Sep 26 '16 01:09 hhamilto

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.

hhamilto avatar Sep 26 '16 01:09 hhamilto

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

cvng avatar Oct 17 '16 04:10 cvng

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

hhamilto avatar Oct 17 '16 15:10 hhamilto