Re: cookies and IE
On Tue, Oct 01, 2002 at 07:23:39PM -0400, Kee Hinckley wrote: At 11:30 AM -0700 10/1/02, Alan wrote: Hi folks... I'm having a bit of a weird problem with Apache::Cookie and IE. I'm setting a cookie and then doing a redirect as follows: This must come up once every few months. I'd complain about that fact, but the irony is that just last week I couldn't figure out why a new site I was working on wasn't setting cookies in IE and I'd done the same thing I'd read about a dozen times. IE doesn't reliably set cookies on a refresh. I believe the only solution is to rearchitect the site. Interesting... on the several browsers/OSs I had it tested on it seemed to work. Anyway, if this is such a common question, who do you talk to to get it stuck in the perl.apache.org page about cookies? :) alan -- Alan Arcterex [EMAIL PROTECTED] -=][=- http://arcterex.net I used to herd dairy cows. Now I herd lusers. Apart from the isolation, I think I preferred the cows. They were better conversation, easier to milk, and if they annoyed me enough, I could shoot them and eat them. -Rodger Donaldson
Re: cookies and IE
Hi Alan, I guess your mistake is to send the refresh header as http header. You should use a meta tag in html or redirect in http. Sven. On Tue, 1 Oct 2002, Alan wrote: Hi folks... I'm having a bit of a weird problem with Apache::Cookie and IE. I'm setting a cookie and then doing a redirect as follows: my $c = Apache::Cookie-new( $r, -name = 'userdata', -value = $cookie, -expires = '1d', -path = '/dealers' ); $r-content_type('text/html'); $c-bake; $r-header_out(Refresh=0;url=/dealers$request_uri); $r-no_cache(1); $r-send_http_header; $r-print( print_refresh_page_content() ); (print_refresh_page_content() just returns a string of authenticated) After the authenticated message is printed it should refresh back to the /dealers/ URL, except this time the handler will see there is a cookie and print out the real data, not a username/pass prompt. This works *perfectly* in mozilla linux, galeon, mozilla windows, and ie6 under windows XP. It *doesn't* work on ie 6 under win98, winME, or ie 5.5 run through crossover office. It displays the authenticated page, but then refreshes back to the login page. No cookie is set, but debug when setting the cookie shows the following: Set-Cookie=userdata=[data]; path=/dealers; expires=1d at /home/alan/code/rubberoven/mod_perl/Rubberoven/Dealer.pm line 139. Refresh=0;url=/dealers/ at /home/alan/code/rubberoven/mod_perl/Rubberoven/Dealer.pm line 139. Pragma=no-cache at /home/alan/code/rubberoven/mod_perl/Rubberoven/Dealer.pm line 139. Cache-control=no-cache at /home/alan/code/rubberoven/mod_perl/Rubberoven/Dealer.pm line 139. Connection=close at /home/alan/code/rubberoven/mod_perl/Rubberoven/Dealer.pm line 139. Content-Type=text/html at /home/alan/code/rubberoven/mod_perl/Rubberoven/Dealer.pm line 139. Expires=Tue, 01 Oct 2002 18:30:31 GMT at /home/alan/code/rubberoven/mod_perl/Rubberoven/Dealer.pm line 139. This is the same that is printed out when a working browser gets cookies set. I've played around with the security settings, and even at the lowest setting, with IE set to prompt for any cookies, it won't even acknowledge that I'm trying to set a cookie. Anyone have any ideas/solutions/thoughts? -- Sven Geislere-mail: [EMAIL PROTECTED] Senior Developertel:(+49 30) 53 62 16 27
default-handler ignored if url points to a directory
Hi on win32 perl 561 with last modperl when a location is reset to default-handler and no real file is called but just a directory, modperl does not pass on to default (and to mod_dir for indexing of the directory). url /stylesheets/style.css triggers the default handler properly, but not /stylesheets/ alone for instance. url/telechargements/some.html also , but /telechargements/ does not trigger default and no mod_dir as well can anyone explain why ? thanks pascal here is my conf, there is no virtual host %Location = ( '/' = { 'PerlHandler' = 'MY::Stat', 'Options' = '+ExecCGI', 'SetHandler' = 'perl-script' }, '/telechargements/' = { 'SetHandler' = 'default-handler' }, '/stylesheets/' = { 'SetHandler' = 'default-handler' }, '/icons/' = { 'SetHandler' = 'default-handler' }, ); %Directory = ( 'c:/home/_stat3/htdocs' = { 'AllowOverride' = 'None', 'Order' = 'allow,deny', 'Options' = 'Indexes', 'Allow' = 'from all' }, 'c:/home/_stat3/telechargements' = { 'AllowOverride' = 'None', 'Order' = 'allow,deny', 'Options' = 'Indexes Multiviews', 'Allow' = 'from all' }, 'c:/home/_stat3/icons' = { 'AllowOverride' = 'None', 'Order' = 'allow,deny', 'Options' = 'Indexes Multiviews', 'Allow' = 'from all' } ); #arrays: Alias = ( [ '/stylesheets/', 'c:/home/_stat3/stylesheets/' ], [ '/icons/', 'c:/home/_stat3/icons/' ], [ '/telechargements/', 'c:/home/_stat3/telechargements/' ] ); #scalars: $DocumentRoot = 'c:/home/_stat3/htdocs'; $Port = 8080; $PerlInitHandler = 'Apache::Reload'; $CustomLog = 'c:/home/_stat3/access.log common'; $ErrorLog = 'c:/home/_stat3/error.log'; Accédez au courrier électronique de La Poste : www.laposte.net ; 3615 LAPOSTENET (0,13 /mn) ; tél : 08 92 68 13 50 (0,34/mn)
Re: cookies and IE
At 09:02 02.10.2002, Alan wrote: On Tue, Oct 01, 2002 at 07:23:39PM -0400, Kee Hinckley wrote: At 11:30 AM -0700 10/1/02, Alan wrote: Hi folks... I'm having a bit of a weird problem with Apache::Cookie and IE. I'm setting a cookie and then doing a redirect as follows: This must come up once every few months. I'd complain about that fact, but the irony is that just last week I couldn't figure out why a new site I was working on wasn't setting cookies in IE and I'd done the same thing I'd read about a dozen times. IE doesn't reliably set cookies on a refresh. I believe the only solution is to rearchitect the site. Interesting... on the several browsers/OSs I had it tested on it seemed to work. Anyway, if this is such a common question, who do you talk to to get it stuck in the perl.apache.org page about cookies? :) Send some paragraphs detailing this to me (preferably in POD), and it'll be added to the site. -- Per Einar Ellefsen [EMAIL PROTECTED]
Re: cookies and IE
Alan wrote [ 01 October 2002 at 03:09 pm ] On Tue, Oct 01, 2002 at 11:30:59AM -0700, Alan wrote: Turns out the issue was the 'expires' tag... IE wouldn't set the cookie until it was set to '+1d' If setting the expires tag to +1d fixed the problem you may want to look at the time on the machine running IE. I ran into a problem where the clients clock was in the wrong timezone, this of course changed the distance from GMT and caused the cookie to be expired as it was sent. IE did not accept the cookie at all. However once the time was set correctly the cookie worked correctly. -- nicholas l studt [EMAIL PROTECTED]
Re: cookies and IE
On Wed, Oct 02, 2002 at 08:15:23AM -0500, Nicholas Studt wrote: Alan wrote [ 01 October 2002 at 03:09 pm ] On Tue, Oct 01, 2002 at 11:30:59AM -0700, Alan wrote: Turns out the issue was the 'expires' tag... IE wouldn't set the cookie until it was set to '+1d' If setting the expires tag to +1d fixed the problem you may want to look at the time on the machine running IE. I ran into a problem where the clients clock was in the wrong timezone, this of course changed the distance from GMT and caused the cookie to be expired as it was sent. IE did not accept the cookie at all. However once the time was set correctly the cookie worked correctly. Nope... one of the versions of IE that I was running was on the same machine (running through crossover office). Looks like my little problem really had nothing to do with refreshing and setting cookies, but it was actually in the way that parsing works in Apache::Cookie (and CGI/CGI::Cookie). When the expires is set to +3d the cookie is set as follows: Set-Cookie=name=value; path=/path; expires=Sat, 05-Oct-2002 15:10:06 GMT But when it's set to 3d the cookie is set as: Set-Cookie=name=value; path=/path; expires=3d Which makes sense, but it's a very subtle thing IMHO, and to me 1d means expire in one day, the same as +1d. Anything think that this deserves a bug report, or chalk it up to stupid user syndrome? Alan -- Alan Arcterex [EMAIL PROTECTED] -=][=- http://arcterex.net I used to herd dairy cows. Now I herd lusers. Apart from the isolation, I think I preferred the cows. They were better conversation, easier to milk, and if they annoyed me enough, I could shoot them and eat them. -Rodger Donaldson
[BUG] Losing GET/POST-data
Hi! We're developing a perl module for apache/mod_perl, but have encountered a really strange problem. After 'a while' we seem to lose the data sent to the apache-server, at least it never reaches our module. We have absolutely no idea what might be causing this, and we realize it isn't an easy question to ask either, since we have never been able to reproduce the error on command. Sometimes it's there, sometimes not. It seems to come more frequently when the apache has been up and running for quite some time though, so our current 'solution' is to restart the apache every 3rd hour, but this doesn't completely solve the problem either. We have encountered the bug on several versions of both apache and mod_perl, on different os's: Solaris/mod_perl 1.25/apache 1.3.19 Debian/mod_perl 1.26/apache 1.3.23 We have also seen it both in the compiled versions and in the standard distributions. Recently we switched from using the standard Apache request-object to using the Apache::Request one, for the added functionality, but this has not had any effect at all as far as we can tell, and the bug keeps happening... It is possible that it has increased somewhat with increased number of vhosts, but we can't say for sure. Our perl module is 2k+ lines of perl-code, using other self-made modules of another 6k+ lines, + several standard modules, if that is of any help. Everything else seems to be fine, and no error-logs show anything. We have searched plenty on the web, in mailing list archives and such, but have so far never seen it mentioned. Does anyone at all know what this could be? Any pointers at all regarding any possible solution to this problem would be much appreciated. Thanks, Hakan Nilsson [EMAIL PROTECTED] - Hi! I'm a .signature virus! Copy me into your .signature file to help me spread!
Re: [BUG] Losing GET/POST-data
On 02 Oct 2002 15:23 GMT you wrote: Hi! We're developing a perl module for apache/mod_perl, but have encountered a really strange problem. After 'a while' we seem to lose the data sent to the apache-server, at least it never reaches our module. SNIP Recently we switched from using the standard Apache request-object to using the Apache::Request one, for the added functionality, but this has not had any effect at all as far as we can tell, and the bug keeps happening... I ran into a problem that the param parts of a request were flushed when read for the first time... so if you lose them (don't store them) then you cannot access them again. If you are not already, then try $apr = HTTP::Request-instance($r); instead... Here is some code that I use to strip a request down and then store in a hashref for each request. Almost every handler that I use calls this in the first instance. This way $r will remain intact and $r_info is a really handy hashref. sub handler { my $r_info = r_info($r); } sub r_info { my $r = shift; my $s = $r-server; my $c = $r-connection; my $apr = Apache::Request-instance($r); #Parse / Collect the parameters. my %params; foreach ($apr-param) { $params{$_} = $apr-param($_); } my $r_info_headers = [r_headers($r)]-[1]; my $cookies = fetch CGI::Cookie; my %hash; undef %hash; %hash = ( server_name = $r-get_server_name(), server_port = $r-get_server_port(), doc_root = $r-document_root(), path_info =$r-path_info(), method = $r-method(), uri = $r-uri(), params = \%params, protocol = $r-protocol(), server_admin = $s-server_admin(), server_hostname=$s-server_hostname(), remote_ip =$c-remote_ip(), headers = $r_info_headers, cookies = $cookies ); return (\%hash); } sub r_headers { my $r = shift; my (list, $header, headers_list, $value, %headers_hash); list = $r-headers_in; while ($header = shift list) { $value = shift list; push (headers_list, $header); $headers_hash{$header} = $value; } return (\@headers_list, \%headers_hash); }
Easy internal redirect question
I call a page, /my/script1?task=foo which does some things and then needs to redirect to /my/script2?task=bar. However, putting $r-internal_redirect('/my/script2?task=bar'); doesn't seem to work as script2 is seeing task=foo rather than task=bar. Looks like the internal_redirect is also passing along the form params to the second request. How is this avoided? I'm looking through the cookbook recipe on internal redirects but nothing is jumping out at me at the moment. Thanks, Fran
Re: Easy internal redirect question
[EMAIL PROTECTED] wrote: I call a page, /my/script1?task=foo which does some things and then needs to redirect to /my/script2?task=bar. However, putting $r-internal_redirect('/my/script2?task=bar'); doesn't seem to work as script2 is seeing task=foo rather than task=bar. Looks like the internal_redirect is also passing along the form params to the second request. How is this avoided? I'm looking through the cookbook recipe on internal redirects but nothing is jumping out at me at the moment. that's pretty odd. given two scripts, one.pl: shift-internal_redirect('/perl-bin/two.pl?internal=redirect'); return Apache::OK; and two.pl: my $r = shift; $r-send_http_header('text/plain'); print args is , scalar $r-args, \n; I get the right results: $ GET localhost/perl-bin/one.pl?main=request args is internal=redirect are you returning OK right after your internal redirect? does setting $r-args() before calling the internal redirect to a third value change anything? --Geoff
Re: cookies and IE
But when it's set to 3d the cookie is set as: Set-Cookie=name=value; path=/path; expires=3d Which makes sense, but it's a very subtle thing IMHO, and to me 1d means expire in one day, the same as +1d. Anything think that this deserves a bug report, or chalk it up to stupid user syndrome? the logic in apache_request.c seems to indicate that you get options +time, -time, and 'now'. any other formats (such as 1d) get the literal string in the cookie. untested, though :) the Apache::Cookie manpage says it's a CGI::Cookie emulation, where CGI::Cookie says to see CGI.pm for acceptable -expires values, which doesn't say much except illustrate that + and - and 'now' are permissible values. so, it's not really a bug if you dig down into the docs and examples. looks like a feature, though :) I can't think of a reason why you'd want a literal in the expires field, but I don't use cookies all that much, so maybe there are some cases where it's desirable. maybe $cookie should be undef, or the cookie should default to browser-session-only if -expires doesn't follow the standard format? maybe that's a question for [EMAIL PROTECTED] --Geoff
Re: cookies and IE
On Wed, Oct 02, 2002 at 01:21:49PM -0400, Geoffrey Young wrote: so, it's not really a bug if you dig down into the docs and examples. looks like a feature, though :) Agreed... more of a 'gotcha' though, ready to bite people in the butt. Personally I think it might make more sense to do a check to see if the val =~ /(\d+)(h|m|d|M)/ before it's sent off as a literal, but who knows. I'll email someone about it anyway. alan -- Alan Arcterex [EMAIL PROTECTED] -=][=- http://arcterex.net I used to herd dairy cows. Now I herd lusers. Apart from the isolation, I think I preferred the cows. They were better conversation, easier to milk, and if they annoyed me enough, I could shoot them and eat them. -Rodger Donaldson
ProxyRewrite configuration
The problem was solved when I set the Apache Servername parameter to the IP address of the Proxy Server. But I don't understand why the ProxyRewrite module doen't change the URL to what we want. It changes it only to /. Thanks, --- Rodney A. Ramos RODNEY ANTONIO RAMOS RODNEYR 27/09/2002 14:31 Para: [EMAIL PROTECTED] cc: Assunto:ProxyRewrite configuration I'm having problem with the ProxyRewrite configuration. My enviroment is: Internal Site: http://a.a.a.a/site External Site (The proxy server): http://b.b.b.b/site I'd like to configure a Reverse Proxy so that all resquests to http://b.b.b.b/site would be redirected to http://a.a.a.a/site. So first I tried the Apache module mod_proxy with the configuration at the httpd.conf. --- ProxyRequests Off ProxyPass /site http://a.a.a.a/site ProxyPassReverse /site http://b.b.b.b/site Everything worked fine. But the problem was with the embedded URLs. The mod_proxy doen't change them. So that's why I'm trying to use the ProxyRewrite module. I put the following lines at the end of the httpd.conf: Location /site SetHandler perl-script PerlHandler Apache::ProxyRewrite PerlSetVar ProxyTo http://a.a.a.a/site PerlSetVar ProxyAuthInfo BASIC aGb2c3ewenQ6amF4szzmY3b= PerlSetVar ProxyAuthRedirect Off PerlSetVar ProxyRewrite http://a.a.a.a/ = / /Location -- What I see is that all the embedded URLs that begin with http://a.a.a.a/; are changed to /. So the links works well but the redirects that I have in my CGI scripts doesn't work. The server don't find the page. Exemple of redirect on my CGI scripts written with perl: print redirect(http://a.a.a.a/site/cgi-bin/.cgi;); As I don't have a DNS, I tried to change the line: PerlSetVar ProxyRewrite http://a.a.a.a/ = / To: PerlSetVar ProxyRewrite http://a.a.a.a/ = http://b.b.b.b/; But the embedded URLs are still changed to /. I can't understand. Can anyone help me? I'd be very grateful. I think that my problem is very simple. I'd like to configure a Reverse Proxy that changes the embedded URLs too, not only the Location URL. Thank you very much. --- Rodney A. Ramos
Re: cookies and IE
At 20:12 02.10.2002, Alan wrote: On Wed, Oct 02, 2002 at 01:21:49PM -0400, Geoffrey Young wrote: so, it's not really a bug if you dig down into the docs and examples. looks like a feature, though :) Agreed... more of a 'gotcha' though, ready to bite people in the butt. Personally I think it might make more sense to do a check to see if the val =~ /(\d+)(h|m|d|M)/ before it's sent off as a literal, but who knows. I'll email someone about it anyway. It's because you can put a correctly formatted date string in the -expires option, AFAIK. So if using your idea, the literal string might be misinterpreted. Also, don't forget that you have +1d and -1d as another possibility. I think the +/- makes sense. It's just one character :) -- Per Einar Ellefsen [EMAIL PROTECTED]
Re: problems with sessions and upgrading
Gerald Richter wrote: OLD STUFF: redhat 5.2, 2.0.36 kernel, 1.3.6 apache, 1.21 mod_perl, perl 5.005_02, apache session 1.04 and a storable of 0.63, embperl 1.2.b10, file system sessions and locking data. NEW STUFF: redhat 5.2, 2.0.36 kernel, 1.3.26 apache, 1.27 mod_perl, perl 5.6.1, apache session 1.54, apache sessionX 2.00b3, storable of 2.05, embperl 1.3.4, file system sessions and locking data.. ... yields the following error message: Storable binary image v56.115 more recent than I am (v2.5) at blib/lib/Storable.pm (autosplit into blib/lib/auto/Storable/thaw.al) line 364, FIL chunk 1, at -e line 1 Did you try to install the old storable into the new Perl? If this works you could convert it to some other format (e.g. Data::Dumper), install the new storeable and put the session data back. i did think about doing that. that is where question #1 come in: 1) the sessions keys for the new sessions are twice as long as the old ones. generally, this is a good thing, but i am concerned that the old session data will not get read when the cookie is submitted. will the old sessions get read and reused, read and new ones created, totally ignored? after i write down my 100k or so dumps, and bring them back into the new sessions but still with the short session key, will Apache::Session readup the key and use the session when the cookie is presented by the browser? if nobody knows the answer, i'll see if i can create a coiple of sessions and test this theory. -- ___cliff [EMAIL PROTECTED]http://www.genwax.com/
passing an object to a handler
hello, I've been off-list for a while, so please forgive (and direct) me if this is a tired subject. In short, i'd like to pass through another object on method invocation, in addition to the apache request. Ideally the (method)handler would look something like: sub handler ($$$) { my ($class, $r, $factory) = _; ... } where $factory is an object I made earlier, and is shared among all the requests. I'd like to avoid class data because the handler will almost always be subclassed, and anyway it makes me nervous. And for the same reason I don't want to make the factory a singleton: each single, hard-working object of the factory class will have a different configuration. but I can't find anything to tell me how to do it. I feel sure I'm missing something really obvious here? thanks will
Re: cookies and IE
On Wed, Oct 02, 2002 at 08:30:54PM +0200, Per Einar Ellefsen wrote: At 20:12 02.10.2002, Alan wrote: On Wed, Oct 02, 2002 at 01:21:49PM -0400, Geoffrey Young wrote: so, it's not really a bug if you dig down into the docs and examples. looks like a feature, though :) Agreed... more of a 'gotcha' though, ready to bite people in the butt. Personally I think it might make more sense to do a check to see if the val =~ /(\d+)(h|m|d|M)/ before it's sent off as a literal, but who knows. I'll email someone about it anyway. It's because you can put a correctly formatted date string in the -expires option, AFAIK. So if using your idea, the literal string might be misinterpreted. Also, don't forget that you have +1d and -1d as another possibility. I think the +/- makes sense. It's just one character :) Oh, totally agreed, I just figured that it might be a good way to set a default if there was no + or -, which could eliminate headaches for people like me :) Also, as there's no chance of a correctly formatted date string being \d(h|m|d|etc), it could be a fair assumption. My $0.02 anyway! :) alan -- Alan Arcterex [EMAIL PROTECTED] -=][=- http://arcterex.net I used to herd dairy cows. Now I herd lusers. Apart from the isolation, I think I preferred the cows. They were better conversation, easier to milk, and if they annoyed me enough, I could shoot them and eat them. -Rodger Donaldson
Re: passing an object to a handler
At 20:47 02.10.2002, william ross wrote: hello, I've been off-list for a while, so please forgive (and direct) me if this is a tired subject. In short, i'd like to pass through another object on method invocation, in addition to the apache request. Ideally the (method)handler would look something like: sub handler ($$$) { my ($class, $r, $factory) = @_; ... } where $factory is an object I made earlier, and is shared among all the requests. I'd like to avoid class data because the handler will almost always be subclassed, and anyway it makes me nervous. And for the same reason I don't want to make the factory a singleton: each single, hard-working object of the factory class will have a different configuration. but I can't find anything to tell me how to do it. I feel sure I'm missing something really obvious here? You can configure objects instead of using static class names. See the doc: http://perl.apache.org/docs/1.0/guide/method_handlers.html -- Per Einar Ellefsen [EMAIL PROTECTED]
RE: Easy internal redirect question
I've got a bit of a better grasp on the problem nowI think it's an interaction with POST data... I have a form in foo.html form action=/rms/admin method=post input type=hidden name=task value=process_config ...other form fields... /form I submit this form, and in /rms/admin, it gets handled like this # suck in form values, stick them in objects, blah blah, then get to the redirect... $r-internal_redirect('/rms/status?task=display'); and what happens is that /rms/status complains that it doesn't know how to handle task=process_config. So, somehow the value for 'task' that was POSTed in the first request from the form gets passed onto the second request, apparently overriding the 'task' value of 'display' which I am trying to set in the url string I'm giving to internal_redirect(). I don't want any of the POST data to get passed onto that redirect. Any thoughts? I saw a note in the API docs that $r-args() can be used to set the query string and that this is useful when redirecting POST requests. I tried doing a $r-args('task=display') right before the call to internal_redirect, but no luck. Thanks, Fran -Original Message- From: Geoffrey Young [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 02, 2002 1:06 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: Easy internal redirect question [EMAIL PROTECTED] wrote: I call a page, /my/script1?task=foo which does some things and then needs to redirect to /my/script2?task=bar. However, putting $r-internal_redirect('/my/script2?task=bar'); doesn't seem to work as script2 is seeing task=foo rather than task=bar. Looks like the internal_redirect is also passing along the form params to the second request. How is this avoided? I'm looking through the cookbook recipe on internal redirects but nothing is jumping out at me at the moment. that's pretty odd. given two scripts, one.pl: shift-internal_redirect('/perl-bin/two.pl?internal=redirect'); return Apache::OK; and two.pl: my $r = shift; $r-send_http_header('text/plain'); print args is , scalar $r-args, \n; I get the right results: $ GET localhost/perl-bin/one.pl?main=request args is internal=redirect are you returning OK right after your internal redirect? does setting $r-args() before calling the internal redirect to a third value change anything? --Geoff
Re: passing an object to a handler
On Wednesday, October 2, 2002, at 08:18 PM, Per Einar Ellefsen wrote: At 20:47 02.10.2002, william ross wrote: but I can't find anything to tell me how to do it. I feel sure I'm missing something really obvious here? You can configure objects instead of using static class names. See the doc: http://perl.apache.org/docs/1.0/guide/method_handlers.html sorry: i wasn't very clear, was I? I am using a method handler, but I want to pass an object of another class to it each time it is called. The object needs to be created outside of an individual request, and therefore presumably in a startup file, and then either passed to the handler along with each request, or somehow made available to all the requests, but preferably without setting a class variable, which is what I do at the moment but dislike. thanks will
Re: passing an object to a handler
At 21:30 02.10.2002, william ross wrote: On Wednesday, October 2, 2002, at 08:18 PM, Per Einar Ellefsen wrote: At 20:47 02.10.2002, william ross wrote: but I can't find anything to tell me how to do it. I feel sure I'm missing something really obvious here? You can configure objects instead of using static class names. See the doc: http://perl.apache.org/docs/1.0/guide/method_handlers.html sorry: i wasn't very clear, was I? I am using a method handler, but I want to pass an object of another class to it each time it is called. The object needs to be created outside of an individual request, and therefore presumably in a startup file, and then either passed to the handler along with each request, or somehow made available to all the requests, but preferably without setting a class variable, which is what I do at the moment but dislike. Yes, and that it exactly what the doc I referred to shows you: You instantiate an object in your startup file; then you configure mod_perl to call your handler with this object as the class, like: PerlHandler $My::obj-handler $My::Obj must then be an instance of the handler class, but can contain any other information too. Now, in your handler, you get: sub handler ($$) { my ($obj, $r) = @_; and you have your $obj, which you can use freely. ($obj isn't a class name, it is an ... object!) Wasn't that what you wanted? -- Per Einar Ellefsen [EMAIL PROTECTED]
Re: passing an object to a handler
On Wednesday, October 2, 2002, at 08:37 PM, Per Einar Ellefsen wrote: At 21:30 02.10.2002, william ross wrote: On Wednesday, October 2, 2002, at 08:18 PM, Per Einar Ellefsen wrote: At 20:47 02.10.2002, william ross wrote: but I can't find anything to tell me how to do it. I feel sure I'm missing something really obvious here? You can configure objects instead of using static class names. See the doc: http://perl.apache.org/docs/1.0/guide/method_handlers.html sorry: i wasn't very clear, was I? I am using a method handler, but I want to pass an object of another class to it each time it is called. The object needs to be created outside of an individual request, and therefore presumably in a startup file, and then either passed to the handler along with each request, or somehow made available to all the requests, but preferably without setting a class variable, which is what I do at the moment but dislike. Yes, and that it exactly what the doc I referred to shows you: You instantiate an object in your startup file; then you configure mod_perl to call your handler with this object as the class, like: PerlHandler $My::obj-handler $My::Obj must then be an instance of the handler class, but can contain any other information too. Now, in your handler, you get: sub handler ($$) { my ($obj, $r) = _; and you have your $obj, which you can use freely. ($obj isn't a class name, it is an ... object!) Wasn't that what you wanted? no, not quite, though i begin to suspect that i wanted the wrong thing, and what you suggest - which I had read several times but apparently not taken in - is what I should be looking for. the trouble is that I want to have many handler objects - they hold session information, among other reasons - but I want each one to use the same factory object. I don't want to instantiate a single handler, as i think your snippet would. so i thought i'd make a new one each time and pass the factory to each one. but it looks - from what you say - like I've just got it back to front: at the moment Class::DBI::Handler expects to be given a Class::DBI::Factory object, but what I should do is put the handler($$) method in the factory itself, and construct a new Class::DBI::Factory::Handler object each time it's called, to hold whatever per-request information is required. excuse me thinking out loud: maybe you could warn me if it sounds like i've found another wrong tree. meanwhile, I'll go try it. thanks for your help will
Re: mod_perl Windows 2000 install notes
On Wed, 2 Oct 2002, Larry Leszczynski wrote: Just wanted to send along some info that might be useful to add as a Windows installation note in the mod_perl guide. The short story is: You may need to shut down and restart your machine after installing to get things to start working! [ ... ] That's a good point ... I'm not sure why that would be needed in this case (maybe something to do with using it as a service), but in any case, on Win32, it's not unusual to recommend a reboot. I'll add that to the docs - thanks. -- best regards, randy
Re: mod_perl Windows 2000 install notes
It's needed, for example, to enable the system-wide PATH to include \Perl\bin in it, which is needed to load mod_perl.so into the server when running as a system service. Note that you can still go to a command shell, add perl\bin to the path and manually start apache from the command shell - that will work. Issac - Original Message - From: Randy Kobes [EMAIL PROTECTED] To: Larry Leszczynski [EMAIL PROTECTED] Cc: mod_perl list [EMAIL PROTECTED] Sent: Wednesday, October 02, 2002 11:30 PM Subject: Re: mod_perl Windows 2000 install notes On Wed, 2 Oct 2002, Larry Leszczynski wrote: Just wanted to send along some info that might be useful to add as a Windows installation note in the mod_perl guide. The short story is: You may need to shut down and restart your machine after installing to get things to start working! [ ... ] That's a good point ... I'm not sure why that would be needed in this case (maybe something to do with using it as a service), but in any case, on Win32, it's not unusual to recommend a reboot. I'll add that to the docs - thanks. -- best regards, randy
Re: passing an object to a handler
On Wednesday, October 2, 2002, at 09:11 PM, Dave Rolsky wrote: On Wed, 2 Oct 2002, william ross wrote: sorry: i wasn't very clear, was I? I am using a method handler, but I want to pass an object of another class to it each time it is called. The object needs to be created outside of an individual request, and therefore presumably in a startup file, and then either passed to the handler along with each request, or somehow made available to all the requests, but preferably without setting a class variable, which is what I do at the moment but dislike. You could make the other object a singleton, so you could just do: my $factory = My::Factory-instance I did have it set up that way at one point. it worked quite nicely as long as I made the singleton in a subclass of the main Factory (which might be shared by several applications with different configurations). i gave up on it in the end because it seemed a bit overheated, but if you approve, i shall reconsider. so, rehearsing: all it should take is a Factory::Subclass-new(config blah) in the startup script and a Factory::Subclass-instance() in the handler? it does sound good if you put it like that. incidentally I made the singleton like this (yes, more poop): use base qw (Class::DBI::Factory Class::Singleton); ... sub _new_instance { shift-new(_) } but it felt rather naughty to subclass the private _new_instance. if anyone knows a better way, I'd be very glad to hear it. (but this is galloping quickly away from the topic, and I'm sure I can work it out in the end :) thank you. will
Re: passing an object to a handler
On Wed, 2 Oct 2002, william ross wrote: I did have it set up that way at one point. it worked quite nicely as long as I made the singleton in a subclass of the main Factory (which might be shared by several applications with different configurations). i gave up on it in the end because it seemed a bit overheated, but if you approve, i shall reconsider. I'm not quite following you. Overheated? so, rehearsing: all it should take is a Factory::Subclass-new(config blah) in the startup script and a Factory::Subclass-instance() in the handler? it does sound good if you put it like that. incidentally I made the singleton like this (yes, more poop): use base qw (Class::DBI::Factory Class::Singleton); ... sub _new_instance { shift-new(_) } but it felt rather naughty to subclass the private _new_instance. if anyone knows a better way, I'd be very glad to hear it. Check out Class::Singleton. -dave /*== www.urth.org we await the New Sun ==*/
Re: passing an object to a handler
On Wednesday, October 2, 2002, at 09:48 PM, Dave Rolsky wrote: On Wed, 2 Oct 2002, william ross wrote: I did have it set up that way at one point. it worked quite nicely as long as I made the singleton in a subclass of the main Factory (which might be shared by several applications with different configurations). i gave up on it in the end because it seemed a bit overheated, but if you approve, i shall reconsider. I'm not quite following you. Overheated? sorry. i just meant that it seemed like a lot of engineering - much of which was a little beyond me, though I've caught up a bit since - for what seemed like such a simple requirement. but i've just been doing as you suggested, and it does work rather nicely. thanks. so, rehearsing: all it should take is a Factory::Subclass-new(config blah) in the startup script and a Factory::Subclass-instance() in the handler? it does sound good if you put it like that. (dimwit: both calls should be to instance(). oops) incidentally I made the singleton like this (yes, more poop): use base qw (Class::DBI::Factory Class::Singleton); ... sub _new_instance { shift-new(_) } but it felt rather naughty to subclass the private _new_instance. if anyone knows a better way, I'd be very glad to hear it. Check out Class::Singleton. er, that's what I said. guess it must be ok :) will
virtualhost based variables
Greetings again. I'm trying to figure out the best/fastest/most elegant way of setting virtualhost based variables. Basically I have three sites, and the only difference between them is the DocumentRoot ($htdocroot) and the database their data is being accessed from ($dbh). When it was a single site I had $documentroot and $dbh declared in my startup.pl, and my modules accessed it through $main::dbh, and it was all find and dandy. Is there a way to do this? Or do I have to use $r-dir_config in every module to get the document root and re-create $dbh? I know mod_perl 2.0 will solve this problem with the +Parent option, but heading to apache 2.0 might not be an option at this point. So how does everyone else do it? :) TIA alan -- Alan Arcterex [EMAIL PROTECTED] -=][=- http://arcterex.net I used to herd dairy cows. Now I herd lusers. Apart from the isolation, I think I preferred the cows. They were better conversation, easier to milk, and if they annoyed me enough, I could shoot them and eat them. -Rodger Donaldson
Re: virtualhost based variables
Alan [EMAIL PROTECTED] wrote: Greetings again. I'm trying to figure out the best/fastest/most elegant way of setting virtualhost based variables. Basically I have three sites, and the only difference between them is the DocumentRoot ($htdocroot) and the database their data is being accessed from ($dbh). Document root should be accessable from $r. I would use Apache::DBI for persistent connections. Then connect at the beginning of the request with the DBI connection parameters coming from $r-dir_config. -- James Smith [EMAIL PROTECTED], 979-862-3725 Texas AM CIS Operating Systems Group, Unix
Graphics and mod_perl
Im new to mod_perl and Im really enjoying it. It has really improved performance. Right now Im just using Modperl::Registry to speed up things. I have a question about showing graphics using a Perl Script and running it through mod_perl. Using Perl under regular CGI to create a dynamic web page I have always used: print img src="\thefile.jpg\; and this would display the graphic to the web page assuming that the file thefile.jpg was in the same directory as the Perl script . If the graphic was in another directory then something like: print img src="\../graphics/thefile.jpg\; was used. Now that Im using mod_perl and an Alias to my cgi-bin Im having difficulties knowing how to reference the graphics file. The following directive is in my httpd.conf file. Alias /ssiweb/ C:/Server/htdocs/develop/cgi-bin/ Location /ssiweb SetHandler perl-script PerlResponseHandler ModPerl::Registry Options +ExecCGI PerlOptions +ParseHeaders /Location It seems that the current working directory for the Perl scripts when run under mod_perl is in the bin directory where Apache.exe is. I have considered using absolute paths but even that does not seem to work correctly with graphics. I could also do something like: print img src="\http://www.mysite.com/graphics/thefile.jpg\; but it seems that there is a delay in displaying the graphic when I do this. Where is the current working directory when running a Perl script under mod_perl. I would appreciate any help. Thanks.
Re: virtualhost based variables
On Wed, Oct 02, 2002 at 06:04:03PM -0500, James G Smith wrote: Alan [EMAIL PROTECTED] wrote: Greetings again. I'm trying to figure out the best/fastest/most elegant way of setting virtualhost based variables. Basically I have three sites, and the only difference between them is the DocumentRoot ($htdocroot) and the database their data is being accessed from ($dbh). Document root should be accessable from $r. I would use Apache::DBI for persistent connections. Then connect at the beginning of the request with the DBI connection parameters coming from $r-dir_config. Yup, and this is exactly how I have it working right now. Each module starts by re-instantiating $dbh and $htdocroot via dir_config and a function that uses dir_config to find the database it's supposed to grab stuff from. The problem is that it seems like I've incurred a pretty high speed penalty, and my requests/sec have dropped from about 165 to 83 :( I'm still pushing enough data to saturate a T1, so at the end it's not going to be a noticable difference. I wanted to know if there was a better/faster way to do this though, without having to call $r-dir_config and $r-document_root for /every/ request. Alan -- Alan Arcterex [EMAIL PROTECTED] -=][=- http://arcterex.net I used to herd dairy cows. Now I herd lusers. Apart from the isolation, I think I preferred the cows. They were better conversation, easier to milk, and if they annoyed me enough, I could shoot them and eat them. -Rodger Donaldson
Re: cookies and IE
At 9:29 AM +0200 10/2/02, Sven Geisler wrote: Hi Alan, Hi Kee, I would say Kee is wrong. In our application, the development of which I am involved in, for a special case we need to write a cookie and redirect to another page. Wouldn't be the first time I've been wrong. I do know that I was seeing inconsistent behavior with cookies not being saved in a redirect page (mostly IE PC, but not 100% of the time), but I didn't spend any time worrying about it because of the previous messages I remembered. A quick check of my mailbox shows a discussion back in March where someone suggested using Refresh instead of Redirect to get around the problem. I recall previous discussions, but I don't have any on file. The typical case here is that the user goes to page a, you redirect them to page b for authentication, they submit their password and the password page then sets a cookie and sends them back to a. It may be that the problem was a coding one rather than a browser one. I just tore out the code and instead decided to internally display page b without doing a a redirect. So your URL is for a, but the content is the login page (b). On submit page sees a successful login, sets the cookie, and displays itself. EmpberlObject made this trivial to do, and it ended up meaning less server roundtrips and less code. -- Kee Hinckley - Somewhere.Com, LLC http://consulting.somewhere.com/ I'm not sure which upsets me more: that people are so unwilling to accept responsibility for their own actions, or that they are so eager to regulate everyone else's.
url to png/jpeg
Hi, Somewhere read about converting urls to jpegs on the fly using modperl ?? Preferrably, to png TIA Alastair Stuart Perl Person
urls with session info
i have been trying to write a handler that will provide me with session data using the URL (eg, http://www.domain.com/$sessionid . $r-url) like the eagle books has on p246. in addition i am serving a cookie with that same $sessionid and then comparing to two $sessionid's in order to prevent the leaking referrer information and other problems. i am using apache::session::flex for my session information. i am running into a lot of operational problems and i think i am looking at restarting this little project of mine. i want to do this for caching of expensive personalized webpages for people would be great if i could. is there a a:session package already out there that does this? there sure are a lot of them. seems that there are none that manipulate the url however in the perltranshandler however. thanks
[Silly Problem] Error Logs all over the place
Hi People, I'm trying to figure out why something is happening and after a failed very silly idea of forking, backticks, greps and strace, I seek your help! Background -- Using: moya# /usr/local/sbin/httpd -v Server version: Apache/1.3.26 (Unix) Server built: Jul 2 2002 13:08:13 On a server which has declared a global MySQL PerlLogHandler and a global declaration of: ErrorLog syslog:local6 Someone else set up the httpd.conf on this server and we have '#includ'ed a vhost with it's own ErrorLog directed to the bottom of the global httpd.conf file. Problem --- The VirtualHost/ is playing up and appears to be showing STDERR output from other VirtualHosts in it's ErrorLog file. I'm not sure if the global PerlLogHandler is interfering in anyway, however this seems most bizzar to me since grepping for that particular ErrorLog file amoungst the other virtual hosts appears to reveal that it is only decalred with the 'one' VirtualHost/ block, whilst all the others seem to fall back to the global declaration. S0 -- It seems like a little slip up somewhere, however I don't see how an ErrorLog declared within 'one' VirtualHost block would become the default for any other vhost processes? Any ideas on this one? Cheers, Rafiq -- Senior Programmer Bookings.nl -- Me::[EMAIL PROTECTED]||www.dreamthought.com Budget hosting on my 10Mbit/backbone::[EMAIL PROTECTED]
[Silly Problem] Error Logs all over the place
Hi People, I'm trying to figure out why something is happening and after a failed very silly idea of forking, backticks, greps and strace, I seek your help! Background -- Using: moya# /usr/local/sbin/httpd -v Server version: Apache/1.3.26 (Unix) Server built: Jul 2 2002 13:08:13 On a server which has declared a global MySQL PerlLogHandler and a global declaration of: ErrorLog syslog:local6 Someone else set up the httpd.conf on this server and we have '#includ'ed a vhost with it's own ErrorLog directed to the bottom of the global httpd.conf file. Problem --- The VirtualHost/ is playing up and appears to be showing STDERR output from other VirtualHosts in it's ErrorLog file. I'm not sure if the global PerlLogHandler is interfering in anyway, however this seems most bizzar to me since grepping for that particular ErrorLog file amoungst the other virtual hosts appears to reveal that it is only decalred with the 'one' VirtualHost/ block, whilst all the others seem to fall back to the global declaration. S0 -- It seems like a little slip up somewhere, however I don't see how an ErrorLog declared within 'one' VirtualHost block would become the default for any other vhost processes? Any ideas on this one? Cheers, Rafiq -- Senior Programmer Bookings.nl -- Me::[EMAIL PROTECTED]||www.dreamthought.com Budget hosting on my 10Mbit/backbone::[EMAIL PROTECTED]
[Silly Problem] Error Logs all over the place
Hi People, I'm trying to figure out why something is happening and after a failed very silly idea of forking, backticks, greps and strace, I seek your help! Background -- Using: moya# /usr/local/sbin/httpd -v Server version: Apache/1.3.26 (Unix) Server built: Jul 2 2002 13:08:13 On a server which has declared a global MySQL PerlLogHandler and a global declaration of: ErrorLog syslog:local6 Someone else set up the httpd.conf on this server and we have '#includ'ed a vhost with it's own ErrorLog directed to the bottom of the global httpd.conf file. Problem --- The VirtualHost/ is playing up and appears to be showing STDERR output from other VirtualHosts in it's ErrorLog file. I'm not sure if the global PerlLogHandler is interfering in anyway, however this seems most bizzar to me since grepping for that particular ErrorLog file amoungst the other virtual hosts appears to reveal that it is only decalred with the 'one' VirtualHost/ block, whilst all the others seem to fall back to the global declaration. S0 -- It seems like a little slip up somewhere, however I don't see how an ErrorLog declared within 'one' VirtualHost block would become the default for any other vhost processes? Any ideas on this one? Cheers, Rafiq -- Senior Programmer Bookings.nl -- Me::[EMAIL PROTECTED]||www.dreamthought.com Budget hosting on my 10Mbit/backbone::[EMAIL PROTECTED]
Re: Graphics and mod_perl
At 01:41 03.10.2002, Justin Luster wrote: I m new to mod_perl and I m really enjoying it. It has really improved performance. Right now I m just using Modperl::Registry to speed up things. I have a question about showing graphics using a Perl Script and running it through mod_perl. Using Perl under regular CGI to create a dynamic web page I have always used: print img src=\ thefile.jpg\ ; and this would display the graphic to the web page assuming that the file thefile.jpg was in the same directory as the Perl script . If the graphic was in another directory then something like: print img src=\ ../graphics/thefile.jpg\ ; [...] print img src=\ http://www.mysite.com/graphics/thefile.jpg\ ; but it seems that there is a delay in displaying the graphic when I do this. Where is the current working directory when running a Perl script under mod_perl. Hello Justin, You seem to misunderstand the working of the HTML img tag. All you're doing is to give an idea to the *browser* about where it should find the image, relatively to the *URI* of your script. Simply put, before you had: /cgi-bin/yourscript.cgi --- img src=thefile.jpg --- browser tries to fetch /cgi-bin/thefile.jpg Now, you have: /ssiweb/yourscript.pl img src=../graphics/thefile.jpg --- browser fetches /ssiweb/../graphics/thefile.jpg = /graphics/thefile.jpg You have almost found the best solution when in doubt: using absolute URIs. However, as you noticed, using the full URL is slower because the browser has to check the DNS again etc etc. So, if your graphics are acccessible as http://www.example.com/graphics/file.jpg, then you can insert an img tag with src=/graphics/file.jpg. Note the first slash which says to the browser Begin at the root of this site and fetch the following URI. Ok? -- Per Einar Ellefsen [EMAIL PROTECTED]
Defaulting to default-handler from custom handler
What is the proper way to revert back to the default-handler from a custom PerlHandler? My handler is only defined in ScriptAlias'd locations. In the cases when I want the default-handler to process the cgi request, that is have mod_cgi (i.e. perl-script) run the script I tried: $r-handler('perl-script') if (special_case); and $r-handler('default-handler') if (special_case); and return DECLINED if (special_case); and lastly $r-handler-('perl-script'); return DECLINED; All four cases result in the Perl code being displayed instead of the script being executed? If a location is defined as a ScriptAlias, then is the default-handler == perl-script? and would returning DECLINED result in mod_cgi handling the request? What am I doing wrong? I'm running: Apache-1.3.26/mod_perl-1.26/perl-5.6.1/UNIX-Solaris8 btw, I have RTFM'd and refered to mod_perl cookbook but still confused ;) Thanks, -Carlos
request patch that fixes previous declaration of getline in htpasswd.c
Doug, All, I am trying to install puresecure, which compiles apache and mod_perl, but im getting the error: htpasswd.c:145: conflicting types for `getline' /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.2/include/stdio.h:445: previous declaration of `getline' which matches your discussion i found here: http://www.gossamer-threads.com/archive/mod_perl_C1/dev_F4/cannot_built_apache-1.$ which mentions a patch that fixed the problem. Could i please be directed to that patch? or another work around? thank you very much, marc Bush should take up t'ai chi. He'd be a lot more relaxed and not so invady. - www.theonion.com
Re: problems with sessions and upgrading
1) the sessions keys for the new sessions are twice as long as the old ones. generally, this is a good thing, but i am concerned that the old session data will not get read when the cookie is submitted. will the old sessions get read and reused, read and new ones created, totally ignored? Frankly, this all begs the question of why you are putting important long-term data in Apache::Session. That isn't what it's for. You should only have transient data in there. I don't think you'll find any clear upgrade path that maintains the data, so you either hav to write your own data migration script or not upgrade Apache::Session. - Perrin
Re: problems with sessions and upgrading
hi perrin, yes, i did read the discussion with interest a few months back regarding what should be stored in a session and what in the back end database. customer and order data is properly stored in a secured back end system. the cart contains data that i want to keep for 30 days, such as cart data, affiliate reference data and things of that nature. i have found the sessions to be simple, quick, convenient and a reliable way to maintain this transient data. the fact is, the data is in there, and i need to migrate it to the new sessions. i may redesign the system at a later time, but the buying season is upon us, and reenginerring this part of the system is not in the current plans. thanks! cliff [EMAIL PROTECTED] wrote: Frankly, this all begs the question of why you are putting important long-term data in Apache::Session. That isn't what it's for. You should only have transient data in there. I don't think you'll find any clear upgrade path that maintains the data, so you either hav to write your own data migration script or not upgrade Apache::Session.