[mod_python] Sending back headers with 4xx responses

Nic James Ferrier nferrier at tapsellferrier.co.uk
Wed May 31 13:59:06 EDT 2006


"Deron Meranda" <deron.meranda at gmail.com> writes:

>> You have to raise these.
>>
>> For example:
>>
>>     if status >= 200 and status < 300:
>>         return apache.OK
>>     else:
>>         raise apache.SERVER_RETURN, status
>
> No, that's not it.  Either way the response code is sent back,
> but not the headers.  It definitely appears to be a problem only
> for 1xx, 4xx and 5xx codes.  For any 2xx or 3xx codes,
> headers go through as expected.
>
> At least for the 4/5xx codes, perhaps the problem is the way
> Apache really does an internal redirect to the appropriate
> error page?  Is there any way to pass information or headers
> on to those?
>
> Whatever the reason, I seem unable to send back a Content-Range
> header for a 416 as recommended by the RFC.

Sorry - I ommitted to mention that the headers have to go into:

   http_request_object.err_headers_out

So, something like:

  http_request_object.err_headers_out["Content-Range"] = 10
  raise apache.SERVER_RETURN, 416

should work.

-- 
Nic Ferrier
http://www.tapsellferrier.co.uk   for all your tapsell ferrier needs


More information about the Mod_python mailing list