Re: Lost connection to MySQL server during query (was "Segfault when connecting during Apache startup")

2008-07-01 Thread Tobias Kremer
Quoting Perrin Harkins <[EMAIL PROTECTED]>:
> On a closer look, you're not.  You are keeping around your $foo
> closure variable in handler(), as well as putting it in a global.
> It's not obvious why that causes this problem.  If you want to
> determine whether Apache::DBI is malfunctioning for you in some way,
> I'd suggest just removing it and seeing if the problem goes away.
> Your test app should work fine without it.

Removing Apache::DBI makes the errors go away. Using two different connection
strings for my initial connection during startup and the subsequent connections
in the handler() method also works. So everything looks like the connection made
during startup is indeed re-used somehow, although Apache::DBI correctly reports
that it won't cache it. Maybe now's the time to file a bug report ...

--Tobias


[MP2]how to catch the response body of a subrequest?

2008-07-01 Thread titetluc titetluc
Hello all,

I am facing a problem: I would like to call sub-requests, but the content of
these sub-requests should not 'pollute' the main request.

Some times ago, Torsten Foertsch sent the same question on the mod_perl
mailing list (see http://marc.info/?l=apache-modperl&m=111720092815754&w=2)

The answer from Stas Bekman was to use ... the sub request API.

I reread the documentation but the solution is not very explicit.
Could someone give me an example to trap the response body of the subrequest
? (Maybe  the solution is to use filters but how can I create this filter
)

Thanks


Re: [MP2]how to catch the response body of a subrequest?

2008-07-01 Thread Torsten Foertsch
On Tue 01 Jul 2008, titetluc titetluc wrote:
> I am facing a problem: I would like to call sub-requests, but the content
> of these sub-requests should not 'pollute' the main request.

  my $content='';
  my $subr=$r->lookup_uri( $tmpl );
  $subr->add_output_filter( sub {
  my ($f, $bb) = @_;
  while (my $e = $bb->first) {
$e->read(my $buf);
$content.=$buf;
$e->delete;
  }
  return Apache2::Const::OK;
} );
  $subr->run;

Torsten

--
Need professional mod_perl support?
Just hire me: [EMAIL PROTECTED]


Re: [MP2]how to catch the response body of a subrequest?

2008-07-01 Thread titetluc titetluc
Less than half an hour to have an answer 
And the code is correctly running (my work now is to understand this cryptic
code ;-))

Thanks a lot


2008/7/1 Torsten Foertsch <[EMAIL PROTECTED]>:

> On Tue 01 Jul 2008, titetluc titetluc wrote:
> > I am facing a problem: I would like to call sub-requests, but the content
> > of these sub-requests should not 'pollute' the main request.
>
>   my $content='';
>  my $subr=$r->lookup_uri( $tmpl );
>  $subr->add_output_filter( sub {
>  my ($f, $bb) = @_;
>  while (my $e = $bb->first) {
>$e->read(my $buf);
>$content.=$buf;
>$e->delete;
>  }
>  return Apache2::Const::OK;
>} );
>  $subr->run;
>
> Torsten
>
> --
> Need professional mod_perl support?
> Just hire me: [EMAIL PROTECTED]
>


Re: Lost connection to MySQL server during query (was "Segfault when connecting during Apache startup")

2008-07-01 Thread Perrin Harkins
On Tue, Jul 1, 2008 at 3:42 AM, Tobias Kremer <[EMAIL PROTECTED]> wrote:
> Removing Apache::DBI makes the errors go away.

Ok.  First, check that you're on the latest version.  Then, turn on
the debug flag and see if it thinks it is reusing the startup
connection or not.

- Perrin


Re: Lost connection to MySQL server during query (was "Segfault when connecting during Apache startup")

2008-07-01 Thread Tobias Kremer
Quoting Perrin Harkins <[EMAIL PROTECTED]>:
> Ok.  First, check that you're on the latest version.  Then, turn on
> the debug flag and see if it thinks it is reusing the startup
> connection or not.

Yes, I'm using the latest 1.07 release. I already had the debug flag on and it's
correctly telling me that it's "skipping connection during server startup".

--Tobias


Re: Lost connection to MySQL server during query (was "Segfault when connecting during Apache startup")

2008-07-01 Thread Perrin Harkins
On Tue, Jul 1, 2008 at 9:56 AM, Tobias Kremer <[EMAIL PROTECTED]> wrote:
> Yes, I'm using the latest 1.07 release. I already had the debug flag on and 
> it's
> correctly telling me that it's "skipping connection during server startup".

Yes, but what does it tell you on the first connection AFTER startup?
It should say whether it's making a new connection or not.

- Perrin


Re: Lost connection to MySQL server during query (was "Segfault when connecting during Apache startup")

