httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Kew <>
Subject Re: [users@httpd] how to suppress hard-coded response body in 302 redirect
Date Tue, 30 Aug 2011 00:14:34 GMT
On 29 Aug 2011, at 23:21, Peter Glasten wrote:

> Hello!
> In my Apache module

Since this is a development question, it would be more on-topic
for the modules-dev list than here.

> (module AP_MODULE_DECLARE_DATA ... etc etc - low-level Apache module written in C) I
need to return a 302 redirect status with no body, Content-Length set to zero, and no content-type
(this is a third-party requirement that I cannot change). Apache by default adds hard-coded
HTML body and text/html content type.

That depends on how/where your module triggers the 302 response.
If it does so by returning 302 from a pre-handler hook (like, for example,
mod_alias and mod_rewrite do) then you get what you describe.
If it works as a handler like CGI or PHP, then you (can easily)
get what you want and expect.  Take a look at mod_asis for a
startingpoint to do it that way.

Alternatively (and unless your module is doing something v.strange)
you should be able to delegate the 302 response to the server admin.
Your module just sets a Location and returns 302, but you can use the
ErrorDocument directive to customise your response.  With a .asis
ErrorDocument you have full control over the headers.

Note that Content-Length: 0 is redundant, in the absence of anything
that would lead a client to expect contents.

See also the book:

Nick Kew
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message