Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Matts (1087)

  (email not shown publicly)

I work for MessageLabs [] in Toronto, ON, Canada. I write spam filters, MTA software, high performance network software, string matching algorithms, and other cool stuff mostly in Perl and C.

Journal of Matts (1087)

Tuesday June 17, 2003
05:02 AM

non-strict OO

[ #12896 ]

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();
It almosts works :)
[arnaud@arnaud-dev arnaud]$ perl
GET /something
Can't call method "url" on an undefined value at
/usr/lib/perl5/site_perl/5.005/HTTP/ 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
GET /something
(I added print $req->method and uri)
Cool! I can now pipe http requests from stunnel into an
RPC::XML perl script :)

Et voila! An SSL enabled HTTP server in pure perl in a few lines of code, all thanks to being able to hack @ISA.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Egads... (Score:3, Insightful)

    by rjray (1649) on 2003.06.17 20:47 (#21179) Homepage Journal

    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...