X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fp5-CGI-Ex;a=blobdiff_plain;f=lib%2FCGI%2FEx.pm;h=f8b666cdf06b42db89cb0a355b25ab88353cf6b5;hp=e163008cb4c3a04ccd9f15a962b85520d96a84b2;hb=490b94ab4051adf93abf16a4ed34efb923d6e8fc;hpb=83f0c6a9aaf9bc520cef93b958d51a5d85e8999c diff --git a/lib/CGI/Ex.pm b/lib/CGI/Ex.pm index e163008..f8b666c 100644 --- a/lib/CGI/Ex.pm +++ b/lib/CGI/Ex.pm @@ -7,7 +7,7 @@ CGI::Ex - CGI utility suite - makes powerful application writing fun and easy =cut ###----------------------------------------------------------------### -# Copyright 2006 - Paul Seamons # +# Copyright 2007 - Paul Seamons # # Distributed under the Perl Artistic License without warranty # ###----------------------------------------------------------------### @@ -24,7 +24,7 @@ use vars qw($VERSION use base qw(Exporter); BEGIN { - $VERSION = '2.06'; + $VERSION = '2.22'; $PREFERRED_CGI_MODULE ||= 'CGI'; @EXPORT = (); @EXPORT_OK = qw(get_form @@ -249,7 +249,7 @@ sub content_type { &print_content_type } # print_content_type(); # print_content_type('text/plain); sub print_content_type { - my ($self, $type) = ($#_ >= 1) ? @_ : ref($_[0]) ? (shift, undef) : (undef, shift); + my ($self, $type, $charset) = (@_ && ref $_[0]) ? @_ : (undef, @_); $self = __PACKAGE__->new if ! $self; if ($type) { @@ -257,6 +257,7 @@ sub print_content_type { } else { $type = 'text/html'; } + $type .= "; charset=$charset" if $charset && $charset =~ m|^[\w\-\.\:\+]+$|; if (my $r = $self->apache_request) { return if $r->bytes_sent; @@ -440,7 +441,9 @@ sub send_status { $r->send_http_header; $r->print($mesg); } else { - # not sure of best way to send the message in MP2 + $r->content_type('text/html'); + $r->print($mesg); + $r->rflush; } } else { print "Status: $code\r\n"; @@ -918,6 +921,14 @@ else already printed content-type). Calling this sends the Content-type header. Trying to print -Econtent_type is an error. For clarity, the method -Eprint_content_type is available. + $cgix->print_content_type; + + # OR + $cgix->print_content_type('text/html'); + + # OR + $cgix->print_content_type('text/html', 'utf-8'); + =item C<-Eset_cookie> Arguments are the same as those to CGI->new->cookie({}). @@ -1036,14 +1047,12 @@ See also L. See also L. -=head1 AUTHOR - -Paul Seamons - =head1 LICENSE This module may be distributed under the same terms as Perl itself. -=cut +=head1 AUTHOR -1; +Paul Seamons + +=cut