Re: Downloading SpreadSheet Data with Apache

2007-09-23 Thread Issac Goldstand
Make sure that you set a TimeOut in httpd.conf greater than your 
script's delay:

http://httpd.apache.org/docs/2.2/mod/core.html#timeout

 Issac

Tyler Bird wrote:

Michael Peters wrote:

Tyler Bird wrote:

 
I run this script and the log files show the incrementing numbers in 
the

for loop, but
whats weird is that the browser seems to still be downloading you 
know

that little icon seems to be spinning
and I see no output not and html header of any line of text.



You need to tell the server not to buffer your output. Do something 
like this at

the top of the routine you use to output the stream.

  local $| = 1;

 

any ideas on why the browser is not receiving or the webserver is not
sending this content?



If you need to know what's happening HTTP wise, use some network 
analyzing tool
like ethereal. But my guess is just that your web server isn't 
sending the info

yet cause it's buffer isn't full.

  
Yes I did try this ( putting in the $| = 1 ) and the behavior did not 
change the browser still appeared to be downloading
and the log files had all the numbers in the for() loop.   my browser 
didn't seem to receive the content-type or the body of the response ( 
statments below for loop )

I am going to re look over $|


Here is the full version incase there is something I am missing.

--cut

local $| = 1;

require in;

my $max = 60 * 8;

foreach ( my $i = 0; $i  $max; $i++)
{
   warn(sleeping, iteration:  . $i);
   sleep(1);

}

in::ct();
print(I rendered);

-- end


Re: +ParseHeaders random corruption

2007-09-23 Thread Philippe M. Chiasson
Mark Farver wrote:
 Perrin Harkins wrote:
 On 9/21/07, Mark Farver [EMAIL PROTECTED] wrote:
   
 Searching my harddrive, those strings appear in the mysql driver but we've
 seen chunks of the gpl, and other weird random data in those errors.  It
 almost looks like a wild pointer.
 
 Maybe some kind of threading issue?  Are you running the prefork MPM?
 
 I thought that too, but we're running the prefork MPM.

Souds like a script that sometimes sends out headers, sometimes doesn't.

How does this behave when running under single-user mode ? I would venture
a guess that it has to do with some global code printing headers triggered
at require/use time or some such. PerlRun is quite different between mod_perl
1 and 2.


Philippe M. Chiasson GPG: F9BFE0C2480E7680 1AE53631CB32A107 88C3A5A5
http://gozer.ectoplasm.org/   m/gozer\@(apache|cpan|ectoplasm)\.org/



signature.asc
Description: OpenPGP digital signature


Re: Problem with RequestRec and Headers

2007-09-23 Thread Philippe M. Chiasson
jk jk wrote:
 I'm trying to port a preexisting CGI app to mod_perl2 and could use some
 help.
 
 Here goes a test case that should illustrate my problem:
 
 The code pasted below loads the page properly the first time it's
 accessed.  However, upon multiple reloads in firefox, the headers either
 disappear altogether or the page is downloaded in the download manager. 
 I assume this is because the wrong $r object is being accessed by the
 request?  In any case, I'm at a loss and would really appreciate some
 input.  Thanks in advance.
 [...]
 
 =
 File: testme/testmod.pm
 =
 
 package testme::testmod;
 
 use Apache2::RequestUtil;
 use strict;
 
 use base qw /Class::Singleton/;

^^

From the documentation of Class::Singleton:

# this only gets called the first time instance() is called

 sub _new_instance{
 
 my ( $class, $r ) = @_;
 
 my $self = {};
 
 bless $self, $class;
 
 $self-{r} = $r;
 
 return ( $self );
 
 }

So effectively, your code will capture the $r (once for each child)
from the first request and keep it forever. Trying to use it for subsequent
requests will cause the kind of problems you've seen.


Philippe M. Chiasson GPG: F9BFE0C2480E7680 1AE53631CB32A107 88C3A5A5
http://gozer.ectoplasm.org/   m/gozer\@(apache|cpan|ectoplasm)\.org/



signature.asc
Description: OpenPGP digital signature


Re: [OT] Client authentication

