Re: Issuing a client side HTTP request from a module

2010-04-23 Thread alin vasile
I don't know. You can try it. if not, third-party libraries should help





From: Some Guy teknos...@gmail.com
To: modules-dev@httpd.apache.org
Sent: Fri, April 23, 2010 12:10:47 AM
Subject: Re: Issuing a client side HTTP request from a module

Wow that looks pretty straightforward.  Can this be issued from the parent?

SB

On Thu, Apr 22, 2010 at 4:21 PM, alin vasile alinachegal...@yahoo.comwrote:

 check the thread Doing a subrequest with ap_run_sub_req in the same list




 
 From: Some Guy teknos...@gmail.com
 To: modules-dev@httpd.apache.org
 Sent: Thu, April 22, 2010 5:14:07 PM
 Subject: Re: Issuing a client side HTTP request from a module

 I don't really need keepalive.  Just a really basic http request.  However,
 this would be in a non request handler thread, so I'll have no initial
 request_rec to create a subrequest from.  It would also be in the parent
 process via a monitor hook.  I see the mod_proxy create_worker and
 initialize_worker, but the latter call requires a server_rec, which I won't
 have.

 SB

 On Thu, Apr 22, 2010 at 3:48 AM, Nick Kew n...@apache.org wrote:

 
  On 22 Apr 2010, at 08:25, Sorin Manolache wrote:
 
   As Nick says, the common solution are subrequests. However, note that
   subrequests are not kept alive.
 
  Backend connections may be kept alive or closed, as detailed in
  the mod_proxy docs!
 
  If you want to implement keepalive without mod_proxy, that's a lot
  of wheel to reinvent.
 
  --
  Nick Kew
 








  

Re: My own module and catching Proxy Request

2010-04-23 Thread Petr Hracek
2010/4/22 Petr Hracek phrac...@gmail.com

 Hello *,

 I hope that I am sending those question to the correct discussion list.

 In my Apache2 (2.2.3) configuration file I have:
 VirtualHost _default_:443
 SSLEngine on
 DocumentRoot /opt/apache/htdocs/ssldocs
 ProxyPass   /PAC/   http://192.168.187.101:8080/PACCBAdmin
 ProxyPassReverse/PAC/   http://192.168.187.150:8080/PACCBAdmin/
 RewriteEngine on
 RewriteCond %{REQUEST_METHOD} ^TRACE
 RewriteRule .* - [F]
 RewriteMap unity txt:/opt/apache/conf/unity.map
 RewriteRule ^/([^/]+)$  ${unity:$1|/$1} [L]
 RewriteRule ^/([^/]+)/(.*)  ${unity:$1|/opt/apache/htdocs/ssldocs/$1}/$2
 [L]
 RewriteLog /var/log/apache2/rewrite_log
 RewriteLogLevel 3

 Location /PAC/
 ProxyPassReverseCookiePath /PACCBAdmin /PAC
 Order Allow,Deny
 Allow from all
 /Location

 /VirtualHost

 In the my modules which takes care about AAA, Security issues, etc.
 I would like to catch in my module when URL contains /PAC/ (which means
 that this is proxy) than it tell to module that this request is not a
 bussiness for them.
 Is it possible to do that somehow?
 I have found that r-proxyreq contains if the Request is Proxy or not.

 Thank you in advance
 --
 Best Regards / S pozdravem
 Petr Hracek


Hello *,

May be I have asked wrongly.

How can I detect if the request from browser if Proxy or not?
How should I configure apache for that case?

-- 
Best Regards / S pozdravem
Petr Hracek


httpd trunk, apr/apu 1.4 branches and Linux

2010-04-23 Thread Jim Jagielski
(sorry for the cross-post but httpd-trunk and APR are now so
entwined that its required)...

OK... I've been playing around with building httpd-trunk
on Linux and I've been having troubles left and right (using
the 1.4 branches of both apr and apr-util installed right
in ./srclib)...

