• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
CGI.pm - 3ло?!
 

CGI.pm - 3ло?!

on

  • 2,273 views

 

Statistics

Views

Total Views
2,273
Views on SlideShare
2,268
Embed Views
5

Actions

Likes
1
Downloads
5
Comments
0

2 Embeds 5

http://www.slideshare.net 3
http://www.linkedin.com 2

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    CGI.pm - 3ло?! CGI.pm - 3ло?! Presentation Transcript

    • CGI.pm — зло?!
    • CGI.pm
    • Lincoln D. Stein
    • 131(76)
    • 3.37 23 апреля 2008
    • 245 КБ
    • 4087
    • 174+
    • 480 стр
    • Возможности
    • • ООП и ФОП • генерация (x)html • поддержка mod_perl, XForms, server-push • совместимость с cgi-lib.pl • поддержка мелочей (IE 3.01 Macintosh) • магия, много магии (174+)
    • Баги
    • 121
    • Недостатки
    • • Vars теряет доступ к FH • одновременно GET и POST параметры • ProgressBar?! • некорректная работа с UTF-8 • mod_perl повсюду • медленная загрузка в память
    • POE
    • 1 my $q; if ( $request->method() eq 'POST' ) { $q = new CGI( $request->content ); } else { $request->uri() =~ /?(.+$)/; if ( defined($1) ) { $q = new CGI( $1 ); } else { $q = new CGI; } }
    • 2 local %ENV; ... $ENV{REQUEST_METHOD} = $request->method; $ENV{QUERY_STRING} = $uri->query; $ENV{COOKIE} = $request->header('Cookie'); ... our $content = $request->content; tie *STDIN, 'IO::Scalar', $content; my $q = new CGI;
    • Альтернативы
    • • CGI::Simple • CGI::Minimal • CGI::Lite • CGI::EasyCGI • CGI::WebIn • CGI::Thin
    • “use CGI or die”
    • Идеальный “CGI.pm”
    • • разбор запроса независимо от интерфейса • CGI, mod_perl, FastCGI, POE и etc. • ProgressBar! • XForms, server-push и etc. • просто, легко и быстро :)
    • *::CGI my $self = shift->SUPER::new( ... 'method' => $ENV{'REQUEST_METHOD'}, 'query' => $ENV{'QUERY_STRING'} || $ENV{'REDIRECT_QUERY_STRING'}, 'type' => $ENV{'CONTENT_TYPE'}, 'length' => $ENV{'CONTENT_LENGTH'}, 'stream' =>*STDIN, ); $self->parse;
    • *::ModPerl my $REQUEST = ({ 1 => sub { require Apache; my $r = shift || Apache->request || return; $r->register_cleanup(sub {1}); return $r; }, 2 => sub { ... } })->{ $ENV{'MOD_PERL'} && $ENV{'MOD_PERL_API_VERSION'} };
    • *::ModPerl my $self = shift->SUPER::new( ... 'method' => $REQUEST ? $REQUEST->method : ..., 'query' => $REQUEST ? $REQUEST->args : ..., 'type' => $ENV{'CONTENT_TYPE'}, 'length' => $ENV{'CONTENT_LENGTH'}, 'stream' =>*STDIN, ); $self->parse;
    • *::FCGI use FCGI; our $REQUEST; BEGIN { $REQUEST = $ENV{'FCGI_SOCKET_PATH'} ? FCGI::Request(undef, undef, undef, undef, FCGI::OpenSocket($ENV{'FCGI_SOCKET_PATH'}, ($ENV{'FCGI_LISTEN_QUEUE'} || 100)), FCGI::FAIL_ACCEPT_ON_INTR ) : FCGI::Request; }
    • *::FCGI $self->{'request'} = $REQUEST; ... $self->{'request'} ? $self->{'request'}->Accept >= 0 : FCGI::accept >= 0; ...
    • *::POE my $REQUEST = ...; # HTTP::Request ... open my $STREAM, '<', ($REQUEST->content || '');
    • *::POE my $self = shift->SUPER::new( ... 'method' => $REQUEST->method, 'query' => URI->new($REQUEST->uri)->query, 'type' => join('; ', $REQUEST->content_type), 'length' => $REQUEST->content_length, 'stream' => $STREAM, ); $self->parse;
    • CGI.pm — зло !
    • CGI.pm — зло?!
    • Анатолий Шарифулин RostovOnDon.pm 2008