From 960e5aace4ac538e90b0014f95b9a48b85048ff7 Mon Sep 17 00:00:00 2001 From: espie Date: Wed, 17 Jan 2018 13:25:36 +0000 Subject: [PATCH] Process redirection messages from http. This will help for round-robin sites in anchoring a pkg_add session to a single site, thus removing shearing effects. Initial idea from job@, reworked a lot by me, enthusiastic okay sthen@ --- usr.sbin/pkg_add/OpenBSD/PackageRepository.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm index bba7101065b..02e24ade348 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageRepository.pm,v 1.148 2017/11/01 18:18:10 espie Exp $ +# $OpenBSD: PackageRepository.pm,v 1.149 2018/01/17 13:25:36 espie Exp $ # # Copyright (c) 2003-2010 Marc Espie # @@ -288,15 +288,16 @@ sub parse_problems CORE::open(my $fh, '<', $filename) or return; my $baseurl = $self->url; - my $url = $baseurl; - if (defined $object) { - $url = $object->url; - } my $notyet = 1; my $broken = 0; my $signify_error = 0; $self->{last_error} = 0; while(<$fh>) { + if (m/^Redirected to https?\:\/\/([^\/]*)/) { + $self->{host} = $1; + $baseurl = $self->url; + next; + } next if m/^(?:200|220|221|226|229|230|227|250|331|500|150)[\s\-]/o; next if m/^EPSV command not understood/o; next if m/^Trying [\da-f\.\:]+\.\.\./o; @@ -334,10 +335,12 @@ sub parse_problems # so it's superfluous next if m/^signify:/ && $self->{lasterror}; if ($notyet) { - $self->{state}->errprint("#1: ", $url); + my $url = $baseurl; if (defined $object) { + $url = $object->url; $object->{error_reported} = 1; } + $self->{state}->errprint("#1: ", $url); $notyet = 0; } if (m/^signify:/) { -- 2.20.1