SlideShare une entreprise Scribd logo
1  sur  29
WEB APPS WITH PERL
                                 HTTP 101




HENDRIK VAN BELLEGHEM
HENDRIK.VANBELLEGHEM@GMAIL.COM
UNDERSTANDING HTTP




     ONE PAGE, MANY PACKETS
UNDERSTANDING HTTP




      DOCUMENT REQUEST
UNDERSTANDING HTTP




      RESPONSE STATUS
UNDERSTANDING HTTP




       REQUEST DOMAIN
UNDERSTANDING HTTP




       RESPONSE SIZE
UNDERSTANDING HTTP




       RESPONSE TIME
UNDERSTANDING HTTP
UNDERSTANDING HTTP




     BROWSER SENDS
UNDERSTANDING HTTP


    WEBSERVER RESPONDS
DIY

CGI SCRIPT - HELLO WORLD

#!/usr/bin/perl
print quot;Content-type: text/htmlnnquot;;
print quot;Hello Worldquot;;
DIY
DIY

   CGI SCRIPT - INTERACTION

#!/usr/bin/perl
print quot;Content-type: text/htmlnnquot;;
@pairs = split(/&/, $ENV{'QUERY_STRING'});
foreach $pair (@pairs)
{ ($name, $value) = split(/=/, $pair);
  $value =~ tr/+/ /;
  $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(quot;Cquot;, hex($1))/eg;
  $value =~ s/n/ /g;
  $request{$name} = $value;
}
print quot;Hello quot;,$request{'name'};
DIY
DIY

   CGI SCRIPT - INTERACTION

#!/usr/bin/perl

                 MY EYES!!!!
print quot;Content-type: text/htmlnnquot;;
@pairs = split(/&/, $ENV{'QUERY_STRING'});
foreach $pair (@pairs)
{ ($name, $value) = split(/=/, $pair);
  $value =~ tr/+/ /;
  $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(quot;Cquot;, hex($1))/eg;
  $value =~ s/n/ /g;
  $request{$name} = $value;
}

           THE HORROR!!!!
print quot;Hello quot;,$request{'name'};
CGI.PM

   CGI SCRIPT - HELLO WORLD

#!/usr/bin/perl
use CGI qw(header);
print header;
print “Hello world”;
CGI.PM

   CGI SCRIPT - INTERACTION

#!/usr/bin/perl
use CGI qw(header param);
print header;
my $name = param(‘name’);
print “Hello $name”;
CGI.PM

TRANSPARENT POST & GET

FILE UPLOADS

QUICK COOKIES

HTML GENERATION (NOT MY FAVORITE)

FUNCTION SETS: :CGI = PARAM , HEADER, ...

DROP-IN DEVELOPMENT
MOD_PERL


PERL AS AN APACHE MODULE

INTERACT WITH EVERY STEP OF APACHE REQUEST CYCLE

PERSISTENT COPY OF PERL IN MEMORY

NO DROP-IN DEVELOPMENT

  EXCEPT FOR APACHE::RELOAD
MOD_PERL 1


16 CYCLES IN MOD_PERL 1

CONTENT HANDLER: PERLHANDLER

LOG HANDLER: PERLLOGHANDLER

AUTHENTICATION HANDLER
MOD_PERL 2


21 CYCLES IN MOD_PERL 2

CONTENT HANDLER: PERLRESPONSEHANDLER

LOG HANDLER: PERLLOGHANDLER

AUTHENTICATION HANDLER
MOD_PERL 1

   CONTENT HANDLER - HELLO WORLD

package Apache::HelloWorld;
use Apache::Constants qw(:common); # Export OK
sub handler
# mod_perl uses handler method unless specified otherwise
{ print quot;Content-type: text/plainnnquot;; # MY EYES!!
   print quot;Hello Worldnquot;;
   return OK; # read as HTTP status 200
}
1;

PerlModule Apache::HelloWorld
<Location /HelloWorld>
 SetHandler perl-script
 PerlHandler Apache::HelloWorld
</Location>

http://localhost/HelloWorld/
MOD_PERL 1

   CONTENT HANDLER - HELLO WORLD REVISED

