develooper Front page | perl.libwww | Postings from April 2001

URI handling of "//" as base_uri

Thread Next
Ben Scott
April 18, 2001 16:02
URI handling of "//" as base_uri
Message ID:
I'm working on some scripts to change URLs to "akamized" ARLs.  The site
I'm working on has a number of files which are are used in both http and
https.  The suggestion by Akamai on how to handle this is to leave off the
scheme portion of the URL, making it:
<a href="//">
instead of
<a href="">

This allows the browser to decide from the calling context whether to 
use http or https.  This is indeed part of the URI RFC (RFC2396).
Unfortunately the following does not work:

  use URI;
  $url = "images/foo.gif";
  $base = "//";
  $arl = URI->new_abs($url,$base);

This results in the following error:

Warning: Use of "require" without parens is ambiguous at (eval 21) line 1, <IN> chunk 43.
        eval 'requireURI:://a248_Oe_Oakamai_Onet/.../
;' called at /usr/local/lib/perl5/site_perl/5.005/ line 116
        URI::implementor('//') called at /usr/local/lib/perl5/site_perl/5.005/ line 53
        URI::new('URI', 'images/foo.gif', '//') called at /usr/local/lib/perl5/site_perl/5.005/ line 65
        URI::new_abs('URI', '/images/foo.gif', '//') called at line 170

Ben Scott					    Office (408)894-6807
Comptroller of His Majesty's Fireworks as well as for War as for Triumph

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About