On Mon, 08 Dec 2003 10:37:51 -0800 Stas Bekman <[EMAIL PROTECTED]> wrote:
Hi, > Enrico Sorcinelli wrote: > > Hi all, > > I'm porting to mp2 this mp1 code: > > > > use Apache::URI; > > my $uri = Apache::URI->parse($r); > > # now I can work with $uri->hostinfo, $uri->scheme, etc > > > > In mp2, 'parse' method has moved from Apache::URI to APR::URI. > > Moreover the method syntax is changed: > > > > APR::URI->parse($r->pool,$uri); > > > > Because I need 'hostinfo' and 'scheme' methods, I must pass a complete url > > to APR::UR->parse (in mp1 this wasn't necessary). > > Since APR::URI is a generic method, not HTTP specific, you need to pass a > complete URI to it. > > There is parse_uri in Apache::URI that's HTTP specific, which is probably the > method you are after. See t/response/TestAPI/uri.pm in the mp2 source. > > > So I've used APR::URI->parse($r->pool,$r->construct_url) ad docs > > explains. However I also must require Apache::URI (maybe the doc can be > > updated?). > > You need to load Apache::URI for $r->construct_url, not for APR::URI->parse. Of course :-) > So the docs need not to be updated for this issue, though I'm sure others > issues could be documented and improved. e.g. APR::URI::parse vs. > Apache::URI::parse_uri. Thanks for the mp2 source help. I've read but it seems the the use of $r->construct_url is alway necessary for me. >From my point of view, the problem is that I don't know all the mp2 code and I haven't found a specific doc about Apache::URI in mp2 docs :-) So by using Apache::URI's parse_uri instead of APR::URI's parse, the code becomes little more complicated: --- use Apache::URI; my $uri = MP2 ? eval {$r->parse_uri($r->construct_url); $uri = $r->parsed_uri} : Apache::URI->parse($r); --- However, when I attemp to use $uri->hostinfo (or $uri->scheme) I have the error: "Can't locale object method "hostinfo" via package APR::URI" But by requiring APR::URI, all works fine ($uri seems to be an APR::URI object) I'm missing some thing again? :-) Thanks in advance by - Enrico -- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html