[opensuse-buildservice] BSRPC: support redirects
Hi, is it possible to add this patch to the BSRPC.pm module so that it supports redirects (atm only 302 is implemented)? This would allow download on demand users to use mirrors like download.o.o or others which do redirects. Are there any objections? Marcus
Marcus Hüwe napsal(a):
Index: BSRPC.pm =================================================================== --- BSRPC.pm (Revision 5877) +++ BSRPC.pm (Arbeitskopie) @@ -225,14 +225,20 @@ } my %headers; BSHTTP::gethead(\%headers, $headers); - if ($status !~ /^200[^\d]/) { + if ($status =~ /^200[^\d]/) { + undef $status; + } elsif ($status =~ /^302[^\d]/) { + # XXX: should we do the redirect if $param->{'ignorestatus'} is defined? + close S; + die("status 302 but no 'location' header found\n") unless exists $headers{'location'}; + $param->{'uri'} = $headers{'location'}; + return rpc($param, $xmlargs, @args);
Shouldn't there be an upper limit on the number of redirects? Michal -- To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-buildservice+help@opensuse.org
On 2008-12-13 23:31:11 +0100, Michal Marek wrote:
Marcus Hüwe napsal(a):
Index: BSRPC.pm =================================================================== --- BSRPC.pm (Revision 5877) +++ BSRPC.pm (Arbeitskopie) @@ -225,14 +225,20 @@ } my %headers; BSHTTP::gethead(\%headers, $headers); - if ($status !~ /^200[^\d]/) { + if ($status =~ /^200[^\d]/) { + undef $status; + } elsif ($status =~ /^302[^\d]/) { + # XXX: should we do the redirect if $param->{'ignorestatus'} is defined? + close S; + die("status 302 but no 'location' header found\n") unless exists $headers{'location'}; + $param->{'uri'} = $headers{'location'}; + return rpc($param, $xmlargs, @args);
Shouldn't there be an upper limit on the number of redirects?
Arghs - thanks for the hint. Here's the new version. Marcus
participants (2)
-
Marcus Hüwe
-
Michal Marek