Enrico Sorcinelli wrote:
[...]
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.

why?


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 :-)

It'd be great if you could write one. That's what I do, every time I need something to be done and it's not documented, I go and figure out how this should be done and then I document it.


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);
---

What's eval {} is for? I think do {} is more intuitive here, as you aren't expecting any of these calls to fail. Also


my $uri = eval { $uri = };

doesn't read too well. This is probably a bit more clean:

my $uri = MP2
    ? do { $r->parse_uri($r->construct_url); $r->parsed_uri }
    : Apache::URI->parse($r);

I agree, that it's far from beinig as simple as Apache::URI->parse($r) in mp1. May be we should provide a wrapper which does the above do {} block.

Byt really you want to use Apache::URI::parse_uri only for its side effects:

from httpd-2.0/include/http_protocol.h:

/**
 * parse_uri: break apart the uri
 * @warning Side Effects: <pre>
 *    - sets r->args to rest after '?' (or NULL if no '?')
 *    - sets r->uri to request uri (without r->args part)
 *    - sets r->hostname (if not set already) from request (scheme://host:port)
 * </pre>
 * @param r The current request
 * @param uri The uri to break apart
 * @deffunc void ap_parse_uri(request_rec *r, const char *uri)
 */
AP_CORE_DECLARE(void) ap_parse_uri(request_rec *r, const char *uri);

If you don't need any of these you are probably better off with your original scheme:

my $uri = MP2 ? APR::URI->parse($r->pool, $r->construct_url) : 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? :-)

No, it's just that the XSUB hostinfo() lives in APR::URI's .so and not Apache::URI's one. So yes, you need to load that module before you can use its method.


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


-- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html



Reply via email to