Re: concerns about adding new url schemes in URI::URL

Tim Bunce (Tim.Bunce@ig.co.uk)
Fri, 7 Apr 1995 23:03:06 +0100


> From: Andrew Wilcox <awilcox@world.std.com>
> 
I've CC'd this to libwww-perl because they 'own' URI::URL more than the
CGI-perl list does.

> In URI::URL, there's a neat hack where you can create a new URL scheme
> (the scheme is the "http:", "ftp:", etc. part of the URL) by adding a
> "scheme.pm" module to your URL library directory.  I was going to
> offer to fix up the code that does this (a misspelled scheme yields a
> "can't locate ... in @INC" error at the moment), but as I think about
> it I'm not sure that it's a good idea.
> 
> With most modules I get to decide what I want loaded by saying
> "use ...;".  I can put half-completed or buggy modules in my Perl library
> directory without having my other programs change behaviour unless
> they explicitly use them.
> 
> It also makes compiling happen at the wrong time.  If I get a compile
> error, I should get it when I start the program, not in response to
> user input.
> 
> While schemes are probably too simple to be usefully subclassed,
> subclassing is something to think about in connection with other
> modules that might try the same auto-require idea.  It doesn't look
> like you can subclass schemes because they always get looked up under
> "URI::URL::scheme".
> 
> My preference would be for schemes to register themselves with
> URI::URL.  I'll volunteer to implement this if there are no
> objections.
> 
Personally I don't see much need for the auto-loading at all.

I left it in at a time when we were still debating if URL should
provide transport services. It's now agreed that it should not.
That just leaves parsing - not a big job.

I'd rather see URI::URL simply 'completed' with code to parse the
other schemes.

I think the next version of URI::URL should have the auto-loading
code removed.

To implement a new scheme in an external module all you need to
is write it as 'package URI::URL::<scheme>;' and load the module
yourself.

As URI::URL is currently still in my hands (since I've not seen
Martijn release it) I'll make a few changes that might suit your
needs. Stay tuned.

> -Andrew
> 
Regards,
Tim.