diff options
author | Christian Poessinger <christian@poessinger.com> | 2017-11-03 16:45:38 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2017-11-03 16:51:10 +0100 |
commit | f051e369456abe92272da77ab5831d541e1eface (patch) | |
tree | 4b2b9d24b9b74b06de384c83d8e1c2fb5e523a4d | |
parent | 26dcf310dc70cd25ad80249edf895560dec8f72f (diff) | |
download | vyatta-cfg-f051e369456abe92272da77ab5831d541e1eface.tar.gz vyatta-cfg-f051e369456abe92272da77ab5831d541e1eface.zip |
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.
-rwxr-xr-x | scripts/vyatta-load-config.pl | 9 |
1 files changed, 4 insertions, 5 deletions
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"; |