Subject: | Long header(longer than 1024bytes) may cause timeout. |
Hi,
I asked question on stackoverflow,
http://stackoverflow.com/questions/13421307/oauthliteconsumer-timeouts-when-i-access-to-twitter
Environment is Net::HTTP 6.05, perl 5.16.2, OAuth::Lite 1.31.
Server is CentOS release 6.3 (Final), 2.6.32-279.14.1.el6.x86_64.
Minimum code to reproduce the bug is below,
use OAuth::Lite::Consumer;
my $consumer = OAuth::Lite::Consumer->new(
request_token_path =>
'https://api.twitter.com/oauth/request_token',
consumer_key => '[CONSUMER KEY]',
consumer_secret => '[CONSUMER SECRET]',
callback_url => '[CALLBACK]',
);
my $rtoken = $consumer->get_request_token();
will return after 30sec.
I read the code, and I figure out that method my_readline in
Net::HTTP::Methods line 259-260 in Net::HTTP 6.05
die "read timeout" unless $self->can_read;
my $n = $self->sysread($_, 1024, length);
blocks request. And the header that my_readline trying to read is
HTTP/1.1 200 OK
Date: Fri, 16 Nov 2012 16:16:39 GMT
Status: 200 OK
X-MID: 266cca0268c8eb68e76eedda256c77829ea9b22e
X-Transaction: 784ff126dfead993
Tag: "382e5356bb65e976f6b117bacdfa05e4"
Cache-Control: no-cache, no-store, must-revalidate, pre-check=0,
post-check=0
X-Runtime: 0.02892
Pragma: no-cache
Expires: Tue, 31 Mar 1981 05:00:00 GMT
X-Frame-Options: SAMEORIGIN
Content-Type: text/html; charset=utf-8
Last-Modified: Fri, 16 Nov 2012 16:16:39 GMT
Set-Cookie: k=10.36.55.109.1353082599368934; path=/; expires=Fri,
23-Nov-12 16:16:39 GMT; domain=.twitter.com
Set-Cookie: guest_id=v1%3A135308259937793094; domain=.twitter.com;
path=/; expires=Mon, 17-Nov-2014 04:16:39 GMT
Set-Cookie:
_twitter_sess=BAh7CCIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo%250ASGFzaHsABjoKQHVzZWR7ADoHaWQiJTJlZGJiN2MyOTMyNmM0OGY0MjJmZmY0%250AMTU3YzllYTI0Og9jcmVhdGVkX2F0bCsI0vcBCjsB--21ab24a6dd6596b1dcc78651c0b6a4836b320621;
domain=.twitter.com; path=/; HttpOnly
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 150
Server: tfe
This header exceeded 1024 characters.
When I downgrade Net-HTTP to 6.03, it works fine.
Thanks.