package Apache::HelloWorld;
use Apache::Constants qw(:common); # Export OK
sub handler
# mod_perl uses handler method unless specified otherwise
{ my $r = shift;
   # 1st argument is instance of Apache's Request object
   $r->send_http_header('text/plain');
   # Send HTTP header (similar to CGI's header)
   $r->print(quot;Hello Worldnquot;);
   return OK; # read as HTTP status 200
}
1;

PerlModule Apache::HelloWorld
<Location /HelloWorld>
 SetHandler perl-script
 PerlHandler Apache::HelloWorld
</Location>

http://localhost/HelloWorld/
MOD_PERL 1

   CONTENT HANDLER - HELLO BOB!

package Apache::HelloBob
use Apache::Constants qw(:common); # Export OK
sub handler
# mod_perl uses handler method unless specified otherwise
{ my $r = shift;
   # 1st argument is instance of Apache's Request object
   my %query_string = $r->args; # GET data
   my %post_data = $r->content; # POST data
   my $name = $query_string{'name'};
   $r->send_http_header('text/plain');
   # Send HTTP header (similar to CGI's header)
   $r->print(quot;Hello $namenquot;);
   return OK; # read as HTTP status 200
}
1;


http://localhost/HelloBob?name=Bob
APACHE::REQUEST (A::R)

INHERITS FROM APACHE CLASS

MIMICS CGI.PM METHODS

SUPPORTS FILE UPLOADS

SUPPORTS COOKIES - APACHE::COOKIE / APACHE2::COOKIE



AVAILABLE FOR MOD_PERL V1 & V2
MOD_PERL 1

   CONTENT HANDLER - HELLO BOB WITH A::R

package Apache::HelloWorld;
use Apache::Constants qw(:common); # Export OK
use Apache::Request (); # isa Apache
sub handler
# mod_perl uses handler method unless specified otherwise
{ my $r = shift;
   my $apr = Apache::Request->new($r);
   # Pass Apaches Request object to A::R
   $apr->send_http_header('text/plain');
   my $name = $apr->param(‘name’);
   # Send HTTP header (similar to CGI's header)
   $apr->print(quot;Hello $namenquot;);
   return OK; # read as HTTP status 200
}
1;

http://localhost/HelloWorld?name=Bob
MOD_PERL 2

   CONTENT HANDLER - HELLO WORLD

package Apache2::HelloWorld;
use Apache2::Const qw(:common); # Export OK
sub handler
# mod_perl2 uses handler method unless specified otherwise
{ print quot;Content-type: text/plainnnquot;; # MY EYES!!
   print quot;Hello Worldnquot;;
   return OK; # read as HTTP status 200
}
1;

PerlModule Apache2::HelloWorld
<Location /HelloWorld>
 SetHandler perl-script
 PerlResponseHandler Apache2::HelloWorld
</Location>

http://localhost/HelloWorld/
MOD_PERL 2

   CONTENT HANDLER - HELLO WORLD REVISED

package Apache2::HelloWorld;
use Apache2::Const qw(:common); # Export OK
sub handler
# mod_perl2 uses handler method unless specified otherwise
{ my $r = shift;
   # 1st argument is instance of Apache's Request object
   $r->content_type('text/plain');
   # Send HTTP header (similar to CGI's header)
   $r->print(quot;Hello Worldnquot;);
   return OK; # read as HTTP status 200
}
1;

PerlModule Apache2::HelloWorld
<Location /HelloWorld>
 SetHandler perl-script
 PerlResponseHandler Apache2::HelloWorld
</Location>

http://localhost/HelloWorld/
MOD_PERL 2

   CONTENT HANDLER - HELLO BOB WITH A2::R

package Apache2::HelloBob;
use Apache2::Const qw(:common); # Export OK
use Apache2::Request (); # isa Apache
sub handler
# mod_perl uses handler method unless specified otherwise
{ my $r = shift;
   my $apr = Apache2::Request->new($r);
   # Pass Apaches Request object to A2::R
   $apr->send_http_header('text/plain');
   my $name = $apr->param(‘name’);
   # Send HTTP header (similar to CGI's header)
   $apr->print(quot;Hello $namenquot;);
   return OK; # read as HTTP status 200
}
1;

