mod_perl logo perl icon
previous page: Apache - Perl interface to the Apache server APIpage up: mod_perl 1.0 APInext page: Apache::Options - OPT_* defines from httpd_core.h

Apache::Constants - Constants defined in apache header files






mod_perl2 User's Guide

mod_perl2 User's Guide

By Stas Bekman, Jim Brandt
Practical mod_perl

Practical mod_perl

By Stas Bekman, Eric Cholet
The mod_perl Developer's Cookbook

The mod_perl Developer's Cookbook

By Geoffrey Young, Paul Lindner, Randy Kobes
mod_perl Pocket Reference

mod_perl Pocket Reference

By Andrew Ford
Writing Apache Modules with Perl and C

Writing Apache Modules with Perl and C

By Lincoln Stein, Doug MacEachern
Embedding Perl in HTML with Mason

Embedding Perl in HTML with Mason

By Dave Rolsky, Ken Williams


Table of Contents

Synopsis

    use Apache::Constants;
    use Apache::Constants ':common';
    use Apache::Constants ':response';


TOP

Description

Server constants used by apache modules are defined in httpd.h and other header files, this module gives Perl access to those constants.



TOP

Export Tags



TOP

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 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'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 OK != HTTP_OK.



TOP

Maintainers

Maintainer is the person(s) you should contact with updates, corrections and patches.



TOP

Authors

Only the major authors are listed above. For contributors see the Changes file.






TOP
previous page: Apache - Perl interface to the Apache server APIpage up: mod_perl 1.0 APInext page: Apache::Options - OPT_* defines from httpd_core.h