perl help

Igor Sysoev is at rambler-co.ru
Fri Feb 6 13:12:50 MSK 2009


On Fri, Feb 06, 2009 at 11:16:02AM +1030, kingsley at internode.com.au wrote:

> Great that mostly helped however
> 
> 
>                        if ($arg_bitstart && $arg_bitstart != 0){
>                                proxy_set_header  Content-Range 
> bytes=$arg_bitstart-;
>                                proxy_set_header  Range 
> bytes=$arg_bitstart-;
>                        }
> 
> I get this error
> 
> 2009/02/06 11:12:38 [emerg] 31739#0: invalid condition "$arg_bitstart" in 
> /etc/nginx/nginx.conf:111
> 2009/02/06 11:12:38 [emerg] 31739#0: the configuration file 
> /etc/nginx/nginx.conf test failed

nginx curerently does not support "&&", etc inside "if".

However, in this case

       if ($arg_bitstart) {

is enough as both "" and "0" are false.
The more stronger test is:

       if ($arg_bitstart ~ [1-9]\d+) {

> Kingsley
> 
> 
> --------------------------------------------------
> From: "Igor Sysoev" <is at rambler-co.ru>
> Sent: Thursday, February 05, 2009 5:50 PM
> To: <nginx at sysoev.ru>
> Subject: Re: perl help
> 
> >On Thu, Feb 05, 2009 at 03:56:43PM +1030, Kingsley Foreman wrote:
> >
> >>Hi guys,
> >>
> >>I just need a quick hand with a rewrite rule im have issues with
> >>
> >>i need to have a url like so
> >>http://blah.com/text.php?bitstart=21000
> >>
> >>i need to use the bitstart=21200
> >>and using that to add the header
> >>Content-Range: 21200
> >>to a request before handing it of to a proxied site.
> >>
> >>Of all things im having trouble getting bitstart=21200, in perl  to use 
> >>it.
> >
> >If you use 0.7.x:
> >
> >       proxy_set_header  Content-Range  $arg_bitstart;
> >
> >Other way is defining perl variable handler:
> >
> >http {
> >
> >   perl_set  $content_range '
> >       sub {
> >           my $r = shift;
> >           my $a = $r->args;
> >           if ($a =~ /bitstart=(\d+)/) {
> >               return $1;
> >           }
> >           return "";
> >      }';
> >
> >      ...
> >
> >          proxy_set_header  Content-Range  $content_range;
> >
> >
> >-- 
> >Igor Sysoev
> >http://sysoev.ru/en/
> >
> >

-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list