http://localhost/HelloWorld?name=Bob

Contenu connexe

Tendances

Perl: Hate it for the Right Reasons
Perl: Hate it for the Right ReasonsPerl: Hate it for the Right Reasons
Perl: Hate it for the Right ReasonsMatt Follett
 
Keeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro frameworkKeeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro frameworkJeremy Kendall
 
Keeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkKeeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkJeremy Kendall
 
Perl: Coro asynchronous
Perl: Coro asynchronous Perl: Coro asynchronous
Perl: Coro asynchronous Shmuel Fomberg
 
Any event intro
Any event introAny event intro
Any event introqiang
 
A reviravolta do desenvolvimento web
A reviravolta do desenvolvimento webA reviravolta do desenvolvimento web
A reviravolta do desenvolvimento webWallace Reis
 
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...Arc & Codementor
 
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Shinya Ohyanagi
 
Operation Oriented Web Applications / Yokohama pm7
Operation Oriented Web Applications / Yokohama pm7Operation Oriented Web Applications / Yokohama pm7
Operation Oriented Web Applications / Yokohama pm7Masahiro Nagano
 
Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)xSawyer
 
Mojolicious: what works and what doesn't
Mojolicious: what works and what doesn'tMojolicious: what works and what doesn't
Mojolicious: what works and what doesn'tCosimo Streppone
 
Zend Framework Study@Tokyo vol1
Zend Framework Study@Tokyo vol1Zend Framework Study@Tokyo vol1
Zend Framework Study@Tokyo vol1Shinya Ohyanagi
 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHPWim Godden
 
Slim RedBeanPHP and Knockout
Slim RedBeanPHP and KnockoutSlim RedBeanPHP and Knockout
Slim RedBeanPHP and KnockoutVic Metcalfe
 
Electrify your code with PHP Generators
Electrify your code with PHP GeneratorsElectrify your code with PHP Generators
Electrify your code with PHP GeneratorsMark Baker
 
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webclkao
 
PHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return TypesPHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return TypesEric Poe
 

Tendances (20)

PHP5.5 is Here
PHP5.5 is HerePHP5.5 is Here
PHP5.5 is Here
 
Perl: Hate it for the Right Reasons
Perl: Hate it for the Right ReasonsPerl: Hate it for the Right Reasons
Perl: Hate it for the Right Reasons
 
Keeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro frameworkKeeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro framework
 
Keeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkKeeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro framework
 
Perl: Coro asynchronous
Perl: Coro asynchronous Perl: Coro asynchronous
Perl: Coro asynchronous
 
Perl5i
Perl5iPerl5i
Perl5i
 
Any event intro
Any event introAny event intro
Any event intro
 
A reviravolta do desenvolvimento web
A reviravolta do desenvolvimento webA reviravolta do desenvolvimento web
A reviravolta do desenvolvimento web
 
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
 
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
 
Operation Oriented Web Applications / Yokohama pm7
Operation Oriented Web Applications / Yokohama pm7Operation Oriented Web Applications / Yokohama pm7
Operation Oriented Web Applications / Yokohama pm7
 
Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)
 
Mojolicious: what works and what doesn't
Mojolicious: what works and what doesn'tMojolicious: what works and what doesn't
Mojolicious: what works and what doesn't
 
Zend Framework Study@Tokyo vol1
Zend Framework Study@Tokyo vol1Zend Framework Study@Tokyo vol1
Zend Framework Study@Tokyo vol1
 
New in php 7
New in php 7New in php 7
New in php 7
 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHP
 
Slim RedBeanPHP and Knockout
Slim RedBeanPHP and KnockoutSlim RedBeanPHP and Knockout
Slim RedBeanPHP and Knockout
 
Electrify your code with PHP Generators
Electrify your code with PHP GeneratorsElectrify your code with PHP Generators
Electrify your code with PHP Generators
 
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time web
 
PHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return TypesPHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return Types
 

Similaire à Web Apps in Perl - HTTP 101

