#!/usr/bin/perl ############################################################ # &outputDebug(); # uncomment this to enable debug mode output # On the web, see http://www.bath.ac.uk/%7Epy8ieh/cgi/development/tests/linemodel1 ############################################################ # name: Line Model (1) # author: Ian Hickson # license: GPL # description: serious stress tests for edge cases of line model # See also: # http://www.bath.ac.uk/%7Epy8ieh/cgi/development/tests/linemodel1 # http://www.bath.ac.uk/%7Epy8ieh/internet/projects/mozilla/compatimg-std.html # http://www.bath.ac.uk/%7Epy8ieh/internet/projects/mozilla/compatimg.html # http://bugzilla.mozilla.org/show_bug.cgi?id=13097 ############################################################ # Initialise System use lib '../utils'; use strict; use MIME::Base64; $output::mediaPath = '../../../media/'; $output::appName = 'HTTP Basic Authentication'; $output::authorContact = 'http://www.bath.ac.uk/%7Epy8ieh/'; $output::authorName = 'Ian Hickson'; $output::authorEmail = 'py8ieh=website=cgi=development=tests=auth_basic@bath.ac.uk'; require 'inputRoutines.pl'; # get cookies, parameters require 'outputRoutines.pl'; # so that we can output stuff $output::level = $output::levelFOOT; # we don't use outputRoutines ############################################################ my($user, $pass); if ($ENV{'HTTP_AUTHORIZATION'} =~ /^Basic (.*)$/os) { ($user, $pass) = split(/:/, decode_base64($1), 2); } if (($user) and ($user ne $ENV{QUERY_STRING})) { print "HTTP/1.1 200 OK\nContent-Type: text/html\n\n"; } else { print "HTTP/1.1 401 Unauthorized\nWWW-Authenticate: Basic realm=\"first test\"\nContent-Type: text/html\n\n"; } print(< Authentication Test -- HTTP Basic Authentication

HTTP Basic Authentication

user: $user; pass: $pass (try again)

Here is the environment of this CGI script:

end foreach my $key (sort(keys %ENV)) { print "\n"; } print(< end ############################################################
VariableValue
" . $key . '' . $ENV{$key} . "