You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by John Zhang <jo...@yahoo.com> on 2007/12/08 01:41:23 UTC
How does set status code in filter work
In an output filter. If something is wrong, and I set
the request object's status to an error code, then am
I responsible for providing the proper error page
content? What is the correct way to handle errors in
an output filter?
Thanks,
John
Re: How does set status code in filter work
Posted by John Zhang <jo...@yahoo.com>.
Thanks a lot, Joe!
--- Joe Lewis <jo...@joe-lewis.com> wrote:
> John Zhang wrote:
> > Joe,
> > Thanks for you rreply, but I do not quite
> > understand "Your filter should run before the
> content
> > type is set". Could you elaberated on that? My
> filter
> > is an output filter.
> >
>
> The filter types are AP_FTYPE_ (followed by one of
> the following )
> RESOURCE, CONTENT_SET, PROTOCOL, TRANSCODE,
> CONNECTION or NETWORK. The
> two most common ones are AP_FTYPE_RESOURCE, and
> AP_FTYPE_CONTENT_SET.
> The difference between the two is one (RESOURCE)
> runs prior to the
> Content-Type header being set. (Meaning they can
> change any of those
> headers). The other (CONTENT_SET) runs after that
> header is set, and
> are not supposed to change that header (I expect
> there are other
> headers, such as the status, that may also be
> effected here, but I do
> not know for sure). It is in your register_hook
> function that you
> declare when you want your filter to be run that
> those are specified.
>
>
> > Also, if I issue a redirect in my (output)
> filter
> > to (say /errors/HTTP_FORBIDDEN.html) and I am a
> filter
> > for .html, will I be called in loading the error
> page?
> >
>
> Error pages do not run in the standard filter chain
> by default. If you
> want your filter running on the error HTML files in
> addition to others,
> you would have to use an error_filter hook as well.
>
> Joe
> --
> Joseph Lewis <http://sharktooth.org/>
> "Divide the fire, and you will sooner put it out." -
> Publius Syrus
>
Re: How does set status code in filter work
Posted by Joe Lewis <jo...@joe-lewis.com>.
John Zhang wrote:
> Joe,
> Thanks for you rreply, but I do not quite
> understand "Your filter should run before the content
> type is set". Could you elaberated on that? My filter
> is an output filter.
>
The filter types are AP_FTYPE_ (followed by one of the following )
RESOURCE, CONTENT_SET, PROTOCOL, TRANSCODE, CONNECTION or NETWORK. The
two most common ones are AP_FTYPE_RESOURCE, and AP_FTYPE_CONTENT_SET.
The difference between the two is one (RESOURCE) runs prior to the
Content-Type header being set. (Meaning they can change any of those
headers). The other (CONTENT_SET) runs after that header is set, and
are not supposed to change that header (I expect there are other
headers, such as the status, that may also be effected here, but I do
not know for sure). It is in your register_hook function that you
declare when you want your filter to be run that those are specified.
> Also, if I issue a redirect in my (output) filter
> to (say /errors/HTTP_FORBIDDEN.html) and I am a filter
> for .html, will I be called in loading the error page?
>
Error pages do not run in the standard filter chain by default. If you
want your filter running on the error HTML files in addition to others,
you would have to use an error_filter hook as well.
Joe
--
Joseph Lewis <http://sharktooth.org/>
"Divide the fire, and you will sooner put it out." - Publius Syrus
Re: How does set status code in filter work
Posted by John Zhang <jo...@yahoo.com>.
Joe,
Thanks for you rreply, but I do not quite
understand "Your filter should run before the content
type is set". Could you elaberated on that? My filter
is an output filter.
Also, if I issue a redirect in my (output) filter
to (say /errors/HTTP_FORBIDDEN.html) and I am a filter
for .html, will I be called in loading the error page?
Thanks,
John
--- Joe Lewis <jo...@joe-lewis.com> wrote:
> Your filter should run before the content type is
> set. Then, you can do
> the usual redirect to /errors/HTTP_FORBIDDEN.html or
> whatever document
> you should be returning. Yes, a filter should only
> be working on the
> through-put, so you should be handling that.
> Perhaps someone knows
> about the pre-content-set filter types - I'm
> definitely not the expert.
>
> Joe
>
> John Zhang wrote:
> > In an output filter. If something is wrong, and I
> set
> > the request object's status to an error code, then
> am
> > I responsible for providing the proper error page
> > content? What is the correct way to handle errors
> in
> > an output filter?
> >
> > Thanks,
> > John
> >
>
>
Re: How does set status code in filter work
Posted by Joe Lewis <jo...@joe-lewis.com>.
Your filter should run before the content type is set. Then, you can do
the usual redirect to /errors/HTTP_FORBIDDEN.html or whatever document
you should be returning. Yes, a filter should only be working on the
through-put, so you should be handling that. Perhaps someone knows
about the pre-content-set filter types - I'm definitely not the expert.
Joe
John Zhang wrote:
> In an output filter. If something is wrong, and I set
> the request object's status to an error code, then am
> I responsible for providing the proper error page
> content? What is the correct way to handle errors in
> an output filter?
>
> Thanks,
> John
>