I experienced a problem with the latest Mail::Webmail::Yahoo
(this is on perl 5.8.1 on Linux) that I *believe* stems from a problem
with LWP::Protocol::http. Correcting what I thought the problem was
there caused the Mail::Webmail::Yahoo tests to pass.
Initial symptom: the Mail::Webmail::Yahoo tests fail:
ok 2
not ok 3
# Test 3 got: <UNDEF> (t/all.t at line 88)
# Expected: '1' (Unable to log in (welcome page did not contain welcome text).)
# t/all.t line 88 is: skip(!$y_username, $l_ok, 1, $@);
Using the debugger I dumped the response to the login request, appended.
Observe the error was 500: "Can't read entity body."
I noticed that the redirect chain showed that the redirected requests were
still sending content-length headers and had the same content as the
original POST. That seemed wrong to me for GET requests, so I reran
it and stepped in the debugger to LWP::UserAgent::request. After the
first simple_request() I modified $referral as follows:
DB<6> $referral->{_content} = ''
DB<7> $referral->{_headers}{'content-length'} = 0
DB<8> delete $referral->{_headers}{'content-type'}
I then let the code continue and the test passed, indicating that the
final response was not 500.
I thought that GET requests were not allowed to send content.
Shouldn't a redirected POST request have its content removed?
That appeared to cure the problem here. The following patch to
LWP::UserAgent.pm has the same effect:
--- UserAgent.pm 2003-11-12 05:39:56.000000000 -0800
+++ UserAgent.pm.orig 2003-11-12 05:30:52.000000000 -0800
@@ -301,15 +301,10 @@
->abs($base);
}
- if (($code == &HTTP::Status::RC_SEE_OTHER ||
- $code == &HTTP::Status::RC_FOUND) &&
- $referral->method ne "HEAD")
- {
- $referral->method("GET");
- $referral->content('');
- $referral->content_length(0);
- $referral->remove_header('Content-type');
- }
+ $referral->method("GET")
+ if ($code == &HTTP::Status::RC_SEE_OTHER ||
+ $code == &HTTP::Status::RC_FOUND) &&
+ $referral->method ne "HEAD";
$referral->url($referral_uri);
$referral->remove_header('Host', 'Cookie');
Even if Yahoo is being unduly picky, or non-compliant, if GETs aren't
supposed to send content, the patch is still valid.
Response dump follows, altered only to elide username and password.
Mail::Webmail::Yahoo::_get_a_page(/root/.cpan/build/Mail-Webmail-Yahoo-0.601/blib/lib/Mail/Webmail/Yahoo.pm:1128):
1128: my $resp = $self->{_ua}->request($req);
DB<4> n
Mail::Webmail::Yahoo::_get_a_page(/root/.cpan/build/Mail-Webmail-Yahoo-0.601/blib/lib/Mail/Webmail/Yahoo.pm:1130):
1130: $self->{_cookie_jar}->extract_cookies($resp);
DB<4> x $resp
0 HTTP::Response=HASH(0x8b930e4)
'_content' => '500 Can\'t read entity body: Connection reset by peer
'
'_headers' => HTTP::Headers=HASH(0x8b93030)
'client-date' => 'Sat, 08 Nov 2003 00:06:18 GMT'
'client-warning' => 'Internal response'
'content-type' => 'text/plain'
'_msg' => 'Can\'t read entity body: Connection reset by peer'
'_previous' => HTTP::Response=HASH(0x8b92e38)
'_content' => "HTTP/1.1 302 Found\cM\cJDate: Sat, 08 Nov 2003 00:06:03
GMT\cM\cJP3P: policyref=\"http://p3p.yahoo.com/w3c/p3p.xml\", CP=\"CAO DSP COR CUR ADM
DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI
PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV\"\cM\cJLocation:
http://us.f205.mail.yahoo.com/ym/login?.rand=237pdnkd1jqjs\cM\cJConnection:
close\cM\cJTransfer-Encoding: chunked\cM\cJContent-Type: text/html;
charset=iso-8859-1\cM\cJ\cM\cJThe document has moved <A
HREF=\"http://us.f205.mail.yahoo.com/ym/login?.rand=237pdnkd1jqjs\">here</A>.<P>\cJ<P>Additionally,
a 302 Found\cJerror was encountered while trying to use an ErrorDocument to handle
the request.\cJ"
'_headers' => HTTP::Headers=HASH(0x8b7fd2c)
'client-date' => 'Sat, 08 Nov 2003 00:06:16 GMT'
'client-peer' => '216.136.226.148:80'
'client-response-num' => 1
'client-transfer-encoding' => 'chunked'
'connection' => 'close'
'content-type' => 'text/html'
'date' => 'Sat, 08 Nov 2003 00:06:03 GMT'
'location' => 'http://us.f205.mail.yahoo.com/ym/login?.rand=237pdnkd1jqjs'
'p3p' => 'policyref="http://p3p.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR
ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL
UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"'
'_msg' => 'Found'
'_previous' => HTTP::Response=HASH(0x8b7d134)
'_content' => ''
'_headers' => HTTP::Headers=HASH(0x8b7d128)
'cache-control' => 'private'
'client-date' => 'Sat, 08 Nov 2003 00:06:15 GMT'
'client-peer' => '66.218.75.184:80'
'client-response-num' => 1
'connection' => 'close'
'content-type' => 'text/html'
'date' => 'Sat, 08 Nov 2003 00:06:03 GMT'
'expires' => 'Thu, 05 Jan 1995 22:00:00 GMT'
'location' => 'http://f205.mail.yahoo.com/ym/login?.rand=237pdnkd1jqjs'
'p3p' => 'policyref="http://p3p.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR
CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY
ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"'
'pragma' => 'no-cache'
'set-cookie' =>
'F=a=M2zc3C0svSMUoXC6Gn6_vF5Xof0kpcZQ_tl8TXu.VKbMQeBUxXaCO09iXEHI&b=_ve_;
domain=.yahoo.com; expires=Thu, 15 Apr 2010 20:00:00 GMT; path=/'
'_msg' => 'Found'
'_previous' => HTTP::Response=HASH(0x8b88ce4)
'_content' => ''
'_headers' => HTTP::Headers=HASH(0x8b88cd8)
'cache-control' => 'private'
'client-date' => 'Sat, 08 Nov 2003 00:06:14 GMT'
'client-peer' => '66.218.75.184:80'
'client-response-num' => 1
'connection' => 'close'
'content-type' => 'text/html'
'date' => 'Sat, 08 Nov 2003 00:06:02 GMT'
'expires' => 'Thu, 05 Jan 1995 22:00:00 GMT'
'location' =>
'http://login.yahoo.com/config/verify?.done=http%3a//f205.mail.yahoo.com/ym/login%3f.rand=237pdnkd1jqjs'
'p3p' => 'policyref="http://p3p.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR
CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY
ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"'
'pragma' => 'no-cache'
'set-cookie' => ARRAY(0x83a25a8)
0
'Y=v=1&n=35s2ifgr4lard&l=f4j4h_9_i2ejj/o&p=m1t2p28413000200&r=4e&lg=us&intl=us&np=1;
path=/; domain=.yahoo.com'
1
'T=z=qNDr/AqTYr/AfwxHmemwMQKNTcyBjU3MDE1MjQxMDY-&a=YAE&sk=DAAVTcsew1WdpT&d=c2wBTWpBMUFdSXdOell5TlRfMk56Rn0BYQFZQUUBb2sBWlcwLQF0aXABWXcyWWZDAXp6AXFORHIvQWdXQQ--;
path=/; domain=.yahoo.com'
'_msg' => 'Found'
'_protocol' => 'HTTP/1.0'
'_rc' => 302
'_request' => HTTP::Request=HASH(0x8b73884)
'_content' =>
'.tries=1&.src=ym&.md5=&.hash=&.js=&.last=&promo=&.intl=us&.bypass=&.partner=&.u=2hkmaugvqocqn&.v=0&.challenge=467_3Mmyry.P9EqZUlpswsywglVb&.yplus=&.emailCode=&pkg=&stepid=&.ev=&hasMsgr=0&.chkP=Y&.done=http%3A%2F%2Fmail.yahoo.com&login=xxx&passwd=xxx&.save=Sign%20In'
'_headers' => HTTP::Headers=HASH(0x8b738e4)
'accept' => 'text/html, text/plain, application/x-director,
application/x-shockwave-flash, image/x-quicktime, video/quicktime, image/jpeg,
image/*, application/x-gunzip, application/x-gzip, application/x-bunzip2,
application/x-tar-gz, audio/*, video/*, text/sgml, video/mpeg, image/jpeg, image/tiff,
image/x-rgb, image/png, image/x-xbitmap, image/x-xbm, image/gif,
application/postscript, */*;q=0.01'
'accept-language' => '*'
'cache-control' => 'no-cache'
'content-length' => 280
'content-type' => 'application/x-www-form-urlencoded'
'cookie' =>
'F=a=.nsTEIIsvSMmhAbWRYt1AEkb7q6issAx4Q8fcQ7wRdZbNHyYo2i5TteoELz2&b=Tixc'
'cookie2' => '$Version="1"'
'pragma' => 'no-cache'
'referer' => 'file://none.html'
'user-agent' => 'Yahoo-Webmail/0.601'
'_method' => 'POST'
'_uri' => URI::http=SCALAR(0x8aee4e0)
-> 'http://login.yahoo.com/config/login?5nkjjqhbhumc4'
'_protocol' => 'HTTP/1.0'
'_rc' => 302
'_request' => HTTP::Request=HASH(0x8b866ac)
'_content' =>
'.tries=1&.src=ym&.md5=&.hash=&.js=&.last=&promo=&.intl=us&.bypass=&.partner=&.u=2hkmaugvqocqn&.v=0&.challenge=467_3Mjymy.P9EqZUlpswsywglVb&.yplus=&.emailCode=&pkg=&stepid=&.ev=&hasMsgr=0&.chkP=Y&.done=http%3A%2F%2Fmail.yahoo.com&login=xxxt&passwd=xxx&.save=Sign%20In'
'_headers' => HTTP::Headers=HASH(0x8b86730)
'accept' => 'text/html, text/plain, application/x-director,
application/x-shockwave-flash, image/x-quicktime, video/quicktime, image/jpeg,
image/*, application/x-gunzip, application/x-gzip, application/x-bunzip2,
application/x-tar-gz, audio/*, video/*, text/sgml, video/mpeg, image/jpeg, image/tiff,
image/x-rgb, image/png, image/x-xbitmap, image/x-xbm, image/gif,
application/postscript, */*;q=0.01'
'accept-language' => '*'
'cache-control' => 'no-cache'
'content-length' => 280
'content-type' => 'application/x-www-form-urlencoded'
'cookie' =>
'Y=v=1&n=35s2ifgr4lard&l=f4j4h_9_i2ejj/o&p=m1t2p28413000200&r=4e&lg=us&intl=us&np=1;
F=a=.nsTEcIsvSMmhARWRYt1AEkb7q6ibsAb4Q8fcQ72Rd7bNHyYo2iuTneoELz2&b=Tixc;
T=z=qNDr/AqTYr/AfwxHmemwMQKNTcyBjU3MDE1MjQxMDY-&a=YAE&sk=DAAVTpsew1WdpT&d=c2wBTWpBMUFUSXdOell5TlRNMk56RS0BYQFZQUUBb2sBWlcwLQF0aXABWXcyWWZDAXp6AXFORHIvQWdXQQ--'
'cookie2' => '$Version="1"'
'pragma' => 'no-cache'
'referer' => 'file://none.html'
'user-agent' => 'Yahoo-Webmail/0.601'
'_method' => 'GET'
'_uri' => URI::http=SCALAR(0x8b88df8)
->
'http://login.yahoo.com/config/verify?.done=http%3a//f205.mail.yahoo.com/ym/login%3f.rand=237pdnkd1jqjs'
'_protocol' => 'HTTP/1.1'
'_rc' => 302
'_request' => HTTP::Request=HASH(0x8b7b4e4)
'_content' =>
'.tries=1&.src=ym&.md5=&.hash=&.js=&.last=&promo=&.intl=us&.bypass=&.partner=&.u=2hkhaugvqocqn&.v=0&.challenge=467_3Mjyrm.P9EqZUlpswsywglVb&.yplus=&.emailCode=&pkg=&stepid=&.ev=&hasMsgr=0&.chkP=Y&.done=http%3A%2F%2Fmail.yahoo.com&login=xxx&passwd=xxx&.save=Sign%20In'
'_headers' => HTTP::Headers=HASH(0x8b7b478)
'accept' => 'text/html, text/plain, application/x-director,
application/x-shockwave-flash, image/x-quicktime, video/quicktime, image/jpeg,
image/*, application/x-gunzip, application/x-gzip, application/x-bunzip2,
application/x-tar-gz, audio/*, video/*, text/sgml, video/mpeg, image/jpeg, image/tiff,
image/x-rgb, image/png, image/x-xbitmap, image/x-xbm, image/gif,
application/postscript, */*;q=0.01'
'accept-language' => '*'
'cache-control' => 'no-cache'
'content-length' => 280
'content-type' => 'application/x-www-form-urlencoded'
'cookie' =>
'Y=v=1&n=35s2ifgr4lard&l=f4j4h_9_i2ejj/o&p=m1t2p28413000200&r=4e&lg=us&intl=us&np=1;
F=a=MLzc3C0svSMUoXC6Gn6_2F5Xof0kpcZV_tl8TXu.VKbMQeBUxSaCO09iXEHI&b=_ve_;
T=z=qNDr/AqTYr/AfwxcmemwMbKNTcyBjU3MDE1MjQxMDY-&a=YAE&sk=DAAVTpsbw1WdpT&d=c2wBTWnBMUFUSXdOell5TlRNMk5cRS0mYQFZQUUBb2sBWlcwLQF0aXABWXcyWWZDAXp6AXFORHIvQWdXQQ--'
'cookie2' => '$Version="1"'
'pragma' => 'no-cache'
'referer' => 'file://none.html'
'user-agent' => 'Yahoo-Webmail/0.601'
'_method' => 'GET'
'_uri' => URI::http=SCALAR(0x8b7b358)
-> 'http://f205.mail.yahoo.com/ym/login?.rand=237pdnkd1jqjs'
'_rc' => 500
'_request' => HTTP::Request=HASH(0x8b7f6a0)
'_content' =>
'.tries=1&.src=ym&.md5=&.hash=&.js=&.last=&promo=&.intl=us&.bypass=&.partner=&.u=2hxhaugvqocqn&.v=0&.challenge=467_3Mjyry.P9EmZblpswsymglVb&.yplus=&.emailCode=&pkg=&stepid=&.ev=&hasMsgr=0&.chkP=Y&.done=http%3A%2F%2Fmail.yahoo.com&login=xxx&passwd=xxx&.save=Sign%20In'
'_headers' => HTTP::Headers=HASH(0x8b7f598)
'accept' => 'text/html, text/plain, application/x-director,
application/x-shockwave-flash, image/x-quicktime, video/quicktime, image/jpeg,
image/*, application/x-gunzip, application/x-gzip, application/x-bunzip2,
application/x-tar-gz, audio/*, video/*, text/sgml, video/mpeg, image/jpeg, image/tiff,
image/x-rgb, image/png, image/x-xbitmap, image/x-xbm, image/gif,
application/postscript, */*;q=0.01'
'accept-language' => '*'
'cache-control' => 'no-cache'
'content-length' => 280
'content-type' => 'application/x-www-form-urlencoded'
'cookie' =>
'Y=v=1&n=35s2ifgr4lard&l=f4j4h_9_i2ejj/o&p=m1t2p28413000200&r=4e&lg=us&intl=us&np=1;
F=a=MLzc3C0svSMUoXC6Gn6_2F5Xof0kpcZV_tl8TXu.VKbMQeBUxSaCO09iXEHI&b=_ve_;
T=z=qNDr/AqTYr/AfwxHmemwMQKNTcyBjU3MDE1MjQxMDY-&a=YAE&sk=DAAVTpsew1xdpT&d=c2wBTWpBMUFUSXbOell5TlRNMk56RS0BmQFZQUUwb2sBWlcwLQF0aXABWXcyWWZDAXp6AXFORHIvQWdXQQ--'
'cookie2' => '$Version="1"'
'pragma' => 'no-cache'
'referer' => 'file://none.html'
'user-agent' => 'Yahoo-Webmail/0.601'
'_method' => 'GET'
'_uri' => URI::http=SCALAR(0x8b7d3e0)
-> 'http://us.f205.mail.yahoo.com/ym/login?.rand=237pdnkd1jqjs'
DB<5>
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com/
*** New! *** http://www.perlmedic.com/