PSGI and Plack from first principles
PSGI and Plack from first principlesPSGI and Plack from first principles
PSGI and Plack from first principlesPerl Careers
 
Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!Jeff Jones
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with PerlDave Cross
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy CodeRowan Merewood
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHPNat Weerawan
 
Php a dynamic web scripting language
Php   a dynamic web scripting languagePhp   a dynamic web scripting language
Php a dynamic web scripting languageElmer Concepcion Jr.
 
Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!Anatoly Sharifulin
 
Doing Things the WordPress Way
Doing Things the WordPress WayDoing Things the WordPress Way
Doing Things the WordPress WayMatt Wiebe
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareAlona Mekhovova
 
HackU PHP and Node.js
HackU PHP and Node.jsHackU PHP and Node.js
HackU PHP and Node.jssouridatta
 
REST with Eve and Python
REST with Eve and PythonREST with Eve and Python
REST with Eve and PythonPiXeL16
 

Similaire à Web Apps in Perl - HTTP 101 (20)

Lecture8
Lecture8Lecture8
Lecture8
 
PSGI and Plack from first principles
PSGI and Plack from first principlesPSGI and Plack from first principles
PSGI and Plack from first principles
 
Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with Perl
 
Plack at YAPC::NA 2010
Plack at YAPC::NA 2010Plack at YAPC::NA 2010
Plack at YAPC::NA 2010
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHP
 
Php a dynamic web scripting language
Php   a dynamic web scripting languagePhp   a dynamic web scripting language
Php a dynamic web scripting language
 
Api Design
Api DesignApi Design
Api Design
 
Blog Hacks 2011
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011
 
Rack Middleware
Rack MiddlewareRack Middleware
Rack Middleware
 
PHP
PHPPHP
PHP
 
Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!
 
Doing Things the WordPress Way
Doing Things the WordPress WayDoing Things the WordPress Way
Doing Things the WordPress Way
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middleware
 
HackU PHP and Node.js
HackU PHP and Node.jsHackU PHP and Node.js
HackU PHP and Node.js
 
REST with Eve and Python
REST with Eve and PythonREST with Eve and Python
REST with Eve and Python
 
Web Scraping with PHP
Web Scraping with PHPWeb Scraping with PHP
Web Scraping with PHP
 
PHP
PHP PHP
PHP
 

Plus de hendrikvb

Mojo – Simple REST Server
Mojo – Simple REST ServerMojo – Simple REST Server
Mojo – Simple REST Serverhendrikvb
 
China.z / Trojan.XorDDOS - Analysis of a hack
China.z / Trojan.XorDDOS - Analysis of a hackChina.z / Trojan.XorDDOS - Analysis of a hack
China.z / Trojan.XorDDOS - Analysis of a hackhendrikvb
 
Source Filters in Perl 2010
Source Filters in Perl 2010Source Filters in Perl 2010
Source Filters in Perl 2010hendrikvb
 
Scrabbling Code - Beatnik - YAPC::Eu::2003
Scrabbling Code - Beatnik - YAPC::Eu::2003Scrabbling Code - Beatnik - YAPC::Eu::2003
Scrabbling Code - Beatnik - YAPC::Eu::2003hendrikvb
 
Json In 5 Slices.Key
Json In 5 Slices.KeyJson In 5 Slices.Key
Json In 5 Slices.Keyhendrikvb
 

Plus de hendrikvb (6)

Mojo – Simple REST Server
Mojo – Simple REST ServerMojo – Simple REST Server
Mojo – Simple REST Server
 
China.z / Trojan.XorDDOS - Analysis of a hack
China.z / Trojan.XorDDOS - Analysis of a hackChina.z / Trojan.XorDDOS - Analysis of a hack
China.z / Trojan.XorDDOS - Analysis of a hack
 
Source Filters in Perl 2010
Source Filters in Perl 2010Source Filters in Perl 2010
Source Filters in Perl 2010
 
Scrabbling Code - Beatnik - YAPC::Eu::2003
Scrabbling Code - Beatnik - YAPC::Eu::2003Scrabbling Code - Beatnik - YAPC::Eu::2003
Scrabbling Code - Beatnik - YAPC::Eu::2003
 
