Twitter Streaming API OAuth - Chunked response
I'm using the Phirehose PHP Twitter Streaming API with some modifications so that it also works with OAuth.
However, when I access the Twitter Streaming API, I get a "Transfer-Encoding: Chunked" header as answer, and this comes through the pipe:
Content-Type: application/jsonTransfer-Encoding: chunkedServer: Jetty(6.1.25)
DC8
3522
{long tweet message in JSON format - skipped here as it is not really part of the problem }
The Phir开发者_如何学Cehose Streaming Client is using bare PHP streams to connect to the Twitter API. However it does not seem to understand - or support - chunked HTTP answers.
My question now is: How should this be handled? How do you parse or work with chunked HTTP responses?
Change it to use HTTP/1.0
instead of advertising HTTP/1.1
. The latter will make the server assume your client understands all 1.1 features and chunked encoding. If you send it in 1.0 compatibility mode (which is also advisable to eschew some caching semantics) you will receive a standard response body.
The alternative would be to use an Accept-Encoding: identity
header. But I'm not sure if this is a reliable avoidance strategy; though proxies should mostly honor it.
精彩评论