CGI-FormBuilder
view release on metacpan or search on metacpan
lib/CGI/FormBuilder.pm view on Meta::CPAN
return wantarray ? @ret : \@ret;
}
sub header {
my $self = shift;
$self->{header} = shift if @_;
return unless $self->{header};
my %head;
if ($self->{cookies} && defined(my $sid = $self->sessionid)) {
require CGI::Cookie;
$head{'-cookie'} = CGI::Cookie->new(-name => $self->{sessionidname},
-value => $sid);
}
# Set the charset for i18n
$head{'-charset'} = $self->charset;
# Forcibly require - no extra time in normal case, and if
# using Apache::Request this needs to be loaded anyways.
return "Content-type: text/html\n\n" if $::TESTING;
require CGI;
return CGI::header(%head); # CGI.pm MOD_PERL fanciness
lib/CGI/FormBuilder.pm view on Meta::CPAN
}
# must forcibly return scalar undef for CGI::Session easiness
sub sessionid {
my $self = shift;
$self->{sessionid} = shift if @_;
return $self->{sessionid} if $self->{sessionid};
return undef unless $self->{sessionidname};
my %cookies;
if ($self->{cookies}) {
require CGI::Cookie;
%cookies = CGI::Cookie->fetch;
}
if (my $cook = $cookies{"$self->{sessionidname}"}) {
return $cook->value;
} else {
return $self->{params}->param($self->{sessionidname}) || undef;
}
}
sub statetags {
my $self = shift;
t/3b-multi-page.t view on Meta::CPAN
EOE
# Placeholders so code can continue
$session ||= new Stub;
our $NOSESSION = $@ ? 'skip: CGI::Session not installed here' : 0;
skip($NOSESSION, $form->sessionid($session->id), $session->id); #35
# Trick ourselves into producing a header w/ cookie
my $c;
{ local $TESTING = 0; ($c) = $form->header =~ /Set-Cookie: (\S+)/; }
skip($NOSESSION, $c, '_sessionid='.$session->id.';'); #36
# Empty return value?
$session->save_param($form) unless $NOSESSION;
skip($NOSESSION, $session->param('ticket'), $form->field('ticket'));#37
skip($NOSESSION, $session->param('name'), $form->field('name')); #38
# reset name forcibly
( run in 0.620 second using v1.01-cache-2.11-cpan-e9199f4ba4c )