2007-09-23 Thread Philippe M. Chiasson


Bill Moseley wrote:
 This isn't mod_perl related, but I'm hoping someone here has
 experience in this area and can provide some feedback.
 Recommendation of a better list for this question is also welcome.
 
 I have a mod_perl/SOAP::Lite server application where I need to
 authenticate the connecting clients.  The clients are all SOAP::Lite
 applications and connect to the server over the Internet.
 
 The server allows SSL connections only, and the server has a list of IP
 addresses of the clients that are allowed to connect.
 
 I'm also looking at using client certificates, which is something I
 have not setup before.
 
 First, I'm not clear in this closed application if I need a real CA or
 if I can self-sign and be my own CA.  (I read someplace that
 this should be avoided for performance reasons, although that might
 have been referring to use in web browsers.)

If it's an internal application, I'd go 100% self-signed with your
own CA. It's not hard, and it will save you tons of $$$.

 I'm also not clear if there's an advantage to using a client
 certificate.  Another other option would be a shared secret and
 generate a message digest that can be verified on the server side.
 
 If the concern is that someone might spoof an IP address then the
 shared secret seems adequate.

If the secret is ever compromised, you have to update every single
client/server out there. If a client cert is compromised, you revoke it
and carry on doing business as usual.

 If the concern is that someone might hack a client machine and make
 fake requests to the server then it seems the hacker would have access to
 the client cert just as easily as the shared secret.

Yup, but you can revoke a client-cert, not a shared secret...

 But, as I said, I have not used client certs before so I might be
 missing a key point.

Oh, and a bonus point. Client applications can generate their own certs,
and only get your CA to sign them.  It's a much neater approach IMO. And
totally worth the slight extra complexity of running your own CA.

