Some people say that perl's OO is far too easy to circumvent. I say phooey.
Here's a recent email discussion with a colleague:
> > I want to use the HTTP parsing bit of HTTP::Daemon using > > STDIN instead of a client socket. > > OK, try this, it *might* just work...: > > use IO::Handle; > use HTTP::Daemon; > @HTTP::Daemon::ClientConn::ISA = ('IO::Handle'); > my $daemon = IO::Handle->new(); > $daemon->fdopen(fileno(STDIN), "r"); > bless($daemon, 'HTTP::Daemon::ClientConn'); > > my $req = $daemon->get_request();Et voila! An SSL enabled HTTP server in pure perl in a few lines of code, all thanks to being able to hack @ISA.
It almosts works :)
[arnaud@arnaud-dev arnaud]$ perl http.pl GET /something Can't call method "url" on an undefined value at /usr/lib/perl5/site_perl/5.005/HTTP/Daemon.pm line 270.
get_requests uses ${*$self}{'httpd_daemon'} which is set in HTTP::Daemon->accept. It seems to be an HTTP::Daemon object..
I haven't fully understood why yet, but adding ${*$daemon}{'httpd_daemon'} = HTTP::Daemon->new; after bless() seems to work :)
[arnaud@arnaud-dev arnaud]$ perl http.pl GET /something GET /something
(I added print $req->method and uri)
Cool! I can now pipe http requests from stunnel into an RPC::XML perl script :)
This is made even more twisted by the fact that I'm doing the same thing within RPC::XML::Server when the user opts for Net::Server over HTTP::Daemon. Unfortunately, I still have to load the latter, since I don't want to re-write the HTTP header-parsing code Gisle has already done. I'd love to have that part in a separately-loadable chunk.
You know, in theory you should be able to use SSL sockets with my module directly, but I think I have an as-yet-unapplied patch somewhere that the server class needs...