CGI-Template

 view release on metacpan or  search on metacpan

lib/CGI/Template.pm  view on Meta::CPAN

	my $self = shift;
	my %passed_hash = @_;

	my $header = "Content-type: text/html\n";

	my $redirect = 0;
	foreach my $i (keys %passed_hash){
		if( $i =~ /-cookie/ ){
			$header .= "Set-Cookie: " . $passed_hash{$i} . "\n";

		} elsif( $i =~ /-content-type/ ) {
			$header =~ s/text\/html/$passed_hash{$i}/;		

		} elsif( $i =~ /-redirect/ ) {
			$header =~ s/Content-type: .*?\n/Status: 302 Found\nLocation: $passed_hash{$i}\n/m;
			$redirect++;

		} else {
			$header .= "$i: " . $passed_hash{$i} . "\n";
		}
	}

lib/CGI/Template.pm  view on Meta::CPAN

Specifies the request method to be used.  Possible values are C<get> or C<post>.  If set, CGI::Template will require that all requests to the script be of the type specified.  Any other types of requests will result in a call to error().

=back 

=head2 $t->header()

Returns an HTTP Content-type header.  By default, the mimetype returned is C<text/html> but this can be specified.  C<header()> accepts options in the form of key/value pairs:

=over 4

=item -content-type

Sets the MIME type value in the header.  Some examples:

  print $t->header( -content-type => "image/png" );
  print $t->header( -content-type => "text/plain" );

=item -redirect

Causes header() to return a HTTP C<Location> header that will redirect the user to a new page.  Example:

  print $t->header( -redirect => "/cgi-bin/new_location" );

=item -cookie

Sets a cookie.  Example:



( run in 1.540 second using v1.01-cache-2.11-cpan-524268b4103 )