On Sat, 2006-08-12 at 16:46 -0400, Michael Peters wrote: > Now, in my handler sub I want to return the corresponding constant for > whatever > status() is set to. Under mod_perl 1.x this worked by just returning the > status() since OK == 200, SERVER_ERROR == 500, etc. But this isn't true under > mod_perl 2 (as far as I can tell). My module needs to work under both, so I > need > a better way.
The HTTP constants all have names like HTTP_OK rather than OK. They are not guaranteed to match the handler return codes, although many of them do. > I'd rather not have to check every possible status() value in a huge if/else > tree to return the right constant You could make a hash that maps handler response codes to HTTP codes. Most people don't need to do that because they only use one or two codes. - Perrin