Mailinglist Archive: opensuse-buildservice (233 mails)

< Previous Next >
[opensuse-buildservice] BSRPC: support redirects
  • From: Marcus Hüwe <suse-tux@xxxxxx>
  • Date: Sat, 13 Dec 2008 23:02:17 +0100
  • Message-id: <20081213220217.GC3175@xxxxxxxxxxxxxxxxxxx>
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
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);
+ } else {
#if ($param->{'verbose'}) {
# 1 while sysread(S, $ans, 1024, length($ans));
# print "< $ans\n";
#}
die("remote error: $status\n") unless $param->{'ignorestatus'};
- } else {
- undef $status;
}
if ($headers{'set-cookie'} && $param->{'uri'}) {
my @cookie = split(',', $headers{'set-cookie'});
< Previous Next >
Follow Ups