This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.
To: "modperl@apache.org" <modperl@apache.org> From: Rasoul Hajikhani <rasoul@rhythm.com> Subject: can not set param Date: Tue, 29 Jan 2002 15:07:43 -0800 Folks, The apache::Request docs indicate that param can be used to set the query string. However, it fails when I do something like this: my $r = Apache::Request->new(shift); ... my $host = $r->hostname; my $uri = $r->uri; my $params = $r->parsed_uri->query; # does not seem to work!? my $scheme = $r->parsed_uri->scheme || 'https'; $r->param('previous_uri' => "$scheme://$host$uri"); $r->param('q_string' => $params) if ($params); $r->header_out(Location => "http://$host/login"); $r->status(REDIRECT); $r->send_http_header; return OK; Can someone tell me why this is failing? I can not get previous_uri or q_string in my login module. Also, $r->parsed_uri->scheme does not return anything back. === To: Rasoul Hajikhani <rasoul@rhythm.com> From: clayton cottingham <drfrog@telus.net> Subject: Re: can not set param Date: Tue, 29 Jan 2002 15:11:32 -0800 Rasoul Hajikhani wrote: > > Folks, > The apache::Request docs indicate that param can be used to set the > query string. However, > it fails when I do something like this: > > my $r = Apache::Request->new(shift); > ... > my $host = $r->hostname; > my $uri = $r->uri; > my $params = $r->parsed_uri->query; > # does not seem to work!? > my $scheme = $r->parsed_uri->scheme || 'https'; > $r->param('previous_uri' => "$scheme://$host$uri"); > $r->param('q_string' => $params) if ($params); > $r->header_out(Location => "http://$host/login"); > $r->status(REDIRECT); > $r->send_http_header; > return OK; > > Can someone tell me why this is failing? I can not get previous_uri or > q_string in my login module. > > Also, $r->parsed_uri->scheme does not return anything back. > > Thanks in advance. > -r why not use $r->args ?? my %args = $r->args; then just have to call your queries like $args{Members_id_ext} === To: Robert Landrum <rlandrum@capitoladvantage.com>, From: Rasoul Hajikhani <rasoul@rhythm.com> Subject: Re: can not set param Date: Tue, 29 Jan 2002 15:26:51 -0800 Robert Landrum wrote: > > >Folks, > >The apache::Request docs indicate that param can be used to set the > >query string. However, > >it fails when I do something like this: > > > > my $r = Apache::Request->new(shift); > > I'm guessing that the original reference isn't being preserved. > > Try > > my $save = shift; > my $r = Apache::Request->new($save); > Makes no difference... Still param or args does not set the query string parameters. > Just as a side note, I never dump these two together... I always > keep a seperate $r and $apr, but that's just me. === To: Rasoul Hajikhani <rasoul@rhythm.com> From: Geoffrey Young <geoff@modperlcookbook.org> Subject: Re: can not set param Date: Tue, 29 Jan 2002 19:07:26 -0500 Rasoul Hajikhani wrote: > Folks, > The apache::Request docs indicate that param can be used to set the > query string. However, > it fails when I do something like this: > > my $r = Apache::Request->new(shift); > ... > my $host = $r->hostname; > my $uri = $r->uri; > my $params = $r->parsed_uri->query; > # does not seem to work!? > my $scheme = $r->parsed_uri->scheme || 'https'; > $r->param('previous_uri' => "$scheme://$host$uri"); > $r->param('q_string' => $params) if ($params); > $r->header_out(Location => "http://$host/login"); > $r->status(REDIRECT); > $r->send_http_header; > return OK; > > Can someone tell me why this is failing? I can not get previous_uri or > q_string in my login module. the way you are thinking about it is fundamentally wrong - $r is the _current_ request object, so setting $r->param sets query string arguments for the current request only. you need to look into the Apache::URI module, which can be used to create properly formed URI strings. > > Also, $r->parsed_uri->scheme does not return anything back. it won't - to create a self-referential URI use Apache::URI->parse($r) === To: Geoffrey Young <geoff@modperlcookbook.org> From: Rasoul Hajikhani <rasoul@rhythm.com> Subject: Re: can not set param Date: Tue, 29 Jan 2002 17:10:53 -0800 Geoffrey Young wrote: > > Rasoul Hajikhani wrote: > > > Folks, > > The apache::Request docs indicate that param can be used to set the > > query string. However, > > it fails when I do something like this: > > > > my $r = Apache::Request->new(shift); > > ... > > my $host = $r->hostname; > > my $uri = $r->uri; > > my $params = $r->parsed_uri->query; > > # does not seem to work!? > > my $scheme = $r->parsed_uri->scheme || 'https'; > > $r->param('previous_uri' => "$scheme://$host$uri"); > > $r->param('q_string' => $params) if ($params); > > $r->header_out(Location => "http://$host/login"); > > $r->status(REDIRECT); > > $r->send_http_header; > > return OK; > > > > Can someone tell me why this is failing? I can not get previous_uri or > > q_string in my login module. > > the way you are thinking about it is fundamentally wrong - $r is the > _current_ request object, so setting $r->param sets query string > arguments for the current request only. > > you need to look into the Apache::URI module, which can be used to > create unless ($c->{userId} && $c->{user}) { my $p_uri = $r->parsed_uri; my $string = "previous_uri=" . $r->uri . ($r->args() ? "?" . $r->args() : undef); $p_uri->query($string); return FORBIDDEN; } This still fails to resolve the problem. Unless of course I am not using the right method. -r ===