summaryrefslogtreecommitdiff
path: root/lib/CGI.pm
diff options
context:
space:
mode:
authorSteve Peters <steve@fisharerojo.org>2006-02-16 12:54:08 +0000
committerSteve Peters <steve@fisharerojo.org>2006-02-16 12:54:08 +0000
commit55b5d70095e7b9679db373ca7ac72c1951b35a3c (patch)
treedb3c84a933fd5db5a07b7d3a8ba6dd5db629957a /lib/CGI.pm
parent45812765cccbfdc897c33c3834bf546fc25c90ab (diff)
downloadperl-55b5d70095e7b9679db373ca7ac72c1951b35a3c.tar.gz
Upgrade to CGI-3.16, with version bump on CGI.pm for documentation
fixes not yet integrated. p4raw-id: //depot/perl@27202
Diffstat (limited to 'lib/CGI.pm')
-rw-r--r--lib/CGI.pm21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/CGI.pm b/lib/CGI.pm
index 4d5742b9c9..e93efc08d4 100644
--- a/lib/CGI.pm
+++ b/lib/CGI.pm
@@ -18,8 +18,8 @@ use Carp 'croak';
# The most recent version and complete docs are available at:
# http://stein.cshl.org/WWW/software/CGI/
-$CGI::revision = '$Id: CGI.pm,v 1.194 2005/12/06 22:12:56 lstein Exp $';
-$CGI::VERSION='3.15_01';
+$CGI::revision = '$Id: CGI.pm,v 1.200 2006/02/08 18:28:54 lstein Exp $';
+$CGI::VERSION='3.16_01';
# HARD-CODED LOCATION FOR FILE UPLOAD TEMPORARY FILES.
# UNCOMMENT THIS ONLY IF YOU KNOW WHAT YOU'RE DOING.
@@ -1418,10 +1418,13 @@ sub header {
'ATTACHMENT','P3P'],@p);
$nph ||= $NPH;
+
+ $type ||= 'text/html' unless defined($type);
+
if (defined $charset) {
$self->charset($charset);
} else {
- $charset = $self->charset;
+ $charset = $self->charset if $type =~ /^text\//;
}
# rearrange() was designed for the HTML portion, so we
@@ -1432,8 +1435,7 @@ sub header {
($_ = $header) =~ s/^(\w)(.*)/"\u$1\L$2" . ': '.$self->unescapeHTML($value)/e;
}
- $type ||= 'text/html' unless defined($type);
- $type .= "; charset=$charset" if $type ne '' and $type =~ m!^text/! and $type !~ /\bcharset\b/ and $charset ne '';
+ $type .= "; charset=$charset" if $type ne '' and $type !~ /\bcharset\b/ and $charset ne '';
# Maybe future compatibility. Maybe not.
my $protocol = $ENV{SERVER_PROTOCOL} || 'HTTP/1.0';
@@ -1499,7 +1501,7 @@ sub redirect {
my($self,@p) = self_or_default(@_);
my($url,$target,$status,$cookie,$nph,@other) =
rearrange([[LOCATION,URI,URL],TARGET,STATUS,['COOKIE','COOKIES'],NPH],@p);
- $status = '302 Moved' unless defined $status;
+ $status = '302 Found' unless defined $status;
$url ||= $self->self_url;
my(@o);
foreach (@other) { tr/\"//d; push(@o,split("=",$_,2)); }
@@ -1546,7 +1548,7 @@ sub start_html {
$self->element_id(0);
$self->element_tab(0);
- $encoding = 'iso-8859-1' unless defined $encoding;
+ $encoding = lc($self->charset) unless defined $encoding;
# Need to sort out the DTD before it's okay to call escapeHTML().
my(@result,$xml_dtd);
@@ -6679,6 +6681,11 @@ simple to turn a CGI parameter into a cookie, and vice-versa:
# vice-versa
param(-name=>'answers',-value=>[cookie('answers')]);
+If you call cookie() without any parameters, it will return a list of
+the names of all cookies passed to your script:
+
+ @cookies = cookie();
+
See the B<cookie.cgi> example script for some ideas on how to use
cookies effectively.