First of all, Ubuntu 8.10 can't even get past a top level
./buildconf (likely due to libtool issues (2.2.4)... But
Ubuntu 9.10 dies when getting to build apr-util due to
expat issues (can't find the system installed version and
the bundled version's config/make is toast)...

checking Expat 1.95.x... no
checking old Debian-packaged expat... no
checking old FreeBSD-packaged expat... no
checking Expat 1.0/1.1... no
  setting LDFLAGS to -L/usr/local/lib
  adding -I/usr/local/include to CPPFLAGS
checking Expat 1.95.x in /usr/local... no
  nulling LDFLAGS
  removed -I/usr/local/include from CPPFLAGS
configuring package in xml/expat now
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
/home/jim/src/asf/code/dev/httpd-trunk/srclib/apr-util/xml/expat/configure: 
line 3321: syntax error near unexpected token `lt_decl_varnames,'
/home/jim/src/asf/code/dev/httpd-trunk/srclib/apr-util/xml/expat/configure: 
line 3321: `lt_if_append_uniq(lt_decl_varnames, SED, , ,'
configure failed for xml/expat

For those who are working on httpd trunk and Linux, what
are you using?

Re: httpd trunk, apr/apu 1.4 branches and Linux

2010-04-23 Thread William A. Rowe Jr.
On 4/23/2010 7:58 AM, Jim Jagielski wrote:
 
 For those who are working on httpd trunk and Linux, what
 are you using?

Expat 2.0.1 or os vendor expat


Re: httpd trunk, apr/apu 1.4 branches and Linux

2010-04-23 Thread Jeff Trawick
On Fri, Apr 23, 2010 at 8:58 AM, Jim Jagielski j...@jagunet.com wrote:
 (sorry for the cross-post but httpd-trunk and APR are now so
 entwined that its required)...

 OK... I've been playing around with building httpd-trunk
 on Linux and I've been having troubles left and right (using
 the 1.4 branches of both apr and apr-util installed right
 in ./srclib)...

 First of all, Ubuntu 8.10 can't even get past a top level
 ./buildconf (likely due to libtool issues (2.2.4)... But
 Ubuntu 9.10 dies when getting to build apr-util due to
 expat issues (can't find the system installed version and
 the bundled version's config/make is toast)...

Hmmm...

my Ubuntu 9.10 x86

./buildconf
found apr source: srclib/apr
found apr-util source: srclib/apr-util
rebuilding srclib/apr/configure
buildconf: checking installation...
buildconf: python version 2.6.4 (ok)
buildconf: autoconf version 2.64 (ok)
buildconf: libtool version 1.5.26 (ok)
...
/home/trawick/svn/httpd-trunk-full/configure --enable-maintainer-mode
--prefix=/home/trawick/inst/23 --with-included-apr --with-ldap=ldap
--enable-maintainer-mode --enable-nonportable-atomics
--enable-VARIOUS-MODULES
configure: WARNING: unrecognized options: --with-ldap,
--enable-nonportable-atomics



 checking Expat 1.95.x... no

checking Expat 1.95.x... yes
  setting APRUTIL_EXPORT_LIBS to -lexpat
  setting APRUTIL_LIBS to -lexpat


 checking old Debian-packaged expat... no
 checking old FreeBSD-packaged expat... no
 checking Expat 1.0/1.1... no
  setting LDFLAGS to -L/usr/local/lib
  adding -I/usr/local/include to CPPFLAGS
 checking Expat 1.95.x in /usr/local... no
  nulling LDFLAGS
  removed -I/usr/local/include from CPPFLAGS
 configuring package in xml/expat now
 checking build system type... i686-pc-linux-gnu
 checking host system type... i686-pc-linux-gnu
 checking target system type... i686-pc-linux-gnu
 /home/jim/src/asf/code/dev/httpd-trunk/srclib/apr-util/xml/expat/configure: 
 line 3321: syntax error near unexpected token `lt_decl_varnames,'
 /home/jim/src/asf/code/dev/httpd-trunk/srclib/apr-util/xml/expat/configure: 
 line 3321: `lt_if_append_uniq(lt_decl_varnames, SED, , ,'
 configure failed for xml/expat


Re: httpd trunk, apr/apu 1.4 branches and Linux

2010-04-23 Thread Jim Jagielski

On Apr 23, 2010, at 9:31 AM, Jeff Trawick wrote:

 On Fri, Apr 23, 2010 at 8:58 AM, Jim Jagielski j...@jagunet.com wrote:
 (sorry for the cross-post but httpd-trunk and APR are now so
 entwined that its required)...
 
 OK... I've been playing around with building httpd-trunk
 on Linux and I've been having troubles left and right (using
 the 1.4 branches of both apr and apr-util installed right
 in ./srclib)...
 
 First of all, Ubuntu 8.10 can't even get past a top level
 ./buildconf (likely due to libtool issues (2.2.4)... But
 Ubuntu 9.10 dies when getting to build apr-util due to
 expat issues (can't find the system installed version and
 the bundled version's config/make is toast)...
 
 Hmmm...
 
 my Ubuntu 9.10 x86
 
 ./buildconf
 found apr source: srclib/apr
 found apr-util source: srclib/apr-util
 rebuilding srclib/apr/configure
 buildconf: checking installation...
 buildconf: python version 2.6.4 (ok)
 buildconf: autoconf version 2.64 (ok)
 buildconf: libtool version 1.5.26 (ok)

Weird... my default libtool is 2.2.6 under 9.10...


 
 
 checking Expat 1.95.x... no
 
 checking Expat 1.95.x... yes
  setting APRUTIL_EXPORT_LIBS to -lexpat
  setting APRUTIL_LIBS to -lexpat
 
 

So far, if I install libtool 2.2.6b, expat 2.0.1 and pcre 8.02
then I can get to at least a completed compile, both with Ubuntu
8.10 and 9.10.


Re: httpd trunk, apr/apu 1.4 branches and Linux

2010-04-23 Thread Jeff Trawick
On Fri, Apr 23, 2010 at 9:40 AM, Jim Jagielski j...@jagunet.com wrote:

 On Apr 23, 2010, at 9:31 AM, Jeff Trawick wrote:

 On Fri, Apr 23, 2010 at 8:58 AM, Jim Jagielski j...@jagunet.com wrote:
 (sorry for the cross-post but httpd-trunk and APR are now so
 entwined that its required)...

 OK... I've been playing around with building httpd-trunk
 on Linux and I've been having troubles left and right (using
 the 1.4 branches of both apr and apr-util installed right
 in ./srclib)...

 First of all, Ubuntu 8.10 can't even get past a top level
 ./buildconf (likely due to libtool issues (2.2.4)... But
 Ubuntu 9.10 dies when getting to build apr-util due to
 expat issues (can't find the system installed version and
 the bundled version's config/make is toast)...

 Hmmm...

 my Ubuntu 9.10 x86

 ./buildconf
 found apr source: srclib/apr
 found apr-util source: srclib/apr-util
 rebuilding srclib/apr/configure
 buildconf: checking installation...
 buildconf: python version 2.6.4 (ok)
 buildconf: autoconf version 2.64 (ok)
 buildconf: libtool version 1.5.26 (ok)

 Weird... my default libtool is 2.2.6 under 9.10...

Ahh, I have my own autoconf and libtool in /usr/local/bin.





 checking Expat 1.95.x... no

 checking Expat 1.95.x... yes
  setting APRUTIL_EXPORT_LIBS to -lexpat
  setting APRUTIL_LIBS to -lexpat



 So far, if I install libtool 2.2.6b, expat 2.0.1 and pcre 8.02
 then I can get to at least a completed compile, both with Ubuntu
 8.10 and 9.10.


Re: HTTP trailers?

2010-04-23 Thread Brian J. France
For those following this thread, here is a update.

You can build a module that is able to insert a trailer by adding a filter and 
ap_hook_create_request call.

You have to have a ap_hook_create_request call that runs after http_core.c and 
loops over the r-output_filters and removes ap_content_length_filter_handle.

Then you have a AP_FTYPE_TRANSCODE+1 filter (chunk filter is AP_FTYPE_TRANSCODE 
and you want to be after) that loops over the brigade looking for a bucket that 
is:

  ASCII_ZERO ASCII_CRLF ASCII_CRLF

followed by a APR_BUCKET_IS_EOS bucket.

Remove it and replaces it with:

  ASCII_ZERO ASCII_CRLF tailer string ASCII_CRLF


and you have chunked encoding with a trailer.

Brian


On Apr 22, 2010, at 10:39 PM, Brian J. France wrote:
 On Apr 22, 2010, at 8:40 PM, Mark Nottingham wrote:
 I couldn't find any obvious way to set HTTP trailers in Apache 2.x without 
 taking over all response processing (a la nph).
 
 Did I miss something?
 
 
 I started hacking on this at work, but got the point where I can't insert a 
 filter in the right spot.
 
 The problem I ran into is that if the Content-Length header is set (which 
 ap_content_length_filter_handle sets), then the chunking filter doesn't kick 
 in.  Something about wanting to use sendfile so don't chunk.
 
 I can't get a filter inserted after ap_content_length_filter_handle, but 
 before ap_http_header_filter (which adds the chunking filter).
 
 My plan was to insert a filter that removes the Content-Length header so the 
 response will be chunked and add another filter after the chunking filter 
 that would search for ASCII_ZERO ASCII_CRLF ASCII_CRLF and insert the trailer 
 data before the last ASCII_CRLF.  This was just a proof of concept to see if 
 it would work and output data in the right format.
 
 If it all worked my plan was add a trailers hook and call the hook in 
 chunk_filter.c in place of the /* trailers */ comment.
 
 Brian
 
 After typing this up and working through it again, I think I can add a filter 
 AP_FTYPE_TRANSCODE+1 for the after chunking filter and AP_FTYPE_PROTOCOL+1 
 and get them to be in the right order.  Will test that out now.
 



Re: HTTP trailers?

2010-04-23 Thread William A. Rowe Jr.
On 4/23/2010 9:03 AM, Brian J. France wrote:
 
 You can build a module that is able to insert a trailer by adding a filter 
 and ap_hook_create_request call.

But doesn't this defeat the purpose of using a modular server
architecture?  It seems this should be a facility of the core HTTP
filter, if anyone wants to offer the patch for 2.3.


Re: httpd trunk, apr/apu 1.4 branches and Linux

2010-04-23 Thread Jim Jagielski

On Apr 23, 2010, at 9:58 AM, Jeff Trawick wrote:

 On Fri, Apr 23, 2010 at 9:40 AM, Jim Jagielski j...@jagunet.com wrote:
 
 On Apr 23, 2010, at 9:31 AM, Jeff Trawick wrote:
 
 
 ./buildconf
 found apr source: srclib/apr
 found apr-util source: srclib/apr-util
 rebuilding srclib/apr/configure
 buildconf: checking installation...
 buildconf: python version 2.6.4 (ok)
 buildconf: autoconf version 2.64 (ok)
 buildconf: libtool version 1.5.26 (ok)
 
 Weird... my default libtool is 2.2.6 under 9.10...
 
 Ahh, I have my own autoconf and libtool in /usr/local/bin.
 

Gotcha... 2.2.6b seems to work, but needs to be built
by hand.


My own module and catching Proxy Request

2010-04-23 Thread Petr Hracek
Authorization is based on username/password stored in database.
First of all I authenticate user and afterwards redirection is done.

I have following RewriteRule but it does not work at all.

RewriteRule ^/([^/]+)$  ${unity:$1|/$1} [L]
RewriteRule ^/([^/]+)/(.*)  ${unity:$1|/opt/apache/htdocs/ssldocs/$1}/$2 [L]
which is used for my module and
in location is:
Location /PAC/
ProxyPass   http://192.168.187.150:8080/PACCBAdmin
ProxyPassReversehttp://192.168.187.150:8080/PACCBAdmin/

ProxyPassReverseCookiePath  /PACCBAdmin/PAC
Order Allow,Deny
Allow from all
/Location

I hope that it is correct.
BR

Petr

2010/4/23 Jeffrey E Burgoyne burgo...@keenuh.com

 I think that would require two modules as the authorization and redirect
 hooks happen at different phases. I've actually written modules for both
 of these phases, it is pretty easy as far as modules go. And remember, the
 authorization module will ALWAYS be called before the redirection modules,
 so you already know if you hit your redirection module that authorization
 was correct.

 You may not, however, have to write a module. You may be able to use one
 of the already provided auth modules plus mod_rewrite to do this.

 Now your authorization, is it based on a username/password, or some other
 restriction (i.e. connecting IP)?

 If username/password, is it basic authentication controlled? If not, I've
 no experience in that area. If it is, then what is the DB used?


  Thanks but I forgott to mentioned that my module makes an authorization
  against database and I would like to catch that if user access some proxy
  than first of all he has to be authorized by my module and afterwards it
  will be redirect to the proxy. Is it possible to do that somehow?
 
  Thanks
 
  2010/4/23 Jeffrey E Burgoyne burgo...@keenuh.com
 
  I'm not using it in a specific module, although you easily could.
 
  I'm not at work today, but it goes something like this :
 
  I want to force all hits to go through our front end web server which
  acts
  as a reverse proxy to the back end apache server. The logic is if there
  is
  no X_FORWARDED_FOR (meaning it was not proxied), then redirect the hit
  to
  the front end reverse proxy server. I used the logic that if the
  X_FORWARDED_FOR did not start with 1-9 then it was not a valid proxied
  request :
 
  RewriteCond   %{X_FORWARDED_FOR} !^[1-9]
  RewriteRule   /(.*) http://proxiedhost.ca/$1 [R,L]
 
 
  For your module you can access the headers from the request pool and
  look
  for X_FORWARDED_FOR.
 
  Note it may be more complicated depending on your setup. Some load
  balancers put that value into the HTTP stream, so you may have to
  account
  for that. If it runs through multiple proxies (perhaps including a load
  balancer), the IP's will be list form comma seperated.
 
  Note too I have DNS lookups off, so if you have them on I suspect you
  would get the DNS name, not the IP, but I cannot say with 100%
  certainty.
 
 
  for example,
 
  if a client from 192.168.2.10 access 10.10.10.10, the web server sees :
 
  connecting IP - 192.168.2.10
  X_FORWARDED_HEADER - blank
 
  If the server at 10.10.10.10 proxies to 10.20.20.20 the web server at
  the
  .20 address sees :
 
  connecting IP - 10.10.10.01
  X_FORWARDED_HEADER - 192.168.2.10
 
 
 
 
 
 
   How do you have configured RewriteRule together with your own module?
   Could you please send me more details or example?
  
   Thanks
   Petr
  
   2010/4/23 Jeffrey E Burgoyne burgo...@keenuh.com
  
   I use the environment variable X_FORWARDED_FOR
  
  
   http://en.wikipedia.org/wiki/X-Forwarded-For
  
  
   with mod_rewrite to determine if it came via a proxy or not.
  
   It may be of use to you.
  
  
  
2010/4/22 Petr Hracek phrac...@gmail.com
   
Hello *,
   
I hope that I am sending those question to the correct discussion
   list.
   
In my Apache2 (2.2.3) configuration file I have:
VirtualHost _default_:443
SSLEngine on
DocumentRoot /opt/apache/htdocs/ssldocs
ProxyPass   /PAC/   http://192.168.187.101:8080/PACCBAdmin
ProxyPassReverse/PAC/
   http://192.168.187.150:8080/PACCBAdmin/
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .* - [F]
RewriteMap unity txt:/opt/apache/conf/unity.map
RewriteRule ^/([^/]+)$  ${unity:$1|/$1} [L]
RewriteRule ^/([^/]+)/(.*)
   ${unity:$1|/opt/apache/htdocs/ssldocs/$1}/$2
[L]
RewriteLog /var/log/apache2/rewrite_log
RewriteLogLevel 3
   
Location /PAC/
ProxyPassReverseCookiePath /PACCBAdmin /PAC
Order Allow,Deny
Allow from all
/Location
   
/VirtualHost
   
In the my modules which takes care about AAA, Security issues,
  etc.
I would like to catch in my module when URL contains /PAC/ (which
   means
that this is proxy) than it tell to module that this request is
  not a
bussiness for them.
Is it possible to do that 

Re: HTTP trailers?

2010-04-23 Thread Brian J. France

On Apr 23, 2010, at 10:08 AM, William A. Rowe Jr. wrote:

 On 4/23/2010 9:03 AM, Brian J. France wrote:
 
 You can build a module that is able to insert a trailer by adding a filter 
 and ap_hook_create_request call.
 
 But doesn't this defeat the purpose of using a modular server
 architecture?  It seems this should be a facility of the core HTTP
 filter, if anyone wants to offer the patch for 2.3.


I agree, my module was more of a proof of concept that I can do it and then get 
some other server to able able to use it.

Not sure what the best solution would be because multiple things need to 
happen.  First part is you have to force chunk encoding either by removing 
content_length filter or tweaking the code to not add it if doing a trailer 
(which you might not know until it is time to insert a tailer).

Then you have to tweak modules/http/chunk_filter.c to allow others to insert a 
trailer, like adding a ap_hook_http_trailer or a optional function for 
inserting it.  I don't know if multiple modules should be allowed to add a 
trailer, if you do how to you join them since a trailer is nothing but a string 
ending with ASCII_CRLF (just strcat?).  Should we just grab 
r-notes['http_trailer'] and let modules just add/set/append values?

I think there is a bigger design discussion that should happen, but I might 
have a patch down the road as a starter if all goes well at work.

Brian



Re: HTTP trailers?

2010-04-23 Thread Jeff Trawick
On Fri, Apr 23, 2010 at 11:25 AM, Brian J. France br...@brianfrance.com wrote:

 On Apr 23, 2010, at 10:08 AM, William A. Rowe Jr. wrote:

 On 4/23/2010 9:03 AM, Brian J. France wrote:

 You can build a module that is able to insert a trailer by adding a filter 
 and ap_hook_create_request call.

 But doesn't this defeat the purpose of using a modular server
 architecture?  It seems this should be a facility of the core HTTP
 filter, if anyone wants to offer the patch for 2.3.


 I agree, my module was more of a proof of concept that I can do it and then 
 get some other server to able able to use it.

 Not sure what the best solution would be because multiple things need to 
 happen.  First part is you have to force chunk encoding either by removing 
 content_length filter or tweaking the code to not add it if doing a trailer 
 (which you might not know until it is time to insert a tailer).

 Then you have to tweak modules/http/chunk_filter.c to allow others to insert 
 a trailer, like adding a ap_hook_http_trailer or a optional function for 
 inserting it.  I don't know if multiple modules should be allowed to add a 
 trailer, if you do how to you join them since a trailer is nothing but a 
 string ending with ASCII_CRLF (just strcat?).  Should we just grab 
 r-notes['http_trailer'] and let modules just add/set/append values?

 I think there is a bigger design discussion that should happen, but I might 
 have a patch down the road as a starter if all goes well at work.

This is probably naive, but something to take pot shots at...

use r-trailers_out

non-empty r-trailers_out could force chunked encoding, as well as
convey the trailers themselves

500 error if trailers set by the time chunking decision is made and
caller can't handle

consider logging msg if trailers found after response already started
but trailers can't be sent for some reason (i.e., output filter adds
trailer but trailers can't be sent)

suppress-trailers or similar envvar probably needed for problematic clients


RE: HTTP trailers?

2010-04-23 Thread Plüm, Rüdiger, VF-Group
 

 -Original Message-
 From: Jeff Trawick 
I think there is a bigger design discussion that should 
 happen, but I might have a patch down the road as a starter 
 if all goes well at work.
 
 This is probably naive, but something to take pot shots at...
 
 use r-trailers_out
 
 non-empty r-trailers_out could force chunked encoding, as well as
 convey the trailers themselves
 
 500 error if trailers set by the time chunking decision is made and
 caller can't handle
 
 consider logging msg if trailers found after response already started
 but trailers can't be sent for some reason (i.e., output filter adds
 trailer but trailers can't be sent)
 
 suppress-trailers or similar envvar probably needed for 
 problematic clients
 

+1. Sounds reasonable.

Regards

Rüdiger


Re: HTTP trailers?

2010-04-23 Thread William A. Rowe Jr.
On 4/23/2010 10:25 AM, Brian J. France wrote:
 
 On Apr 23, 2010, at 10:08 AM, William A. Rowe Jr. wrote:
 
 On 4/23/2010 9:03 AM, Brian J. France wrote:

 You can build a module that is able to insert a trailer by adding a filter 
 and ap_hook_create_request call.

 But doesn't this defeat the purpose of using a modular server
 architecture?  It seems this should be a facility of the core HTTP
 filter, if anyone wants to offer the patch for 2.3.
 
 
 I agree, my module was more of a proof of concept that I can do it and then 
 get some other server to able able to use it.

:)

 Not sure what the best solution would be because multiple things need to 
 happen.  First part is you have to force chunk encoding either by removing 
 content_length filter or tweaking the code to not add it if doing a trailer 
 (which you might not know until it is time to insert a tailer).

Well, you also have to insert the 'Trailers' header, which must be known at the
beginning of the request, so that becomes a simple trigger for dropping the
content-length and forcing chunked encoding.

If no Trailer header field is present, the trailer SHOULD NOT include any 
header
fields is a very explicit statement :)

This could be constructed from r-trailers_out, however users need to understand
that after the beginning of the response, r-trailers out cannot be extended, 
only
modified.

 Then you have to tweak modules/http/chunk_filter.c to allow others to insert 
 a trailer, like adding a ap_hook_http_trailer or a optional function for 
 inserting it.  I don't know if multiple modules should be allowed to add a 
 trailer, if you do how to you join them since a trailer is nothing but a 
 string ending with ASCII_CRLF (just strcat?).  Should we just grab 
 r-notes['http_trailer'] and let modules just add/set/append values?
 
 I think there is a bigger design discussion that should happen, but I might 
 have a patch down the road as a starter if all goes well at work.

These pieces seem more like implementation details.


Re: svn commit: r937378 - in /httpd/mod_fcgid/trunk: CHANGES-FCGID docs/manual/mod/mod_fcgid.xml modules/fcgid/mod_fcgid.c

2010-04-23 Thread Jeff Trawick
On Fri, Apr 23, 2010 at 1:04 PM,  traw...@apache.org wrote:
 Author: trawick
 Date: Fri Apr 23 17:04:40 2010
 New Revision: 937378

 URL: http://svn.apache.org/viewvc?rev=937378view=rev
 Log:
 FcgidPassHeader now maps header names to environment variable names
 in the usual manner: The header name is converted to upper case and
 is prefixed with HTTP_.  An additional environment variable is
 created with the legacy name.

 Modified: httpd/mod_fcgid/trunk/modules/fcgid/mod_fcgid.c
 URL: 
 http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/modules/fcgid/mod_fcgid.c?rev=937378r1=937377r2=937378view=diff
 ==
 --- httpd/mod_fcgid/trunk/modules/fcgid/mod_fcgid.c (original)
 +++ httpd/mod_fcgid/trunk/modules/fcgid/mod_fcgid.c Fri Apr 23 17:04:40 2010
 @@ -19,6 +19,7 @@
  #include http_request.h
  #include http_protocol.h
  #include ap_mmn.h
 +#include apr_lib.h
  #include apr_buckets.h
  #include apr_strings.h
  #include apr_thread_proc.h
 @@ -105,6 +106,32 @@ default_build_command(const char **cmd,
     return APR_SUCCESS;
  }

 +/* http2env stolen from util_script.c */
 +static char *http2env(apr_pool_t *a, const char *w)

a few modules out there have duplicated this function, which is bad;
but as-is it hardly seems like a good API; I guess a function to take
a header name and return the corresponding envvar name would be more
appropriate; it would contain the special logic for
CONTENT_TYPE/CONTENT_LENGTH

mod_fcgid and mod_fastcgi would theoretically have to work around the
CONTENT_TYPE/CONTENT_LENGTH situation to preserve the legacy behavior,
or just slap any script writer that looked at HTTP_CONTENT_TYPE
instead of CONTENT_TYPE

perhaps the whole FcgidPassHeader issue would have been avoided had
there been a config option to pass through [Proxy-]Authorization to
CGIs

(no hurry here to worry about the duplicated code given the other concerns)


Re: mod_fcgid: process PID graceful kill fail, sending SIGKILL

2010-04-23 Thread Jeff Trawick
On Tue, Apr 20, 2010 at 1:36 AM, Weedy weedy2...@gmail.com wrote:
 For the life of me I can't seem to find a way to make mod_fcgid wait
 longer. I don't mean FcgidMaxRequestsPerProcess or
 FcgidProcessLifeTime. I mean what controls the time between the signal
 -2/-11/-15/whatever and the -9.
 Any help would be appreciated.

During steady state:

FcgidErrorScanInterval controls normal termination of idle/extra
processes.  The directive controls the time between scans of the error
list, and during one scan it can send SIGTERM and during the next
scan, if it hasn't exited yet, it can send SIGKILL.

Keeping zombies cleaned up requires a small scan interval, but that
can keep some scripts from having adequate time to terminate before
getting KILL-ed.

At shutdown:

1 second hard-coded sleep between graceful kill and SIGKILL

--/--

Does this match what you are seeing?


Re: mod_fcgid: process PID graceful kill fail, sending SIGKILL

2010-04-23 Thread Jeff Trawick
On Fri, Apr 23, 2010 at 3:33 PM, Jeff Trawick traw...@gmail.com wrote:

 Keeping zombies cleaned up requires a small scan interval, but that
 can keep some scripts from having adequate time to terminate before
 getting KILL-ed.

whoops, ignore that; I'm getting scans confused :)
(FcgidZombieScanInterval controls zombie cleanup)


Re: After-request hooks or asychronous modules

2010-04-23 Thread Libo Song
Hi Samuel,

I am very curious about your solution. Have you satisfied with what
you are doing.  I am also facing a problem to asynchronous do some
job related to the served page, but the served page do not rely
on what I am doing.

Would you please share your experience?

Thanks,
Libo

On Sat, Feb 27, 2010 at 7:50 PM, Samuel ROZE samuel.r...@gmail.com wrote:
 Hello,

 I'm writing an Apache2 module which takes some time to be executed
 (500ms avg) because it is communicating with another server for each
 request. What is it doing haven't any consequence on the served page
 or file, so it can be run after that the connection with the client
 was closed.

 Now, it is working as a basic module, with libcurl and each request
 take 500ms because it is executed after sending the result page, even
 if it's not needed... Is it possible to execute a module after that
 the request was done? Or is it possible to create a function which
 will be called at this time using a hook?

 Thanks in advance.
 Regards,
 Samuel.