Json In 5 Slices.Key
Json In 5 Slices.KeyJson In 5 Slices.Key
Json In 5 Slices.Key
 
Cleancode
CleancodeCleancode
Cleancode
 

Dernier

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 

Dernier (20)

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 

Web Apps in Perl - HTTP 101

  • 1. WEB APPS WITH PERL HTTP 101 HENDRIK VAN BELLEGHEM HENDRIK.VANBELLEGHEM@GMAIL.COM
  • 2. UNDERSTANDING HTTP ONE PAGE, MANY PACKETS
  • 3. UNDERSTANDING HTTP DOCUMENT REQUEST
  • 4. UNDERSTANDING HTTP RESPONSE STATUS
  • 5. UNDERSTANDING HTTP REQUEST DOMAIN
  • 6. UNDERSTANDING HTTP RESPONSE SIZE
  • 7. UNDERSTANDING HTTP RESPONSE TIME
  • 9. UNDERSTANDING HTTP BROWSER SENDS
  • 10. UNDERSTANDING HTTP WEBSERVER RESPONDS
  • 11. DIY CGI SCRIPT - HELLO WORLD #!/usr/bin/perl print quot;Content-type: text/htmlnnquot;; print quot;Hello Worldquot;;
  • 12. DIY
  • 13. DIY CGI SCRIPT - INTERACTION #!/usr/bin/perl print quot;Content-type: text/htmlnnquot;; @pairs = split(/&/, $ENV{'QUERY_STRING'}); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(quot;Cquot;, hex($1))/eg; $value =~ s/n/ /g; $request{$name} = $value; } print quot;Hello quot;,$request{'name'};
  • 14. DIY
  • 15. DIY CGI SCRIPT - INTERACTION #!/usr/bin/perl MY EYES!!!! print quot;Content-type: text/htmlnnquot;; @pairs = split(/&/, $ENV{'QUERY_STRING'}); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(quot;Cquot;, hex($1))/eg; $value =~ s/n/ /g; $request{$name} = $value; } THE HORROR!!!! print quot;Hello quot;,$request{'name'};
  • 16. CGI.PM CGI SCRIPT - HELLO WORLD #!/usr/bin/perl use CGI qw(header); print header; print “Hello world”;
  • 17. CGI.PM CGI SCRIPT - INTERACTION #!/usr/bin/perl use CGI qw(header param); print header; my $name = param(‘name’); print “Hello $name”;
  • 18. CGI.PM TRANSPARENT POST & GET FILE UPLOADS QUICK COOKIES HTML GENERATION (NOT MY FAVORITE) FUNCTION SETS: :CGI = PARAM , HEADER, ... DROP-IN DEVELOPMENT
  • 19. MOD_PERL PERL AS AN APACHE MODULE INTERACT WITH EVERY STEP OF APACHE REQUEST CYCLE PERSISTENT COPY OF PERL IN MEMORY NO DROP-IN DEVELOPMENT EXCEPT FOR APACHE::RELOAD
  • 20. MOD_PERL 1 16 CYCLES IN MOD_PERL 1 CONTENT HANDLER: PERLHANDLER LOG HANDLER: PERLLOGHANDLER AUTHENTICATION HANDLER
  • 21. MOD_PERL 2 21 CYCLES IN MOD_PERL 2 CONTENT HANDLER: PERLRESPONSEHANDLER LOG HANDLER: PERLLOGHANDLER AUTHENTICATION HANDLER
  • 22. MOD_PERL 1 CONTENT HANDLER - HELLO WORLD package Apache::HelloWorld; use Apache::Constants qw(:common); # Export OK sub handler # mod_perl uses handler method unless specified otherwise { print quot;Content-type: text/plainnnquot;; # MY EYES!! print quot;Hello Worldnquot;; return OK; # read as HTTP status 200 } 1; PerlModule Apache::HelloWorld <Location /HelloWorld> SetHandler perl-script PerlHandler Apache::HelloWorld </Location> http://localhost/HelloWorld/
  • 23. MOD_PERL 1 CONTENT HANDLER - HELLO WORLD REVISED package Apache::HelloWorld; use Apache::Constants qw(:common); # Export OK sub handler # mod_perl uses handler method unless specified otherwise { my $r = shift; # 1st argument is instance of Apache's Request object $r->send_http_header('text/plain'); # Send HTTP header (similar to CGI's header) $r->print(quot;Hello Worldnquot;); return OK; # read as HTTP status 200 } 1; PerlModule Apache::HelloWorld <Location /HelloWorld> SetHandler perl-script PerlHandler Apache::HelloWorld </Location> http://localhost/HelloWorld/
  • 24. MOD_PERL 1 CONTENT HANDLER - HELLO BOB! package Apache::HelloBob use Apache::Constants qw(:common); # Export OK sub handler # mod_perl uses handler method unless specified otherwise { my $r = shift; # 1st argument is instance of Apache's Request object my %query_string = $r->args; # GET data my %post_data = $r->content; # POST data my $name = $query_string{'name'}; $r->send_http_header('text/plain'); # Send HTTP header (similar to CGI's header) $r->print(quot;Hello $namenquot;); return OK; # read as HTTP status 200 } 1; http://localhost/HelloBob?name=Bob
  • 25. APACHE::REQUEST (A::R) INHERITS FROM APACHE CLASS MIMICS CGI.PM METHODS SUPPORTS FILE UPLOADS SUPPORTS COOKIES - APACHE::COOKIE / APACHE2::COOKIE AVAILABLE FOR MOD_PERL V1 & V2
  • 26. MOD_PERL 1 CONTENT HANDLER - HELLO BOB WITH A::R package Apache::HelloWorld; use Apache::Constants qw(:common); # Export OK use Apache::Request (); # isa Apache sub handler # mod_perl uses handler method unless specified otherwise { my $r = shift; my $apr = Apache::Request->new($r); # Pass Apaches Request object to A::R $apr->send_http_header('text/plain'); my $name = $apr->param(‘name’); # Send HTTP header (similar to CGI's header) $apr->print(quot;Hello $namenquot;); return OK; # read as HTTP status 200 } 1; http://localhost/HelloWorld?name=Bob
  • 27. MOD_PERL 2 CONTENT HANDLER - HELLO WORLD package Apache2::HelloWorld; use Apache2::Const qw(:common); # Export OK sub handler # mod_perl2 uses handler method unless specified otherwise { print quot;Content-type: text/plainnnquot;; # MY EYES!! print quot;Hello Worldnquot;; return OK; # read as HTTP status 200 } 1; PerlModule Apache2::HelloWorld <Location /HelloWorld> SetHandler perl-script PerlResponseHandler Apache2::HelloWorld </Location> http://localhost/HelloWorld/
  • 28. MOD_PERL 2 CONTENT HANDLER - HELLO WORLD REVISED package Apache2::HelloWorld; use Apache2::Const qw(:common); # Export OK sub handler # mod_perl2 uses handler method unless specified otherwise { my $r = shift; # 1st argument is instance of Apache's Request object $r->content_type('text/plain'); # Send HTTP header (similar to CGI's header) $r->print(quot;Hello Worldnquot;); return OK; # read as HTTP status 200 } 1; PerlModule Apache2::HelloWorld <Location /HelloWorld> SetHandler perl-script PerlResponseHandler Apache2::HelloWorld </Location> http://localhost/HelloWorld/
  • 29. MOD_PERL 2 CONTENT HANDLER - HELLO BOB WITH A2::R package Apache2::HelloBob; use Apache2::Const qw(:common); # Export OK use Apache2::Request (); # isa Apache sub handler # mod_perl uses handler method unless specified otherwise { my $r = shift; my $apr = Apache2::Request->new($r); # Pass Apaches Request object to A2::R $apr->send_http_header('text/plain'); my $name = $apr->param(‘name’); # Send HTTP header (similar to CGI's header) $apr->print(quot;Hello $namenquot;); return OK; # read as HTTP status 200 } 1; http://localhost/HelloWorld?name=Bob

Notes de l'éditeur