Here is the patch again, to make Doug's life easier.
Index: Constants/Constants.pm
===================================================================
RCS file: /home/cvspublic/modperl/Constants/Constants.pm,v
retrieving revision 1.22
diff -u -r1.22 Constants.pm
--- Constants/Constants.pm 24 Mar 2002 02:07:58 -0000 1.22
+++ Constants/Constants.pm 27 Apr 2002 09:43:01 -0000
@@ -66,19 +66,20 @@
Apache::Constants - Constants defined in apache header files
-=head1 SYNOPSIS
+=head1 Synopsis
use Apache::Constants;
use Apache::Constants ':common';
use Apache::Constants ':response';
-=head1 DESCRIPTION
+=head1 Description
Server constants used by apache modules are defined in
B<httpd.h> and other header files, this module gives Perl access
-to those constants.
+to those constants.
-=head1 EXPORT TAGS
+
+=head1 Export Tags
=over 4
@@ -92,12 +93,12 @@
NOT_FOUND
FORBIDDEN
AUTH_REQUIRED
- SERVER_ERROR
+ SERVER_ERROR
=item response
This tag imports the B<common> response codes, plus these
-response codes:
+response codes:
DOCUMENT_FOLLOWS
MOVED
@@ -125,7 +126,7 @@
M_OPTIONS
M_POST
M_PUT
- M_TRACE
+ M_TRACE
M_PATCH
M_PROPFIND
M_PROPPATCH
@@ -137,12 +138,12 @@
=item options
-These constants are most commonly used with
+These constants are most commonly used with
the Apache B<allow_options> method:
OPT_NONE
OPT_INDEXES
- OPT_INCLUDES
+ OPT_INCLUDES
OPT_SYM_LINKS
OPT_EXECCGI
OPT_UNSET
@@ -153,7 +154,7 @@
=item satisfy
-These constants are most commonly used with
+These constants are most commonly used with
the Apache B<satisfies> method:
SATISFY_ALL
@@ -162,7 +163,7 @@
=item remotehost
-These constants are most commonly used with
+These constants are most commonly used with
the Apache B<get_remote_host> method:
REMOTE_HOST
@@ -178,14 +179,14 @@
HTTP_OK
HTTP_MOVED_TEMPORARILY
HTTP_MOVED_PERMANENTLY
- HTTP_METHOD_NOT_ALLOWED
+ HTTP_METHOD_NOT_ALLOWED
HTTP_NOT_MODIFIED
HTTP_UNAUTHORIZED
HTTP_FORBIDDEN
HTTP_NOT_FOUND
HTTP_BAD_REQUEST
HTTP_INTERNAL_SERVER_ERROR
- HTTP_NOT_ACCEPTABLE
+ HTTP_NOT_ACCEPTABLE
HTTP_NO_CONTENT
HTTP_PRECONDITION_FAILED
HTTP_SERVICE_UNAVAILABLE
@@ -243,6 +244,55 @@
=back
-=head1 AUTHORS
+=head1 Warnings
+
+You should be aware of the issues relating to using constant
+subroutines in Perl. For example, look at this example:
+
+ $r->custom_response(FORBIDDEN => "File size exceeds quota.");
+
+This will not set a custom response for C<FORBIDDEN>, but for the
+string C<"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't numeric in
subroutine entry at ...
+
+Therefore, you can avoid this by not using the hash notation for
+things that don't require it.
+
+ $r->custom_response(FORBIDDEN, "File size exceeds quota.");
+
+Another important note is that you should be using the correct
+constants defined here, and not direct HTTP codes. For example:
+
+ sub handler {
+ return 200;
+ }
+
+Is not correct. The correct use is:
+
+ use Apache::Constants qw(OK);
+
+ sub handler {
+ return OK;
+ }
+
+Also remember that C<OK != HTTP_OK>.
+
+
+=head1 Authors
+
+=over
+
+=item * Doug MacEachern
+
+=item * Gisle Aas
+
+=item * h2xs
+
+=back
+
+Only the major authors are listed above. For contributors see the
+Changes file.
-Doug MacEachern, Gisle Aas and h2xs
+=cut
At 14:55 24.04.2002, Geoffrey Young wrote:
>>>personally, I think that FORBIDDEN() is just as bad as $FORBIDDEN - it's
>>>removing the constant idea behind constant subroutines (though sometimes
>>>you just have to do things that way to get past the compiler or
>>>whatnot). it's a matter of personal choice, I suppose...
>>
>>Yes, I agree. I just seem to remember that that was what is suggested in
>>the perl docs. Anyway, there is no reason to use hash notation here.
>>However, there might be for some other functions (don't ask me which).
>
>
>I think that the hash notation is a carryover from other functions like
>notes() and the other Apache::Table based functions where the shortcut
>makes sense.
>
>
>>
>>>oh, and C<OK == 1> is wrong - OK is 0 (which is another reason to just
>>>use constants and forget about their values ;)
>>
>>Thanks for spotting that one :) I still think that warning is important
>>though, as I've seen that a couple of times on the list.
>
>
>yes :)
>
>--Geoff
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
--
Per Einar Ellefsen
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]