#!/usr/bin/perl
##
##  downuni -- downloads a book from the universal folder
##

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@forminput = split(/&/, $buffer);
@addenda = split(/&/, $ENV{'QUERY_STRING'});
@finalinput = (@forminput, @addenda);
foreach (@finalinput)
{
  tr/+/ /;
  ($name, $value) = split(/=/, $_);
  $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  $in{$name}=$value;
}
print "Location: http://www.newtonslibrary.org/uni/$in{'file'}\n\n";

