Query: lwp::protocol::psgi
OS: debian
Section: 3pm
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
LWP::Protocol::PSGI(3pm) User Contributed Perl Documentation LWP::Protocol::PSGI(3pm)NAMELWP::Protocol::PSGI - Override LWP's HTTP/HTTPS backend with your own PSGI applciationSYNOPSISuse LWP::UserAgent; use LWP::Protocol::PSGI; # can be Mojolicious, Catalyst ... any PSGI application my $psgi_app = do { use Dancer; setting apphandler => 'PSGI'; get '/search' => sub { return 'googling ' . params->{q}; }; dance; }; LWP::Protocol::PSGI->register($psgi_app); # can hijack any code or module that uses LWP::UserAgent underneath, with no changes my $ua = LWP::UserAgent->new; my $res = $ua->get("http://www.google.com/search?q=bar"); print $res->content; # "googling bar"DESCRIPTIONLWP::Protocol::PSGI is a module to hijack any code that uses LWP::UserAgent underneath such that any HTTP or HTTPS requests can be routed to your own PSGI application. Because it works with any code that uses LWP, you can override various WWW::*, Net::* or WebService::* modules such as WWW::Mechanize, without modifying the calling code or its internals. use WWW::Mechanize; use LWP::Protocol::PSGI; LWP::Protocol::PSGI->register($my_psgi_app); my $mech = WWW::Mechanize->new; $mech->get("http://amazon.com/"); # $my_psgi_app runsMETHODSregister LWP::Protocol::PSGI->register($app); my $guard = LWP::Protocol::PSGI->register($app); Registers an override hook to hijack HTTP requests. If called in a non-void context, returns a Guard object that automatically resets the override when it goes out of context. { my $guard = LWP::Protocol::PSGI->register($app); # hijack the code using LWP with $app } # now LWP uses the original HTTP implementations unregister LWP::Protocol::PSGI->unregister; Resets all the overrides for LWP. If you use the guard interface described above, it will be automatically called for you.AUTHORTatsuhiko Miyagawa <miyagawa@bulknews.net>COPYRIGHTCopyright 2011- Tatsuhiko MiyagawaLICENSEThis library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.SEE ALSOPlack::Client LWP::UserAgent perl v5.12.3 2011-05-12 LWP::Protocol::PSGI(3pm)
Related Man Pages |
---|
lwp::protocol(3) - centos |
lwp::protocol::ldap(3) - mojave |
lwp::protocol::ldap(3) - osx |
catalyst::engine::psgi(3pm) - debian |
lwp::authen::wsse(3pm) - debian |
Similar Topics in the Unix Linux Community |
---|
twitter-cmdline 1.02 (Default branch) |
Networking |
Login using perl LWP module |
Help with file manipulation script |
Hrd in AIX 7.1 - what's it good for ? |