Apache::Constants3pm
Constants defined in apache header files
Usage
use Apache::Constants;use Apache::Constants ':common';use Apache::Constants ':response';
Overview
Server constants used by apache modules are defined in httpd.h and other header files, this module gives Perl access to those constants.
Export tags
- common
-
This tag imports the most commonly used constants.
OKDECLINEDDONENOT_FOUNDFORBIDDENAUTH_REQUIREDSERVER_ERROR
- response
-
This tag imports the
commonresponse codes, plus these response codes:DOCUMENT_FOLLOWSMOVEDREDIRECTUSE_LOCAL_COPYBAD_REQUESTBAD_GATEWAYRESPONSE_CODESNOT_IMPLEMENTEDCONTINUENOT_AUTHORITATIVECONTINUE and
NOT_AUTHORITATIVEare aliases for DECLINED.
- methods
-
This are the method numbers, commonly used with the Apache
method_numbermethod.METHODSM_CONNECTM_DELETEM_GETM_INVALIDM_OPTIONSM_POSTM_PUTM_TRACEM_PATCHM_PROPFINDM_PROPPATCHM_MKCOLM_COPYM_MOVEM_LOCKM_UNLOCK
- options
-
These constants are most commonly used with the Apache
allow_optionsmethod:OPT_NONEOPT_INDEXESOPT_INCLUDESOPT_SYM_LINKSOPT_EXECCGIOPT_UNSETOPT_INCNOEXECOPT_SYM_OWNEROPT_MULTIOPT_ALL
- satisfy
-
These constants are most commonly used with the Apache
satisfiesmethod:SATISFY_ALLSATISFY_ANYSATISFY_NOSPEC
- remotehost
-
These constants are most commonly used with the Apache
get_remote_hostmethod:REMOTE_HOSTREMOTE_NAMEREMOTE_NOLOOKUPREMOTE_DOUBLE_REV
- http
-
This is the full set of HTTP response codes: (NOTE: not all implemented here)
HTTP_OKHTTP_MOVED_TEMPORARILYHTTP_MOVED_PERMANENTLYHTTP_METHOD_NOT_ALLOWEDHTTP_NOT_MODIFIEDHTTP_UNAUTHORIZEDHTTP_FORBIDDENHTTP_NOT_FOUNDHTTP_BAD_REQUESTHTTP_INTERNAL_SERVER_ERRORHTTP_NOT_ACCEPTABLEHTTP_NO_CONTENTHTTP_PRECONDITION_FAILEDHTTP_SERVICE_UNAVAILABLEHTTP_VARIANT_ALSO_VARIES
- server
-
These are constants related to server version:
MODULE_MAGIC_NUMBERSERVER_VERSIONSERVER_BUILT
- config
-
These are constants related to configuration directives:
DECLINE_CMD
- types
-
These are constants related to internal request types:
DIR_MAGIC_TYPE
- override
-
These constants are used to control and test the context of configuration directives.
OR_NONEOR_LIMITOR_OPTIONSOR_FILEINFOOR_AUTHCFGOR_INDEXESOR_UNSETOR_ALLACCESS_CONFRSRC_CONF
- args_how
-
RAW_ARGSTAKE1TAKE2TAKE12TAKE3TAKE23TAKE123ITERATEITERATE2FLAGNO_ARGS
Misuses
You should be aware of the issues relating to using constant subroutines in Perl. For example this:
$r->custom_response(FORBIDDEN => "File size exceeds quota.");
will not set a custom response for "FORBIDDEN", but for the string "FORBIDDEN", which clearly isn't what is expected. You'll get an error like this:
[Tue Apr 23 19:46:14 2002] null: Argument "FORBIDDEN" isn'tnumeric in subroutine entry at ...
Therefore, the best solution is not to use the hash notation for things that don't require it:
$r->custom_response(FORBIDDEN, "File size exceeds quota.");
Another important note is that instead of using HTTP codes, you should use designed for that purpose constants. Therefore, this is wrong:
sub handler { return 200; }
The correct use is:
use Apache::Constants qw(OK);sub handler { return OK; }
Also remember that "OK != HTTP_OK".
Releases
5 releases since Debian 2.1 (Slink); the text changed 4 times.