You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Ruslan U. Zakirov" <cu...@wildgate.miee.ru> on 2004/11/04 18:19:51 UTC

[mp2] API questions.

		Hello.
1) I can't find how to get string that represent initial request 
location. I mean 'http://www.example.com/foo...'. Is it possible? Now, I 
use next code as workaround:
       my $location = $r->dir_config( 'ServerName' );
       unless( $location ) {
          $location = 'http://'. join ':', $r->get_server_name, 
$r->get_server_port;
       }

2) Can I get name of the current mod_perl hook. My module works well as 
PerlTransHandler or other that executes later, but should return OK if 
it's translating handler and DECLINED in other cases. I wish to write 
something like next code:
   if( $r->foo_method eq 'PerlTransHandler' ) {
     return OK;
   } else {
     return DECLINED
   }

3) I have two configuration variables in httpd.conf:
  PerlSetVar StorageRoot /mnt/local/storage/music/
  PerlSetVar BaseLocation /download
Can I declare 'Alias BaseLocation StorageRoot' with mod_perl API?
Without this alias Apache can't find file and I don't want to force user 
to input same strings twice.

				Best regards. Ruslan.

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [mp2] API questions.

Posted by "Ruslan U. Zakirov" <cu...@wildgate.miee.ru>.
THanks.
All suggestions works well.

Stas Bekman wrote:
> Ruslan U. Zakirov wrote:
> 
>>         Hello.
>> 1) I can't find how to get string that represent initial request 
>> location. I mean 'http://www.example.com/foo...'. Is it possible? Now, 
>> I use next code as workaround:
>>       my $location = $r->dir_config( 'ServerName' );
>>       unless( $location ) {
>>          $location = 'http://'. join ':', $r->get_server_name, 
>> $r->get_server_port;
>>       }
> 
> 
> better:
> 
>         $location = 'http://' . $r->construct_server;
> 
> http://perl.apache.org/docs/2.0/api/Apache/URI.html#C_construct_server_
> 
> but your code doesn't include the URI.
> 
>        my $uri = $r->parsed_uri->unparse;
> 
> But really what you are after is: $r->construct_url();
> http://perl.apache.org/docs/2.0/api/Apache/URI.html#C_construct_url_
> 
>> 2) Can I get name of the current mod_perl hook. My module works well 
>> as PerlTransHandler or other that executes later, but should return OK 
>> if it's translating handler and DECLINED in other cases. I wish to 
>> write something like next code:
>>   if( $r->foo_method eq 'PerlTransHandler' ) {
>>     return OK;
>>   } else {
>>     return DECLINED
>>   }
> 
> 
>   my $callback = ModPerl::Util::current_callback();
> http://perl.apache.org/docs/2.0/api/ModPerl/Util.html#C_current_callback_
> 
>> 3) I have two configuration variables in httpd.conf:
>>  PerlSetVar StorageRoot /mnt/local/storage/music/
>>  PerlSetVar BaseLocation /download
>> Can I declare 'Alias BaseLocation StorageRoot' with mod_perl API?
>> Without this alias Apache can't find file and I don't want to force 
>> user to input same strings twice.
> 
> 
> There is no direct API (is there a C API for that? if there is we can 
> add the perl glue), but you can always push httpd.conf text with:
> $r->add_config()
> http://perl.apache.org/docs/2.0/api/Apache/RequestUtil.html#C_add_config_
> or $s->add_config()
> http://perl.apache.org/docs/2.0/api/Apache/ServerUtil.html#C_add_config_
> 
> 


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [mp2] API questions.

Posted by Stas Bekman <st...@stason.org>.
Ruslan U. Zakirov wrote:
>         Hello.
> 1) I can't find how to get string that represent initial request 
> location. I mean 'http://www.example.com/foo...'. Is it possible? Now, I 
> use next code as workaround:
>       my $location = $r->dir_config( 'ServerName' );
>       unless( $location ) {
>          $location = 'http://'. join ':', $r->get_server_name, 
> $r->get_server_port;
>       }

better:

         $location = 'http://' . $r->construct_server;

http://perl.apache.org/docs/2.0/api/Apache/URI.html#C_construct_server_

but your code doesn't include the URI.

        my $uri = $r->parsed_uri->unparse;

But really what you are after is: $r->construct_url();
http://perl.apache.org/docs/2.0/api/Apache/URI.html#C_construct_url_

> 2) Can I get name of the current mod_perl hook. My module works well as 
> PerlTransHandler or other that executes later, but should return OK if 
> it's translating handler and DECLINED in other cases. I wish to write 
> something like next code:
>   if( $r->foo_method eq 'PerlTransHandler' ) {
>     return OK;
>   } else {
>     return DECLINED
>   }

   my $callback = ModPerl::Util::current_callback();
http://perl.apache.org/docs/2.0/api/ModPerl/Util.html#C_current_callback_

> 3) I have two configuration variables in httpd.conf:
>  PerlSetVar StorageRoot /mnt/local/storage/music/
>  PerlSetVar BaseLocation /download
> Can I declare 'Alias BaseLocation StorageRoot' with mod_perl API?
> Without this alias Apache can't find file and I don't want to force user 
> to input same strings twice.

There is no direct API (is there a C API for that? if there is we can add 
the perl glue), but you can always push httpd.conf text with:
$r->add_config()
http://perl.apache.org/docs/2.0/api/Apache/RequestUtil.html#C_add_config_
or $s->add_config()
http://perl.apache.org/docs/2.0/api/Apache/ServerUtil.html#C_add_config_


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

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html