Subject: | PoCo::Client::UserAgent and "303 See Other" |
Date: | Sun, 21 Jan 2007 14:30:58 +0900 (JST) |
To: | rcaputo [...] pobox.com |
From: | PHO <phonohawk [...] ps.sakura.ne.jp> |
Hello,
I found PoCo::Client::UserAgent (and LWP::Parallel::UserAgent) only
follows a redirection when its status is "301 Moved Permanently" or
"302 Found". I know LWP is an HTTP/1.0 client and that behavior is
correct for those clients, but some loose servers (e.g. youtube.com)
send back "303 See Other" as a response to an HTTP/1.0 request. So it
would be nice if PoCo::Client::UserAgent (and
LWP::Parallel::UserAgent) recognizes also "303 See Other" and "307
Temporary Redirect".
Please note that POE-Component-Client-UserAgent-0.06.redirect.patch
only works if ParallelUserAgent-2.57.redirect.patch is applied. I have
sent the latter patch to its author and waiting for a response...
Regards,
PHO
Show quoted text
_______________________________________________________
- PHO - http://ccm.sherry.jp/
OpenPGP public key: 1024D/1A86EF72
Fpr: 5F3E 5B5F 535C CE27 8254 4D1A 14E7 9CA7 1A86 EF72
diff -r -u ParallelUserAgent-2.57.orig/lib/LWP/Parallel/UserAgent.pm
ParallelUserAgent-2.57.mod/lib/LWP/Parallel/UserAgent.pm
--- ParallelUserAgent-2.57.orig/lib/LWP/Parallel/UserAgent.pm
2004-02-11 00:19:19.000000000 +0900
+++ ParallelUserAgent-2.57.mod/lib/LWP/Parallel/UserAgent.pm
2007-01-21 13:50:12.000000000 +0900
@@ -1247,7 +1247,9 @@
"Unknown code $code"));
if ($code == &HTTP::Status::RC_MOVED_PERMANENTLY or
- $code == &HTTP::Status::RC_MOVED_TEMPORARILY) {
+ $code == &HTTP::Status::RC_FOUND or
+ $code == &HTTP::Status::RC_SEE_OTHER or
+ $code == &HTTP::Status::RC_TEMPORARY_REDIRECT) {
# Make a copy of the request and initialize it with the new URI
my $referral = $request->clone;
diff -r -u POE-Component-Client-UserAgent-0.06.orig/UserAgent.pm POE-
Component-Client-UserAgent-0.06.mod/UserAgent.pm
--- POE-Component-Client-UserAgent-0.06.orig/UserAgent.pm 2004-09-04
07:28:31.000000000 +0900
+++ POE-Component-Client-UserAgent-0.06.mod/UserAgent.pm 2007-01-21
13:55:35.000000000 +0900
@@ -315,7 +315,9 @@
# See LWP::Parallel::UserAgent::handle_response for details.
my $code = $response -> code;
if ( $code == HTTP::Status::RC_MOVED_PERMANENTLY
- or $code == HTTP::Status::RC_MOVED_TEMPORARILY )
+ or $code == HTTP::Status::RC_FOUND
+ or $code == HTTP::Status::RC_SEE_OTHER
+ or $code == HTTP::Status::RC_TEMPORARY_REDIRECT )
{
$code = $response -> header ('Client-Warning');
return unless defined ($code) and $code eq 'Redirect loop
detected';