CGI-Ex

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

  * (Validate) Allow for type, enum, and equals to short circuit (don't run match, compare, length, or custom checks if type fails)
  * (App) Fix the test suite to not require installation of CGI
  * (App) Add CGI::Ex::App::Constants module supporting constants as a source of documentation
  * (App) Allow for access to constants via use CGI::Ex::App qw(:App); or use MyApp qw(:App);

2.36      2010-06-10
  * (Auth) Make delete_cookie always delete, even for session Apps.

2.35      2010-05-24
  * (Auth) More robust cookie reading and writing and deleting.
  * Workaround CGI::Cookie->parse weird empty cookie implementation.
  * (Auth) Allow cookie_domain to be modified more gracefully.
  * (Auth) Consider case with multiple cookies for the same name.

2.34      2010-04-23
  * (Auth) Don't attempted to decode base64 armor unless use_base64

2.33      2010-04-01
  * (Auth) Allow for custom form user vs valid cookie check

2.32      2010-02-25

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

    my $obj    = $self->object;
    my $cookie = "" . $obj->cookie(%$args);

    if ($self->content_typed) {
        print "<script>document.cookie = '$cookie'</script>\n";
    } else {
        if (my $r = $self->apache_request) {
            if ($self->is_mod_perl_1) {
                $r->header_out("Set-cookie", $cookie);
            } else {
                $r->headers_out->add("Set-Cookie", $cookie);
            }
        } else {
            print "Set-Cookie: $cookie\r\n";
        }
    }
}

### print the last modified time
### takes a time or filename and an optional keyname
#   $cgix->last_modified; # now
#   $cgix->last_modified((stat $file)[9]); # file's time
#   $cgix->last_modified(time, 'Expires'); # different header
sub last_modified {

t/0_ex_00_base.t  view on Meta::CPAN

### try print_content_type
if (eval { require Tie::Handle }) {
    local @ISA = qw(Tie::Handle);
    my $old_out = select STDOUT;

    {
        local *STDOUT;
        tie *STDOUT, __PACKAGE__;

        local $ENV{'CONTENT_TYPED'} = 0;
        is($cgix->set_cookie(name => 'test', value => 1), "Set-Cookie: test=1; path=/\r\n", 'Got correct Set-Cookie header');

        local $ENV{'CONTENT_TYPED'} = 1;
        is($cgix->set_cookie(name => 'test', value => 0), "<script>document.cookie = 'test=0; path=/'</script>\n", 'Got correct cookie js due to headers printing earlier');
    }

    foreach ([[]                             => "Content-Type: text/html\r\n\r\n"],
             [['text/html']                  => "Content-Type: text/html\r\n\r\n"],
             [['text/html', '']              => "Content-Type: text/html\r\n\r\n"],
             [['image/gif']                  => "Content-Type: image/gif\r\n\r\n"],
             [['text/html', 'utf-8'],        => "Content-Type: text/html; charset=utf-8\r\n\r\n"],

t/8_auth_00_base.t  view on Meta::CPAN

ok($Auth::printed, "Printed was set");
ok(! $Auth::set_cookie, "Set_cookie was not called");
ok($Auth::deleted_cookie, "deleted_cookie was called");
is($Auth::failed_login_user, 'test2', 'correct user on failed passed information');

###----------------------------------------------------------------###

Auth::reset();
Auth->get_valid_auth({form => {%$form_good}, cookies => {}});
ok($Auth::set_cookie, "Set_cookie called");
ok($Auth::cookie->{'expires'}, "Cookie had expires");

Auth::reset();
Auth->get_valid_auth({form => {%$form_good}, cookies => {}, use_session_cookie => 0});
ok($Auth::set_cookie, "Set_cookie called");
ok($Auth::cookie->{'expires'}, "Cookie had expires");

Auth::reset();
Auth->get_valid_auth({form => {%$form_good}, cookies => {}, use_session_cookie => 1});
ok($Auth::set_cookie, "Set_cookie called");
ok(! $Auth::cookie->{'expires'}, "Session cookie");

Auth::reset();
Auth->get_valid_auth({form => {%$form_good}, cookies => {}, use_plaintext => 1});
ok($Auth::set_cookie, "Set_cookie called");
ok(! $Auth::cookie->{'expires'}, "Session cookie");

Auth::reset();
Auth->get_valid_auth({form => {%$form_good}, cookies => {}, use_plaintext => 1, use_session_cookie => 0});
ok($Auth::set_cookie, "Set_cookie called");
ok($Auth::cookie->{'expires'}, "Cookie had expires");

Auth::reset();
Auth->get_valid_auth({form => {%$form_good}, cookies => {}, use_plaintext => 1, use_session_cookie => 1});
ok($Auth::set_cookie, "Set_cookie called");
ok(! $Auth::cookie->{'expires'}, "Session cookie");


###----------------------------------------------------------------###

my $auth = Aut2->get_valid_auth({form => {%$form_good3}});



( run in 0.643 second using v1.01-cache-2.11-cpan-e9199f4ba4c )