From f051e369456abe92272da77ab5831d541e1eface Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Fri, 3 Nov 2017 16:45:38 +0100 Subject: T281: Support 'http' permanent redirects (code 301) This enables fetching a VyOS config from a http://foo/bar URL even when http://foo/bar is a permanent redirect to https://foo/bar. --- scripts/vyatta-load-config.pl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/vyatta-load-config.pl b/scripts/vyatta-load-config.pl index 1ffadcd..c52851c 100755 --- a/scripts/vyatta-load-config.pl +++ b/scripts/vyatta-load-config.pl @@ -107,15 +107,14 @@ elsif ( $mode eq 'url' ) { if ( $proto eq 'http' or $proto eq 'https' ) { # # error codes are send back in html, so 1st try a header - # and look for "HTTP/1.1 200 OK" + # and look for "HTTP/1.1 200 OK" or "HTTP/1.1 301 Moved Permanently" # - my $rc = `curl -q -I $load_file 2>&1`; + my $rc = `curl -L -q -I $load_file 2>&1`; if ( $rc =~ /HTTP\/\d+\.?\d\s+(\d+)\s+(.*)$/mi ) { my $rc_code = $1; my $rc_string = $2; - if ( $rc_code == 200 ) { - - # good resonse + if ( $rc_code == 200 or $rc_code == 301 ) { + # good response } else { print "http error: [$rc_code] $rc_string\n"; -- cgit v1.2.3