You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Harald Becker <ha...@webscope.de> on 2003/07/15 00:08:25 UTC
Access to %udat in epocgi.pl
Hi list,
I want to compress the output of the calculated page with gzip. I
changed the epocgi.pl with a few lines. There is no problem to compress
the output, But I also want to use the cookie session handling and I
cannot find a solution. Can I access the embperl cookie header or how
can I access the %udat to get the _session_id in epocgi.pl?
Which module exports the %udat hash ?
Or can I get the udat hash ref in Execute like the output string ?
One hint that I found in the mail-archive does not work:
%Embperl::Object::component -> param -> udat;
Thanks for any suggestion,
Harald Becker
I'm using Embperl 2.09.
Here is the changed epocgi.pl
use Embperl;
use Embperl::Object;
my $rc = Embperl::Object::Execute ({ output => \$out }) ;
if ($ENV{"HTTP_ACCEPT_ENCODING"} =~ m/gzip/i) {
require Compress::Zlib;
my $gzip = Compress::Zlib::memGzip($out);
my $len = length $gzip;
binmode STDOUT;
print <<EOF;
Accept-Ranges: bytes
Content-length: $len
Content-Encoding: gzip
Content-type: text/html
$gzip
EOF
} else {
print <<EOF;
Content-type: text/html
$out
EOF
}
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Access to %udat in epocgi.pl
Posted by Gerald Richter <ri...@ecos.de>.
>I think Emberpl parse the cookie in a wrong way not /E=(.*?);/. It only
>takes the last cookie var entry, that is EMBPERL_UID=...
Looks to me like you set the cookie name to late. If you do it in Perl, make
sure it's inside a BEGIN {} block
>Is there a trick to reset the cookie entry, so I can get rid of unused
>cookie entries ?
The only thing you can do is delete the session at all e.g. tied(%udat) ->
delete
>Or must I do it in two steps (sent page with cookie expires yesterday
>and reload page and sent correct cookie entry) ?
That#s the other possibilty
Gerald
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
RE: Access to %udat in epocgi.pl
Posted by Harald Becker <ha...@webscope.de>.
> The problem is that when you come back from
> Embperl::Object::Execute %udat is already gone (saved to
> session store). The only idea I have at the moment, in case
> you need read only access, is to put the content you need in
> some global inside your base template:
>
> $Session::myvar = $udat{myvar} ;
>
> and use that global in you epocgi.pl. (note to put it in a
> separete namespace to avoid auto cleanup)
>
Thank you. It works now.
But I've found some possible misbehave with the cookie management in
Embperl.
I've sent the cookie string myself and made a mistake (Set-Cookie: E:xxx
instead of E=xxx)
If I use the original epocgi.pl and set EMBPERL_COOKIE_NAME to 'E' the
%ENV entry for HTTP_COOKIE is
"HTTP_COOKIE" => E:375afe2130e5741a270b95ef27377d2d;
E=ea2251e45914b9af09a0e4b65837024a;
EMBPERL_UID=4133d8db9443d581db8f706c8c5a6831
There are three session ids (thats ok), but Embperl cannot not extract
the session id for 'E' (the cookie management generates new session ids
every time I reload the page). It works fine if I not set the
EMBPERL_COOKIE_NAME.
I think Emberpl parse the cookie in a wrong way not /E=(.*?);/. It only
takes the last cookie var entry, that is EMBPERL_UID=...
Is there a trick to reset the cookie entry, so I can get rid of unused
cookie entries ?
Or must I do it in two steps (sent page with cookie expires yesterday
and reload page and sent correct cookie entry) ?
Harald
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Access to %udat in epocgi.pl
Posted by Gerald Richter <ri...@ecos.de>.
Hi,
>I want to compress the output of the calculated page with gzip. I
>changed the epocgi.pl with a few lines. There is no problem to compress
>the output, But I also want to use the cookie session handling and I
>cannot find a solution. Can I access the embperl cookie header or how
>can I access the %udat to get the _session_id in epocgi.pl?
The problem is that when you come back from Embperl::Object::Execute %udat
is already gone (saved to session store). The only idea I have at the
moment, in case you need read only access, is to put the content you need in
some global inside your base template:
$Session::myvar = $udat{myvar} ;
and use that global in you epocgi.pl. (note to put it in a separete
namespace to avoid auto cleanup)
Gerald
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org