2008-07-01 Thread Tobias Kremer
Quoting Perrin Harkins <[EMAIL PROTECTED]>:
> Yes, but what does it tell you on the first connection AFTER startup?
> It should say whether it's making a new connection or not.

Here's the complete debug output which suggests that the connection during
startup is reused for the first request.

On server start:

20097 Apache::DBI  skipping connection during server startup, read the docu !!
20097 Apache::DBI  push PerlCleanupHandler
20097 Apache::DBI  need ping: yes
20097 Apache::DBI  new connect to 'foo:bar...'
20097 Apache::DBI  disconnect (overloaded)

On first request:

20099 Apache::DBI  need ping: yes
20099 Apache::DBI  already connected to 'foo:bar...'
20099 Apache::DBI  PerlCleanupHandler

--Tobias


[MP2]lookup_uri and HTTPS

2008-07-01 Thread titetluc titetluc
Hello all,

I am writing an handler generating sub-requests by using the lookup_uri and
run (Apache2::SubRequest) methods.
My question is : is it technically possible to generate HTTPS sub-request (I
observed that sub-requests were using HTTP) using the mod_perl API  ?
If yes, which API do I have to use (I can not find any examples, or I tried
the APR::URI class but unsuccessfully) ?
If not, which solution is possible (using LWP ?)

Thanks


Re: [MP2]lookup_uri and HTTPS

2008-07-01 Thread André Warnier

titetluc titetluc wrote:

My question is : is it technically possible to generate HTTPS sub-request (I
observed that sub-requests were using HTTP) using the mod_perl API  ?


Forgive my impertinence, but on the face of it, that question does not 
seem to make a lot of sense.
HTTP or HTTPS are protocols that carry requests and responses over "the 
outside world" (e.g. the Internet or Intranet).  A sub-request is 
something that happens totally inside of Apache, so it does not really 
have (nor need) a protocol.  You just ask Apache to return the result of 
getting "/location/object", without ever leaving the context of Apache 
itself.


Now, a REDIRECT going back to the browser is another story, but above 
you mention sub-requests, don't you ?


André



Re: [MP2]lookup_uri and HTTPS

2008-07-01 Thread Torsten Foertsch
On Tue 01 Jul 2008, titetluc titetluc wrote:
> I am writing an handler generating sub-requests by using the lookup_uri and
> run (Apache2::SubRequest) methods.
> My question is : is it technically possible to generate HTTPS sub-request
> (I observed that sub-requests were using HTTP)

No, none of the protocols is used to make subreqs. HTTP/HTTPS are network 
protocols. With subreqs there is no network. A subreq is like a recursive 
call of the same request answering machine. Hence, HTTPS? is irrelevant. 
Normally the document accessed via a subreq has to be accessible locally.

> using the mod_perl API  ?  If 
> yes, which API do I have to use (I can not find any examples, or I tried
> the APR::URI class but unsuccessfully) ?
> If not, which solution is possible (using LWP ?)

But it can be any kind of document apache can serve. So it can be a regular 
file, something dynamically created (CGI/PHP/modperl etc) or even a document 
for which the current server acts as proxy.

So in your case I see 2 options:

1) implement the included document via a CGI/modperl handler using LWP or 
similar

2) use mod_proxy as reverse proxy

In both cases it's not possible to proxy an established SSL identity (client 
certificate) to the backend server due to the nature of SSL. Nor can your 
client verify the identity of the backend.

If possible I'd go for the mod_proxy version. 1) it doesn't load perl routines 
in memory. 2) it passes the data an almost as fast as possible whereas 
homegrown LWP solutions tend to buffer the whole document before sending any 
output.

But mod_proxy has also drawbacks. It is very difficult to make a POST request 
to the backend this way and feed it some data. I once had a similar problem 
when I wanted to include a proxied document and pass on the POST input of the 
original request to the backend. In the end I did it in Perl.

Torsten

--
Need professional mod_perl support?
Just hire me: [EMAIL PROTECTED]


Re: Lost connection to MySQL server during query (was "Segfault when connecting during Apache startup")

2008-07-01 Thread Perrin Harkins
On Tue, Jul 1, 2008 at 10:08 AM, Tobias Kremer <[EMAIL PROTECTED]> wrote:
> On server start:
> 
> 20097 Apache::DBI  skipping connection during server startup, read the docu !!
> 20097 Apache::DBI  push PerlCleanupHandler
> 20097 Apache::DBI  need ping: yes
> 20097 Apache::DBI  new connect to 'foo:bar...'
> 20097 Apache::DBI  disconnect (overloaded)

That looks like two different connect attempts.  The line following
the "skipping" part is a return, and then it must come back in later.

How are you loading this?  With a PerlModule call?  Can you try
loading it from a Perl section like this?


  use MyModule;


- Perrin