Google
 

include/http_core.h

Go to the documentation of this file.
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more
00002  * contributor license agreements.  See the NOTICE file distributed with
00003  * this work for additional information regarding copyright ownership.
00004  * The ASF licenses this file to You under the Apache License, Version 2.0
00005  * (the "License"); you may not use this file except in compliance with
00006  * the License.  You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00026 #ifndef APACHE_HTTP_CORE_H
00027 #define APACHE_HTTP_CORE_H
00028 
00029 #include "apr.h"
00030 #include "apr_hash.h"
00031 #include "apr_optional.h"
00032 #include "util_filter.h"
00033 
00034 #if APR_HAVE_STRUCT_RLIMIT
00035 #include <sys/time.h>
00036 #include <sys/resource.h>
00037 #endif
00038 
00039 
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043 
00044 /* ****************************************************************
00045  *
00046  * The most basic server code is encapsulated in a single module
00047  * known as the core, which is just *barely* functional enough to
00048  * serve documents, though not terribly well.
00049  *
00050  * Largely for NCSA back-compatibility reasons, the core needs to
00051  * make pieces of its config structures available to other modules.
00052  * The accessors are declared here, along with the interpretation
00053  * of one of them (allow_options).
00054  */
00055 
00065 #define OPT_NONE 0
00066 
00067 #define OPT_INDEXES 1
00068 
00069 #define OPT_INCLUDES 2
00070 
00071 #define OPT_SYM_LINKS 4
00072 
00073 #define OPT_EXECCGI 8
00074 
00075 #define OPT_UNSET 16
00076 
00077 #define OPT_INCNOEXEC 32
00078 
00079 #define OPT_SYM_OWNER 64
00080 
00081 #define OPT_MULTI 128
00082 
00083 #define OPT_ALL (OPT_INDEXES|OPT_INCLUDES|OPT_SYM_LINKS|OPT_EXECCGI)
00084 
00095 #define REMOTE_HOST (0)
00096 
00101 #define REMOTE_NAME (1)
00102 
00106 #define REMOTE_NOLOOKUP (2)
00107 
00113 #define REMOTE_DOUBLE_REV (3)
00114 
00118 #define SATISFY_ALL 0
00119 
00120 #define SATISFY_ANY 1
00121 
00122 #define SATISFY_NOSPEC 2
00123 
00126 #define AP_MIN_BYTES_TO_WRITE  8000
00127 
00129 # define AP_DEFAULT_MAX_INTERNAL_REDIRECTS 10
00130 
00132 # define AP_DEFAULT_MAX_SUBREQ_DEPTH 10
00133 
00139 AP_DECLARE(int) ap_allow_options(request_rec *r);
00140 
00146 AP_DECLARE(int) ap_allow_overrides(request_rec *r);
00147 
00153 AP_DECLARE(const char *) ap_default_type(request_rec *r);     
00154 
00162 AP_DECLARE(const char *) ap_document_root(request_rec *r);
00163 
00188 AP_DECLARE(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config, int type, int *str_is_ip);
00189 
00196 AP_DECLARE(const char *) ap_get_remote_logname(request_rec *r);
00197 
00198 /* Used for constructing self-referencing URLs, and things like SERVER_PORT,
00199  * and SERVER_NAME.
00200  */
00208 AP_DECLARE(char *) ap_construct_url(apr_pool_t *p, const char *uri, request_rec *r);
00209 
00215 AP_DECLARE(const char *) ap_get_server_name(request_rec *r);
00216 
00222 AP_DECLARE(apr_port_t) ap_get_server_port(const request_rec *r);
00223 
00229 AP_DECLARE(apr_off_t) ap_get_limit_req_body(const request_rec *r);
00230 
00236 AP_DECLARE(size_t) ap_get_limit_xml_body(const request_rec *r);
00237 
00245 AP_DECLARE(void) ap_custom_response(request_rec *r, int status, const char *string);
00246 
00252 AP_DECLARE(int) ap_is_recursion_limit_exceeded(const request_rec *r);
00253 
00259 AP_DECLARE(int) ap_exists_config_define(const char *name);
00260 /* FIXME! See STATUS about how */
00261 AP_DECLARE_NONSTD(int) ap_core_translate(request_rec *r);
00262 
00263 /* Authentication stuff.  This is one of the places where compatibility
00264  * with the old config files *really* hurts; they don't discriminate at
00265  * all between different authentication schemes, meaning that we need
00266  * to maintain common state for all of them in the core, and make it
00267  * available to the other modules through interfaces.
00268  */
00269 
00271 typedef struct require_line require_line;
00272 
00276 struct require_line {
00278     apr_int64_t method_mask;
00280     char *requirement;
00281 };
00282      
00288 AP_DECLARE(const char *) ap_auth_type(request_rec *r);
00289 
00295 AP_DECLARE(const char *) ap_auth_name(request_rec *r);     
00296 
00307 AP_DECLARE(int) ap_satisfies(request_rec *r);
00308 
00309 #ifdef CORE_PRIVATE
00310 
00316 AP_DECLARE_DATA extern module core_module;
00317 
00321 typedef struct {
00324     struct apr_bucket_brigade *bb;
00325 
00331     void **notes;
00332 
00341     int deliver_script;
00342 
00346     char **response_code_strings; /* from ap_custom_response(), not from
00347                                    * ErrorDocument
00348                                    */
00351     int suppress_charset;
00352 } core_request_config;
00353 
00354 /* Standard entries that are guaranteed to be accessible via
00355  * ap_get_request_note() for each request (additional entries
00356  * can be added with ap_register_request_note())
00357  */
00358 #define AP_NOTE_DIRECTORY_WALK 0
00359 #define AP_NOTE_LOCATION_WALK  1
00360 #define AP_NOTE_FILE_WALK      2
00361 #define AP_NUM_STD_NOTES       3
00362 
00370 AP_DECLARE(apr_size_t) ap_register_request_note(void);
00371 
00386 AP_DECLARE(void **) ap_get_request_note(request_rec *r, apr_size_t note_num);
00387 
00388 
00389 typedef unsigned char allow_options_t;
00390 typedef unsigned char overrides_t;
00391 
00392 /*
00393  * Bits of info that go into making an ETag for a file
00394  * document.  Why a long?  Because char historically
00395  * proved too short for Options, and int can be different
00396  * sizes on different platforms.
00397  */
00398 typedef unsigned long etag_components_t;
00399 
00400 #define ETAG_UNSET 0
00401 #define ETAG_NONE  (1 << 0)
00402 #define ETAG_MTIME (1 << 1)
00403 #define ETAG_INODE (1 << 2)
00404 #define ETAG_SIZE  (1 << 3)
00405 #define ETAG_BACKWARD (ETAG_MTIME | ETAG_INODE | ETAG_SIZE)
00406 #define ETAG_ALL   (ETAG_MTIME | ETAG_INODE | ETAG_SIZE)
00407 
00411 typedef enum {
00412     srv_sig_unset,
00413     srv_sig_off,
00414     srv_sig_on,
00415     srv_sig_withmail
00416 } server_signature_e;
00417 
00421 typedef struct {
00423     char *d;
00425     unsigned d_components;
00426 
00434     allow_options_t opts;
00435     allow_options_t opts_add;
00436     allow_options_t opts_remove;
00437     overrides_t override;
00438     allow_options_t override_opts;
00439     
00440     /* MIME typing --- the core doesn't do anything at all with this,
00441      * but it does know what to slap on a request for a document which
00442      * goes untyped by other mechanisms before it slips out the door...
00443      */
00444     
00445     char *ap_default_type;
00446   
00447     /* Custom response config. These can contain text or a URL to redirect to.
00448      * if response_code_strings is NULL then there are none in the config,
00449      * if it's not null then it's allocated to sizeof(char*)*RESPONSE_CODES.
00450      * This lets us do quick merges in merge_core_dir_configs().
00451      */
00452   
00453     char **response_code_strings; /* from ErrorDocument, not from
00454                                    * ap_custom_response() */
00455 
00456     /* Hostname resolution etc */
00457 #define HOSTNAME_LOOKUP_OFF     0
00458 #define HOSTNAME_LOOKUP_ON      1
00459 #define HOSTNAME_LOOKUP_DOUBLE  2
00460 #define HOSTNAME_LOOKUP_UNSET   3
00461     unsigned int hostname_lookups : 4;
00462 
00463     signed int content_md5 : 2;  /* calculate Content-MD5? */
00464 
00465 #define USE_CANONICAL_NAME_OFF   (0)
00466 #define USE_CANONICAL_NAME_ON    (1)
00467 #define USE_CANONICAL_NAME_DNS   (2)
00468 #define USE_CANONICAL_NAME_UNSET (3)
00469     unsigned use_canonical_name : 2;
00470 
00471     /* since is_fnmatch(conf->d) was being called so frequently in
00472      * directory_walk() and its relatives, this field was created and
00473      * is set to the result of that call.
00474      */
00475     unsigned d_is_fnmatch : 1;
00476 
00477     /* should we force a charset on any outgoing parameterless content-type?
00478      * if so, which charset?
00479      */
00480 #define ADD_DEFAULT_CHARSET_OFF   (0)
00481 #define ADD_DEFAULT_CHARSET_ON    (1)
00482 #define ADD_DEFAULT_CHARSET_UNSET (2)
00483     unsigned add_default_charset : 2;
00484     const char *add_default_charset_name;
00485 
00486     /* System Resource Control */
00487 #ifdef RLIMIT_CPU
00488     struct rlimit *limit_cpu;
00489 #endif
00490 #if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS)
00491     struct rlimit *limit_mem;
00492 #endif
00493 #ifdef RLIMIT_NPROC
00494     struct rlimit *limit_nproc;
00495 #endif
00496     apr_off_t limit_req_body;      /* limit on bytes in request msg body */
00497     long limit_xml_body;           /* limit on bytes in XML request msg body */
00498 
00499     /* logging options */
00500 
00501     server_signature_e server_signature;
00502 
00503     int loglevel;
00504     
00505     /* Access control */
00506     apr_array_header_t *sec_file;
00507     ap_regex_t *r;
00508 
00509     const char *mime_type;       /* forced with ForceType  */
00510     const char *handler;         /* forced with SetHandler */
00511     const char *output_filters;  /* forced with SetOutputFilters */
00512     const char *input_filters;   /* forced with SetInputFilters */
00513     int accept_path_info;        /* forced with AcceptPathInfo */
00514 
00515     apr_hash_t *ct_output_filters; /* added with AddOutputFilterByType */
00516 
00517     /*
00518      * What attributes/data should be included in ETag generation?
00519      */
00520     etag_components_t etag_bits;
00521     etag_components_t etag_add;
00522     etag_components_t etag_remove;
00523 
00524     /*
00525      * Run-time performance tuning
00526      */
00527 #define ENABLE_MMAP_OFF    (0)
00528 #define ENABLE_MMAP_ON     (1)
00529 #define ENABLE_MMAP_UNSET  (2)
00530     unsigned int enable_mmap : 2;  /* whether files in this dir can be mmap'ed */
00531 
00532 #define ENABLE_SENDFILE_OFF    (0)
00533 #define ENABLE_SENDFILE_ON     (1)
00534 #define ENABLE_SENDFILE_UNSET  (2)
00535     unsigned int enable_sendfile : 2;  /* files in this dir can be mmap'ed */
00536     unsigned int allow_encoded_slashes : 1; /* URLs may contain %2f w/o being
00537                                              * pitched indiscriminately */
00538 
00539 #define USE_CANONICAL_PHYS_PORT_OFF   (0)
00540 #define USE_CANONICAL_PHYS_PORT_ON    (1)
00541 #define USE_CANONICAL_PHYS_PORT_UNSET (2)
00542     unsigned use_canonical_phys_port : 2;
00543 
00544 } core_dir_config;
00545 
00546 /* Per-server core configuration */
00547 
00548 typedef struct {
00549   
00550 #ifdef GPROF
00551     char *gprof_dir;
00552 #endif
00553 
00554     /* Name translations --- we want the core to be able to do *something*
00555      * so it's at least a minimally functional web server on its own (and
00556      * can be tested that way).  But let's keep it to the bare minimum:
00557      */
00558     const char *ap_document_root;
00559   
00560     /* Access control */
00561 
00562     char *access_name;
00563     apr_array_header_t *sec_dir;
00564     apr_array_header_t *sec_url;
00565 
00566     /* recursion backstopper */
00567     int redirect_limit; /* maximum number of internal redirects */
00568     int subreq_limit;   /* maximum nesting level of subrequests */
00569 
00570     const char *protocol;
00571     apr_table_t *accf_map;
00572 
00573     /* TRACE control */
00574 #define AP_TRACE_UNSET    -1
00575 #define AP_TRACE_DISABLE   0
00576 #define AP_TRACE_ENABLE    1
00577 #define AP_TRACE_EXTENDED  2
00578     int trace_enable;
00579 
00580 } core_server_config;
00581 
00582 /* for AddOutputFiltersByType in core.c */
00583 void ap_add_output_filters_by_type(request_rec *r);
00584 
00585 /* for http_config.c */
00586 void ap_core_reorder_directories(apr_pool_t *, server_rec *);
00587 
00588 /* for mod_perl */
00589 AP_CORE_DECLARE(void) ap_add_per_dir_conf(server_rec *s, void *dir_config);
00590 AP_CORE_DECLARE(void) ap_add_per_url_conf(server_rec *s, void *url_config);
00591 AP_CORE_DECLARE(void) ap_add_file_conf(core_dir_config *conf, void *url_config);
00592 AP_CORE_DECLARE_NONSTD(const char *) ap_limit_section(cmd_parms *cmd, void *dummy, const char *arg);
00593 
00594 /* Core filters; not exported. */
00595 int ap_core_input_filter(ap_filter_t *f, apr_bucket_brigade *b,
00596                          ap_input_mode_t mode, apr_read_type_e block,
00597                          apr_off_t readbytes);
00598 apr_status_t ap_core_output_filter(ap_filter_t *f, apr_bucket_brigade *b);
00599 
00600 #endif /* CORE_PRIVATE */
00601 
00602 AP_DECLARE(const char*) ap_get_server_protocol(server_rec* s);
00603 AP_DECLARE(void) ap_set_server_protocol(server_rec* s, const char* proto);
00604 
00605 /* ----------------------------------------------------------------------
00606  *
00607  * Runtime status/management
00608  */
00609 
00610 typedef enum {
00611     ap_mgmt_type_string,
00612     ap_mgmt_type_long,
00613     ap_mgmt_type_hash
00614 } ap_mgmt_type_e;
00615 
00616 typedef union {
00617     const char *s_value;
00618     long i_value;
00619     apr_hash_t *h_value;
00620 } ap_mgmt_value;
00621 
00622 typedef struct {
00623     const char *description;
00624     const char *name;
00625     ap_mgmt_type_e vtype;
00626     ap_mgmt_value v;
00627 } ap_mgmt_item_t;
00628 
00629 /* Handles for core filters */
00630 extern AP_DECLARE_DATA ap_filter_rec_t *ap_subreq_core_filter_handle;
00631 extern AP_DECLARE_DATA ap_filter_rec_t *ap_core_output_filter_handle;
00632 extern AP_DECLARE_DATA ap_filter_rec_t *ap_content_length_filter_handle;
00633 extern AP_DECLARE_DATA ap_filter_rec_t *ap_core_input_filter_handle;
00634 
00648 AP_DECLARE_HOOK(int, get_mgmt_items,
00649                 (apr_pool_t *p, const char * val, apr_hash_t *ht))
00650 
00651 /* ---------------------------------------------------------------------- */
00652 
00653 /* ----------------------------------------------------------------------
00654  *
00655  * I/O logging with mod_logio
00656  */
00657 
00658 APR_DECLARE_OPTIONAL_FN(void, ap_logio_add_bytes_out,
00659                         (conn_rec *c, apr_off_t bytes));
00660 
00661 /* ----------------------------------------------------------------------
00662  *
00663  * ident lookups with mod_ident
00664  */
00665 
00666 APR_DECLARE_OPTIONAL_FN(const char *, ap_ident_lookup,
00667                         (request_rec *r));
00668 
00669 /* ----------------------------------------------------------------------
00670  *
00671  * authorization values with mod_authz_core
00672  */
00673 
00674 APR_DECLARE_OPTIONAL_FN(int, authz_some_auth_required, (request_rec *r));
00675 APR_DECLARE_OPTIONAL_FN(const char *, authn_ap_auth_type, (request_rec *r));
00676 APR_DECLARE_OPTIONAL_FN(const char *, authn_ap_auth_name, (request_rec *r));
00677 
00678 /* ----------------------------------------------------------------------
00679  *
00680  * authorization values with mod_access_compat
00681  */
00682 
00683 APR_DECLARE_OPTIONAL_FN(int, access_compat_ap_satisfies, (request_rec *r));
00684 
00685 /* ---------------------------------------------------------------------- */
00686 
00687 #ifdef __cplusplus
00688 }
00689 #endif
00690 
00691 #endif  /* !APACHE_HTTP_CORE_H */
00692 

Generated on Sun Jul 1 10:07:04 2007 by Doxygen 1.5.2. This rendition of the open source Apache HTTP Server header documentation is not endorsed by or affiliated with the Apache Software Foundation.