Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

lwp::protocol::psgi(3pm) [debian man page]

LWP::Protocol::PSGI(3pm)				User Contributed Perl Documentation				  LWP::Protocol::PSGI(3pm)

NAME
LWP::Protocol::PSGI - Override LWP's HTTP/HTTPS backend with your own PSGI applciation SYNOPSIS
use 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" DESCRIPTION
LWP::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 runs METHODS
register 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. AUTHOR
Tatsuhiko Miyagawa <miyagawa@bulknews.net> COPYRIGHT
Copyright 2011- Tatsuhiko Miyagawa LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Plack::Client LWP::UserAgent perl v5.12.3 2011-05-12 LWP::Protocol::PSGI(3pm)

Check Out this Related Man Page

Catalyst::Engine::PSGI(3pm)				User Contributed Perl Documentation			       Catalyst::Engine::PSGI(3pm)

NAME
Catalyst::Engine::PSGI - PSGI engine for Catalyst SYNOPSIS
# app.psgi use strict; use MyApp; MyApp->setup_engine('PSGI'); my $app = sub { MyApp->run(@_) }; DESCRIPTION
Catalyst::Engine::PSGI is a Catalyst Engine that adapts Catalyst into the PSGI gateway protocol. COMPATIBILITY
o Currently this engine works with Catalyst 5.8 (Catamoose) or newer. o Your application is supposed to work with any PSGI servers without any code modifications, but if your application uses "$c->res->write" to do streaming write, this engine will buffer the output until your app finishes. To do real streaming with this engine, you should implement an IO::Handle-like object that responds to "getline" method that returns chunk or undef when done, and set that object to "$c->res->body". Alternatively, it is possible to set the body to a code reference, which will be used to stream content as documented in the PSGI spec. o When your application runs behind the frontend proxy like nginx or lighttpd, this Catalyst engine doesn't automatically recognize the incoming headers like "X-Forwarded-For", because respecting these headers by default causes a potential security issue. You have to enable Plack::Middleware::ReverseProxy or Plack::Middleware::ForwardedHeaders to automatically promote those forwarded headers into "REMOTE_ADDR" hence IP address of the request. ReverseProxy middleware is pretty simple and has no configuration while ForwardedHeaders allows you to configure which upstream host to trust, etc. AUTHOR
Tatsuhiko Miyagawa <miyagawa@bulknews.net> Most of the code is taken and modified from Catalyst::Engine::CGI. LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Catalyst::Engine PSGI Plack perl v5.12.3 2011-06-11 Catalyst::Engine::PSGI(3pm)
Man Page