You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Eric Covener <co...@gmail.com> on 2013/06/30 21:47:10 UTC
stop copying r->content_type to r->handler?
All releases still have what I guess is an old pre-SetHandler
mechanism to allow content type -> handler mappings. If no r->handler
has been set, but a content-type has, the content-type is copied to
r->handler.
Is there a use case for this? It makes it hard for handlers to check
if someone else has laid claim to a request w/ their own r->handler
string.
Maybe something to consider zapping from just trunk?
--
Eric Covener
covener@gmail.com
Re: stop copying r->content_type to r->handler?
Posted by Jim Jagielski <ji...@jaguNET.com>.
On Jun 30, 2013, at 3:47 PM, Eric Covener <co...@gmail.com> wrote:
>
> Maybe something to consider zapping from just trunk?
>
++1.
Re: stop copying r->content_type to r->handler?
Posted by Christian Seiler <ch...@gmx.net>.
Hi there,
>> As an httpd user who's reading this proposal: Currently, I like to
>> configure PHP in combination with Apache in such a way that I set the
>> content type and then have Action application/x-httpd-php ... I don't
>> want to use AddHandler, since then Apache also processes files ending
>> in .php.txt with PHP, so the usage of the content type as handler has
>> been very useful to me. (Btw. this is PHP as CGI/FastCGI, hence the
>> Action statement.)
>
> Thanks for the feedback, can you show an example stanza? Curious how
> you set the type in contrast of AddHandler
extract from my httpd configuration (still 2.2, I should probably
upgrade soon...):
-----------------------------------------------------------------
# FastCGI configuration (abbreviated)
LoadModule fcgid_module modules/mod_fcgid.so
<Location /fcgi-bin/>
SetHandler fcgid-script
Options +ExecCGI
Order allow,deny
Allow from all
</Location>
Alias /fcgi-bin/ /srv/www/fcgi-bin/
# /srv/www/fcgi-bin/php-fcgi-wrapper:
# (shell script because of suexec; immutable fs attribute set)
#!/bin/sh
exec /usr/bin/php-cgi "$@"
# PHP configuration
AddType application/x-httpd-php .php
Action application/x-httpd-php /fcgi-bin/php-fcgi-wrapper
-----------------------------------------------------------------
That has worked for me since at least some later version of Apache 2.0.
Has the advantage of having the same semantics as mod_php when it comes
to resolving whether a PHP file should be called or not.
-- Christian
Re: stop copying r->content_type to r->handler?
Posted by Christian Seiler <ch...@gmx.net>.
Hi,
> It looks like mod_actions does not recognize r->handler set to "" --
> when r->handler is NULL, he will look directly to r->content_type, so
> that may be a potential way to still handle content-type based
> "dispatch" without having the content-type sit in r->handler.
What you suggest would, as far as I can see, make my configuration still
work as expected but allow you to remove the copy of r->content_type, so
I don't have any objections to that. From a coding perspective, this
seems cleaner to me.
By the way, I just cross-checked against the current mod_php [1], and
they check against r->handler, so your change would probably break
current mod_php regardless of mod_actions. On the other hand, a) my
guess is that this change will not make it into 2.4 or lower anyway, so
there should be plenty of time to write a release note about that and b)
as far as I understand it (I may be wrong about this) mod_php is
discouraged in favor of FastCGI anyway nowadays.
The interesting thing would be to see how many other modules also check
r->handler for content_type.
-- Christian
[1]
http://git.php.net/?p=php-src.git;a=blob;f=sapi/apache2handler/sapi_apache2.c;h=b7f95e0c1272996b48cee904d9fe98c062c6c413;hb=refs/heads/master
Re: stop copying r->content_type to r->handler?
Posted by Eric Covener <co...@gmail.com>.
On Mon, Jul 1, 2013 at 12:29 PM, Eric Covener <co...@gmail.com> wrote:
> On Mon, Jul 1, 2013 at 12:16 PM, Christian Seiler <ch...@gmx.net> wrote:
>> Hi there,
>>
>>
>>> All releases still have what I guess is an old pre-SetHandler
>>> mechanism to allow content type -> handler mappings. If no r->handler
>>> has been set, but a content-type has, the content-type is copied to
>>> r->handler.
>>
>>
>> As an httpd user who's reading this proposal: Currently, I like to
>> configure PHP in combination with Apache in such a way that I set the
>> content type and then have Action application/x-httpd-php ... I don't
>> want to use AddHandler, since then Apache also processes files ending
>> in .php.txt with PHP, so the usage of the content type as handler has
>> been very useful to me. (Btw. this is PHP as CGI/FastCGI, hence the
>> Action statement.)
>
> Thanks for the feedback, can you show an example stanza? Curious how
> you set the type in contrast of AddHandler
It looks like mod_actions does not recognize r->handler set to "" --
when r->handler is NULL, he will look directly to r->content_type, so
that may be a potential way to still handle content-type based
"dispatch" without having the content-type sit in r->handler.
--
Eric Covener
covener@gmail.com
Re: stop copying r->content_type to r->handler?
Posted by Eric Covener <co...@gmail.com>.
On Mon, Jul 1, 2013 at 12:16 PM, Christian Seiler <ch...@gmx.net> wrote:
> Hi there,
>
>
>> All releases still have what I guess is an old pre-SetHandler
>> mechanism to allow content type -> handler mappings. If no r->handler
>> has been set, but a content-type has, the content-type is copied to
>> r->handler.
>
>
> As an httpd user who's reading this proposal: Currently, I like to
> configure PHP in combination with Apache in such a way that I set the
> content type and then have Action application/x-httpd-php ... I don't
> want to use AddHandler, since then Apache also processes files ending
> in .php.txt with PHP, so the usage of the content type as handler has
> been very useful to me. (Btw. this is PHP as CGI/FastCGI, hence the
> Action statement.)
Thanks for the feedback, can you show an example stanza? Curious how
you set the type in contrast of AddHandler
Re: stop copying r->content_type to r->handler?
Posted by Christian Seiler <ch...@gmx.net>.
Hi there,
> All releases still have what I guess is an old pre-SetHandler
> mechanism to allow content type -> handler mappings. If no r->handler
> has been set, but a content-type has, the content-type is copied to
> r->handler.
As an httpd user who's reading this proposal: Currently, I like to
configure PHP in combination with Apache in such a way that I set the
content type and then have Action application/x-httpd-php ... I don't
want to use AddHandler, since then Apache also processes files ending
in .php.txt with PHP, so the usage of the content type as handler has
been very useful to me. (Btw. this is PHP as CGI/FastCGI, hence the
Action statement.)
I've just skimmed the current httpd documentation for SetHandler and
there's the example of
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Obviously, this should also work for the standard case of a file just
ending in .php, but if you want to then combine the whole thing with
for example MultiViews, then the FilesMatch rule has to become more
compilicated. And since a .txt suffix shouldn't cause PHP to process
them, I'd have to provide and update a whitelist of languages
instead of just relying on the fact that MultiViews "just works". I
believe this makes these kinds of configurations unnecessarily
harder. Unless I overlooked something.
Just my 2c as a user.
-- Christian
Re: stop copying r->content_type to r->handler?
Posted by Eric Covener <co...@gmail.com>.
On Sun, Jun 30, 2013 at 3:48 PM, Joseph Schaefer <jo...@yahoo.com> wrote:
> The directory handling still relies on this.
Other *_MAGIC_TYPES do too, but I'm guessing they could be boiled down
to just r->handler.
Re: stop copying r->content_type to r->handler?
Posted by Joseph Schaefer <jo...@yahoo.com>.
The directory handling still relies on this.
Sent from my iPhone
On Jun 30, 2013, at 3:47 PM, Eric Covener <co...@gmail.com> wrote:
> All releases still have what I guess is an old pre-SetHandler
> mechanism to allow content type -> handler mappings. If no r->handler
> has been set, but a content-type has, the content-type is copied to
> r->handler.
>
> Is there a use case for this? It makes it hard for handlers to check
> if someone else has laid claim to a request w/ their own r->handler
> string.
>
> Maybe something to consider zapping from just trunk?
>
> --
> Eric Covener
> covener@gmail.com