Check out TinyCA as a good simple tool for this kind of CA 
(http://tinyca.sm-zone.net/)


Philippe M. Chiasson GPG: F9BFE0C2480E7680 1AE53631CB32A107 88C3A5A5
http://gozer.ectoplasm.org/   m/gozer\@(apache|cpan|ectoplasm)\.org/



signature.asc
Description: OpenPGP digital signature


Re: Problem with RequestRec and Headers

2007-09-23 Thread jk jk
Why is that?  Class::Singleton is modperl compatible, Apache::Singleton is
the same thing with a few more features.  Its purpose to simplify singleton
application creation.  My understanding was it would only allow a single
instance of the object to be created for each request, not forever.  Please
explain your reasoning.  Thanks. --JAK

On 9/23/07, Philippe M. Chiasson [EMAIL PROTECTED] wrote:

 jk jk wrote:
  I'm trying to port a preexisting CGI app to mod_perl2 and could use some
  help.
 
  Here goes a test case that should illustrate my problem:
 
  The code pasted below loads the page properly the first time it's
  accessed.  However, upon multiple reloads in firefox, the headers either
  disappear altogether or the page is downloaded in the download manager.
  I assume this is because the wrong $r object is being accessed by the
  request?  In any case, I'm at a loss and would really appreciate some
  input.  Thanks in advance.
  [...]
 
  =
  File: testme/testmod.pm
  =
 
  package testme::testmod;
 
  use Apache2::RequestUtil;
  use strict;
 
  use base qw /Class::Singleton/;

 ^^

 From the documentation of Class::Singleton:

 # this only gets called the first time instance() is called

  sub _new_instance{
 
  my ( $class, $r ) = @_;
 
  my $self = {};
 
  bless $self, $class;
 
  $self-{r} = $r;
 
  return ( $self );
 
  }

 So effectively, your code will capture the $r (once for each child)
 from the first request and keep it forever. Trying to use it for
 subsequent
 requests will cause the kind of problems you've seen.

 
 Philippe M. Chiasson GPG: F9BFE0C2480E7680 1AE53631CB32A107 88C3A5A5
 http://gozer.ectoplasm.org/   m/gozer\@(apache|cpan|ectoplasm)\.org/





Re: Problem with RequestRec and Headers

2007-09-23 Thread jk jk
I've been trying to use Apache::Singleton::Request under the assumption that
you're right about Class::Singleton being the crux of the issue.
Unfortunately, I can't get it working under Apache2.  Is there a different
module for mp2/apache2 ?  Thanks for your patience. --JAK

On 9/23/07, jk jk [EMAIL PROTECTED] wrote:

 Why is that?  Class::Singleton is modperl compatible, Apache::Singleton is
 the same thing with a few more features.  Its purpose to simplify singleton
 application creation.  My understanding was it would only allow a single
 instance of the object to be created for each request, not forever.  Please
 explain your reasoning.  Thanks. --JAK

 On 9/23/07, Philippe M. Chiasson [EMAIL PROTECTED] wrote:
 
  jk jk wrote:
   I'm trying to port a preexisting CGI app to mod_perl2 and could use
  some
   help.
  
   Here goes a test case that should illustrate my problem:
  
   The code pasted below loads the page properly the first time it's
   accessed.  However, upon multiple reloads in firefox, the headers
  either
   disappear altogether or the page is downloaded in the download
  manager.
   I assume this is because the wrong $r object is being accessed by the
   request?  In any case, I'm at a loss and would really appreciate some
   input.  Thanks in advance.
   [...]
  
   =
   File: testme/testmod.pm
   =
  
   package testme::testmod;
  
   use Apache2::RequestUtil;
   use strict;
  
   use base qw /Class::Singleton/;
 
  ^^
 
  From the documentation of Class::Singleton:
 
  # this only gets called the first time instance() is called
 
   sub _new_instance{
  
   my ( $class, $r ) = @_;
  
   my $self = {};
  
   bless $self, $class;
  
   $self-{r} = $r;
  
   return ( $self );
  
   }
 
  So effectively, your code will capture the $r (once for each child)
  from the first request and keep it forever. Trying to use it for
  subsequent
  requests will cause the kind of problems you've seen.
 
  
  Philippe M. Chiasson GPG: F9BFE0C2480E7680 1AE53631CB32A107 88C3A5A5
  http://gozer.ectoplasm.org/   m/gozer\@(apache|cpan|ectoplasm)\.org/
 
 
 



Re: Problem with RequestRec and Headers

2007-09-23 Thread Perrin Harkins
On 9/23/07, jk jk [EMAIL PROTECTED] wrote:
 I've been trying to use Apache::Singleton::Request under the assumption that
 you're right about Class::Singleton being the crux of the issue.
 Unfortunately, I can't get it working under Apache2.  Is there a different
 module for mp2/apache2 ?

It should be easy to port if you want to.  I wonder why you're trying
to use a singleton at all though.  It seems like either you should
create a new object every time, or just use class methods if you don't
need an object.  If this was just to get access to the request object,
you don't need it.  You can always get the request object from
anywhere using Apache2::RequestUtil.

By the way, a quick look at Class::Singleton confirms what Philippe
said: the instance() method just returns an existing instance after
the first call and ignores all parameters.  It's not a mod_perl
incomaptibilty; it's the intended behavior of the module.

- Perrin


Re: Problem with RequestRec and Headers

2007-09-23 Thread jk jk
I'm trying to port a pre-existing application built using a singleton
design.  Various class instances use a __PACKAGE__::getInstance() method to
get a handle on the current request's instance.  getInstance just returns
$self which is a global variable.  This works as a cgi, since every request
is in a separate interpreter.  It does not in mod_perl for obvious reasons.
It was my impression that the most direct method of porting would be to use
Class::Singleton (Apache::Singleton::Request).  Any other ideas?  Thanks.
--JAK

On 9/23/07, Perrin Harkins [EMAIL PROTECTED] wrote:

 On 9/23/07, jk jk [EMAIL PROTECTED] wrote:
  I've been trying to use Apache::Singleton::Request under the assumption
 that
  you're right about Class::Singleton being the crux of the issue.
  Unfortunately, I can't get it working under Apache2.  Is there a
 different
  module for mp2/apache2 ?

 It should be easy to port if you want to.  I wonder why you're trying
 to use a singleton at all though.  It seems like either you should
 create a new object every time, or just use class methods if you don't
 need an object.  If this was just to get access to the request object,
 you don't need it.  You can always get the request object from
 anywhere using Apache2::RequestUtil.

 By the way, a quick look at Class::Singleton confirms what Philippe
 said: the instance() method just returns an existing instance after
 the first call and ignores all parameters.  It's not a mod_perl
 incomaptibilty; it's the intended behavior of the module.

 - Perrin



Re: Problem with RequestRec and Headers

2007-09-23 Thread bharanee rathna
AFAIK Apache::Singleton works for MP2, also it does both per request and per
process singletons.


On 9/24/07, jk jk [EMAIL PROTECTED] wrote:

 I've been trying to use Apache::Singleton::Request under the assumption
 that you're right about Class::Singleton being the crux of the issue.
 Unfortunately, I can't get it working under Apache2.  Is there a different
 module for mp2/apache2 ?  Thanks for your patience. --JAK

 On 9/23/07, jk jk [EMAIL PROTECTED] wrote:
 
  Why is that?  Class::Singleton is modperl compatible, Apache::Singleton
  is the same thing with a few more features.  Its purpose to simplify
  singleton application creation.  My understanding was it would only allow a
  single instance of the object to be created for each request, not forever.
  Please explain your reasoning.  Thanks. --JAK
 
  On 9/23/07, Philippe M. Chiasson  [EMAIL PROTECTED] wrote:
  
   jk jk wrote:
I'm trying to port a preexisting CGI app to mod_perl2 and could use
   some
help.
   
Here goes a test case that should illustrate my problem:
   
The code pasted below loads the page properly the first time it's
accessed.  However, upon multiple reloads in firefox, the headers
   either
disappear altogether or the page is downloaded in the download
   manager.
I assume this is because the wrong $r object is being accessed by
   the
request?  In any case, I'm at a loss and would really appreciate
   some
input.  Thanks in advance.
[...]
   
=
File: testme/testmod.pm
=
   
package testme::testmod;
   
use Apache2::RequestUtil;
use strict;
   
use base qw /Class::Singleton/;
  
   ^^
  
   From the documentation of Class::Singleton:
  
   # this only gets called the first time instance() is called
  
sub _new_instance{
   
my ( $class, $r ) = @_;
   
my $self = {};
   
bless $self, $class;
   
$self-{r} = $r;
   
return ( $self );
   
}
  
   So effectively, your code will capture the $r (once for each child)
   from the first request and keep it forever. Trying to use it for
   subsequent
   requests will cause the kind of problems you've seen.
  
  
   
   Philippe M. Chiasson GPG: F9BFE0C2480E7680 1AE53631CB32A107
   88C3A5A5
   http://gozer.ectoplasm.org/
   m/gozer\@(apache|cpan|ectoplasm)\.org/
  
  
  
 



Re: Newbie - Samples or Tutorials

2007-09-23 Thread Foo JH

aqua wrote:

Thanks for your email. I am actually looking for current mod perl related 
tutorials and not just Perl related. This HoptScripts site contains 3 mod_perl related 
tutorials and they are very old (2000).
Why not drop by Amazon and pick up the mod_perl 2 book instead? It's 
just released:

http://www.amazon.com/mod_perl-Users-Guide-Stas-Bekman/dp/0977920119


Re: [OT] Client authentication

2007-09-23 Thread Philippe M. Chiasson
Bill Moseley wrote:
 On Sun, Sep 23, 2007 at 01:44:44AM -0700, Philippe M. Chiasson wrote:

 If the concern is that someone might spoof an IP address then the
 shared secret seems adequate.
 If the secret is ever compromised, you have to update every single
 client/server out there. If a client cert is compromised, you revoke it
 and carry on doing business as usual.

 If the concern is that someone might hack a client machine and make
 fake requests to the server then it seems the hacker would have access to
 the client cert just as easily as the shared secret.
 Yup, but you can revoke a client-cert, not a shared secret...
 
 Hum, perhaps I'm missing something.
 
 The shared secret can be a single pair between a specific client and
 the server.
 
 The server is setup with a list of known secrets, so it's possible
 that each client has its own secret pair with the server.  If a client
 is compromised then just that secret pair is removed/replaced and
 other clients continue.

That's correct, however, the idea with public-key crypto (as in this case)
is that the key generation can be handled by the clients themselves, and
the CA's responsability is just signing stuff.

But in your case, if managing shared-secrets in this way is not a problem,
then it doesn't matter what approach you chose.

 But, as I said, I have not used client certs before so I might be
 missing a key point.
 Oh, and a bonus point. Client applications can generate their own certs,
 and only get your CA to sign them.  It's a much neater approach IMO. And
 totally worth the slight extra complexity of running your own CA.
 
 Plus, it all happens at a higher level.  The shared secret has to be
 at the application, where mod_ssl can handle client cert.
 
 It's just something I need to learn more about...

Applied Cryptography - Bruce Schneier (http://www.amazon.com/dp/0471117099)


Philippe M. Chiasson GPG: F9BFE0C2480E7680 1AE53631CB32A107 88C3A5A5
http://gozer.ectoplasm.org/   m/gozer\@(apache|cpan|ectoplasm)\.org/



signature.asc
Description: OpenPGP digital signature


Re: Problem with RequestRec and Headers

2007-09-23 Thread jk jk
I looked at the source.  It does seem to be written for both.  My
understanding was that everything for apache2 was supposed to be in the
Apach2:: namespace.  In any case I posted the install error below.  Does an
environment variable need to be set?


perl Makefile.PL
Warning: prerequisite mod_perl 0 not found.
Writing Makefile for Apache::Singleton

If I install it anyway I get [Sun Sep 23 15:09:49 2007] [error] Can't
locate Apache/RequestUtil.pm in @INC (@INC contains:..

Thanks. --JAK

On 9/23/07, bharanee rathna [EMAIL PROTECTED] wrote:

 AFAIK Apache::Singleton works for MP2, also it does both per request and
 per process singletons.


 On 9/24/07, jk jk  [EMAIL PROTECTED] wrote:
 
  I've been trying to use Apache::Singleton::Request under the assumption
  that you're right about Class::Singleton being the crux of the issue.
  Unfortunately, I can't get it working under Apache2.  Is there a different
  module for mp2/apache2 ?  Thanks for your patience. --JAK
 
  On 9/23/07, jk jk [EMAIL PROTECTED]  wrote:
  
   Why is that?  Class::Singleton is modperl compatible,
   Apache::Singleton is the same thing with a few more features.  Its purpose
   to simplify singleton application creation.  My understanding was it would
   only allow a single instance of the object to be created for each request,
   not forever.  Please explain your reasoning.  Thanks. --JAK
  
   On 9/23/07, Philippe M. Chiasson  [EMAIL PROTECTED] wrote:
   
jk jk wrote:
 I'm trying to port a preexisting CGI app to mod_perl2 and could
use some
 help.

 Here goes a test case that should illustrate my problem:

 The code pasted below loads the page properly the first time it's
 accessed.  However, upon multiple reloads in firefox, the headers
either
 disappear altogether or the page is downloaded in the download
manager.
 I assume this is because the wrong $r object is being accessed by
the
 request?  In any case, I'm at a loss and would really appreciate
some
 input.  Thanks in advance.
 [...]

 =
 File: testme/testmod.pm
 =

 package testme::testmod;

 use Apache2::RequestUtil;
 use strict;

 use base qw /Class::Singleton/;
   
^^
   
From the documentation of Class::Singleton:
   
# this only gets called the first time instance() is called
   
 sub _new_instance{

 my ( $class, $r ) = @_;

 my $self = {};

 bless $self, $class;

 $self-{r} = $r;

 return ( $self );

 }
   
So effectively, your code will capture the $r (once for each child)
from the first request and keep it forever. Trying to use it for
subsequent
requests will cause the kind of problems you've seen.
   
   

Philippe M. Chiasson GPG: F9BFE0C2480E7680 1AE53631CB32A107
88C3A5A5
http://gozer.ectoplasm.org/
m/gozer\@(apache|cpan|ectoplasm)\.org/