I'm working on a script that crawls a website and reports on any pages that return a 401 status code. The aim is to identify any pages that accept Basic Authentication over plain http (and therefore passwords sent in clear text). Below is a simplified version with the relevant code:
This works fine until we apply the solution, which is for the server to redirect us to the same address starting https://. If I visit one of these 'fixed' pages with a browser and look at the headers, I see a request for http://page followed by a 302 response which redirects to https://page and then a 401 response. My perl script, however, tells me "Status 401 at http://page", which for my purposes is a false positive. Can anyone think of a better way to do this?use strict; use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $uri = shift @ARGV; my $headreq = HTTP::Request->new(HEAD => $uri); my $headres = $ua->request($headreq); my $statuscode = $headres->code(); print "Status 401 at $uri\n" if $statuscode == 401;
cheers
memwaster
In reply to HTTP status codes by memwaster
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |