http_core.h revision 117e2968318323d2ad2187fcd4de379d2eca245c
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye/* ====================================================================
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * The Apache Software License, Version 1.1
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye *
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * reserved.
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye *
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * Redistribution and use in source and binary forms, with or without
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * modification, are permitted provided that the following conditions
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * are met:
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye *
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * 1. Redistributions of source code must retain the above copyright
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * notice, this list of conditions and the following disclaimer.
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye *
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * 2. Redistributions in binary form must reproduce the above copyright
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * notice, this list of conditions and the following disclaimer in
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * the documentation and/or other materials provided with the
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * distribution.
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye *
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * 3. The end-user documentation included with the redistribution,
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * if any, must include the following acknowledgment:
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * "This product includes software developed by the
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * Apache Software Foundation (http://www.apache.org/)."
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * Alternately, this acknowledgment may appear in the software itself,
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * if and wherever such third-party acknowledgments normally appear.
cf1f7b5e81583dfca30972cfef322266a6928e7fKnut Anders Hatlen *
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * 4. The names "Apache" and "Apache Software Foundation" must
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * not be used to endorse or promote products derived from this
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * software without prior written permission. For written
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * permission, please contact apache@apache.org.
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye *
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * 5. Products derived from this software may not be called "Apache",
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * nor may "Apache" appear in their name, without prior written
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * permission of the Apache Software Foundation.
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye *
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * SUCH DAMAGE.
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * ====================================================================
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye *
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * This software consists of voluntary contributions made by many
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * individuals on behalf of the Apache Software Foundation. For more
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * information on the Apache Software Foundation, please see
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * <http://www.apache.org/>.
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye *
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * Portions of this software are based upon public domain software
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * originally written at the National Center for Supercomputing Applications,
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * University of Illinois, Urbana-Champaign.
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye */
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye#ifndef APACHE_HTTP_CORE_H
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye#define APACHE_HTTP_CORE_H
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye#include "apr.h"
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye#include "apr_hash.h"
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye#if APR_HAVE_STRUCT_RLIMIT
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye#include <sys/time.h>
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye#include <sys/resource.h>
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye#endif
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye#ifdef __cplusplus
64b763950bf11e9357facbd2b5666631a895c085Trond Norbyeextern "C" {
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye#endif
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye/**
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * @package CORE HTTP Daemon
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye */
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye/* ****************************************************************
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye *
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * The most basic server code is encapsulated in a single module
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * known as the core, which is just *barely* functional enough to
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * serve documents, though not terribly well.
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye *
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * Largely for NCSA back-compatibility reasons, the core needs to
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * make pieces of its config structures available to other modules.
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * The accessors are declared here, along with the interpretation
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * of one of them (allow_options).
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye */
0a0811923cbbd2976425db6f4c78eed811c2825bKnut Anders Hatlen
77e3bcb700604954082585e3d7107004769a9f48Trond Norbye#define OPT_NONE 0
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders Hatlen#define OPT_INDEXES 1
0a0811923cbbd2976425db6f4c78eed811c2825bKnut Anders Hatlen#define OPT_INCLUDES 2
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye#define OPT_SYM_LINKS 4
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye#define OPT_EXECCGI 8
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye#define OPT_UNSET 16
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye#define OPT_INCNOEXEC 32
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye#define OPT_SYM_OWNER 64
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye#define OPT_MULTI 128
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye#define OPT_ALL (OPT_INDEXES|OPT_INCLUDES|OPT_SYM_LINKS|OPT_EXECCGI)
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye/* options for get_remote_host() */
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye/* REMOTE_HOST returns the hostname, or NULL if the hostname
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * lookup fails. It will force a DNS lookup according to the
225d5411e0f1f0e690e3553aad7a97c648d566a1HemangLavana * HostnameLookups setting.
225d5411e0f1f0e690e3553aad7a97c648d566a1HemangLavana */
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye#define REMOTE_HOST (0)
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye/* REMOTE_NAME returns the hostname, or the dotted quad if the
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * hostname lookup fails. It will force a DNS lookup according
75640e2b0da81c240758d747e76d30acd1ed194dKnut Anders Hatlen * to the HostnameLookups setting.
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye */
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye#define REMOTE_NAME (1)
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye/* REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * never forced.
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye */
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye#define REMOTE_NOLOOKUP (2)
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye/* REMOTE_DOUBLE_REV will always force a DNS lookup, and also force
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye * a double reverse lookup, regardless of the HostnameLookups
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye * setting. The result is the (double reverse checked) hostname,
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye * or NULL if any of the lookups fail.
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye */
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye#define REMOTE_DOUBLE_REV (3)
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye#define SATISFY_ALL 0
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye#define SATISFY_ANY 1
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye#define SATISFY_NOSPEC 2
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye/* Make sure we don't write less than 8192 bytes at any one time.
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye */
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye#define AP_MIN_BYTES_TO_WRITE 8192
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye/**
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye * Retrieve the value of Options for this request
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye * @param r The current request
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye * @return the Options bitmask
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye * @deffunc int ap_allow_options(request_rec *r)
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye */
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond NorbyeAP_DECLARE(int) ap_allow_options(request_rec *r);
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye/**
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye * Retrieve the value of the AllowOverride for this request
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye * @param r The current request
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye * @return the overrides bitmask
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye * @deffunc int ap_allow_overrides(request_rec *r)
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye */
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond NorbyeAP_DECLARE(int) ap_allow_overrides(request_rec *r);
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye/**
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * Retrieve the value of the DefaultType directive, or text/plain if not set
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * @param r The current request
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * @return The default type
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik * @deffunc const char *ap_default_type(request_rec *r)
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye */
64b763950bf11e9357facbd2b5666631a895c085Trond NorbyeAP_DECLARE(const char *) ap_default_type(request_rec *r);
9cf297d9a579835e9336d587eaee187ca0954767Knut Anders Hatlen
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen/**
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * Retrieve the document root for this server
9cf297d9a579835e9336d587eaee187ca0954767Knut Anders Hatlen * @param r The current request
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * @warning Don't use this! If your request went through a Userdir, or
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * something like that, it'll screw you. But it's back-compatible...
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * @return The document root
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * @deffunc const char *ap_document_root(request_rec *r)
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen */
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders HatlenAP_DECLARE(const char *) ap_document_root(request_rec *r);
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen/**
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * Lookup the remote client's DNS name or IP address
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * @param conn The current connection
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * @param dir_config The directory config vector from the request
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * @param type The type of lookup to perform. One of:
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * <pre>
9cf297d9a579835e9336d587eaee187ca0954767Knut Anders Hatlen * REMOTE_HOST returns the hostname, or NULL if the hostname
9cf297d9a579835e9336d587eaee187ca0954767Knut Anders Hatlen * lookup fails. It will force a DNS lookup according to the
9cf297d9a579835e9336d587eaee187ca0954767Knut Anders Hatlen * HostnameLookups setting.
9cf297d9a579835e9336d587eaee187ca0954767Knut Anders Hatlen * REMOTE_NAME returns the hostname, or the dotted quad if the
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * hostname lookup fails. It will force a DNS lookup according
9cf297d9a579835e9336d587eaee187ca0954767Knut Anders Hatlen * to the HostnameLookups setting.
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * never forced.
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * REMOTE_DOUBLE_REV will always force a DNS lookup, and also force
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * a double reverse lookup, regardless of the HostnameLookups
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * setting. The result is the (double reverse checked)
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * hostname, or NULL if any of the lookups fail.
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * </pre>
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * @param str_is_ip unless NULL is passed, this will be set to non-zero on output when an IP address
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * string is returned
7b046969a1b2565787df8ae3a8126359e8cd6fafTrond Norbye * @return The remote hostname
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * @deffunc const char *ap_get_remote_host(conn_rec *conn, void *dir_config, int type, int *str_is_ip)
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen */
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders HatlenAP_DECLARE(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config, int type, int *str_is_ip);
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen/**
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * Retrieve the login name of the remote user. Undef if it could not be
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen * determined
9661674ed58ba62a40e43d1a4b38d5e77c3c6545Knut Anders Hatlen * @param r The current request
9661674ed58ba62a40e43d1a4b38d5e77c3c6545Knut Anders Hatlen * @return The user logged in to the client machine
9661674ed58ba62a40e43d1a4b38d5e77c3c6545Knut Anders Hatlen * @deffunc const char *ap_get_remote_logname(request_rec *r)
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders Hatlen */
2dbc1835e0ae88ad102e2b9a85e5c7b5298b14b6Knut Anders HatlenAP_DECLARE(const char *) ap_get_remote_logname(request_rec *r);
9cf297d9a579835e9336d587eaee187ca0954767Knut Anders Hatlen
9cf297d9a579835e9336d587eaee187ca0954767Knut Anders Hatlen/* Used for constructing self-referencing URLs, and things like SERVER_PORT,
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye * and SERVER_NAME.
9cf297d9a579835e9336d587eaee187ca0954767Knut Anders Hatlen */
c0550b01024b910b8c1468811c0ea663b10b1372Trond Norbye/**
c0550b01024b910b8c1468811c0ea663b10b1372Trond Norbye * build a fully qualified URL from the uri and information in the request rec
c0550b01024b910b8c1468811c0ea663b10b1372Trond Norbye * @param p The pool to allocate the URL from
c0550b01024b910b8c1468811c0ea663b10b1372Trond Norbye * @param uri The path to the requested file
9794eb72d2b2da2812cdba67562851047cce4600Trond Norbye * @param r The current request
c0550b01024b910b8c1468811c0ea663b10b1372Trond Norbye * @return A fully qualified URL
523201f786f6b12b7cf54091c6e5be167878cbeeTrond Norbye * @deffunc char *ap_construct_url(apr_pool_t *p, const char *uri, request_rec *r)
523201f786f6b12b7cf54091c6e5be167878cbeeTrond Norbye */
523201f786f6b12b7cf54091c6e5be167878cbeeTrond NorbyeAP_DECLARE(char *) ap_construct_url(apr_pool_t *p, const char *uri, request_rec *r);
523201f786f6b12b7cf54091c6e5be167878cbeeTrond Norbye
523201f786f6b12b7cf54091c6e5be167878cbeeTrond Norbye/**
523201f786f6b12b7cf54091c6e5be167878cbeeTrond Norbye * Get the current server name from the request
523201f786f6b12b7cf54091c6e5be167878cbeeTrond Norbye * @param r The current request
523201f786f6b12b7cf54091c6e5be167878cbeeTrond Norbye * @return the server name
c0550b01024b910b8c1468811c0ea663b10b1372Trond Norbye * @deffunc const char *ap_get_server_name(request_rec *r)
0a0811923cbbd2976425db6f4c78eed811c2825bKnut Anders Hatlen */
0a0811923cbbd2976425db6f4c78eed811c2825bKnut Anders HatlenAP_DECLARE(const char *) ap_get_server_name(request_rec *r);
0a0811923cbbd2976425db6f4c78eed811c2825bKnut Anders Hatlen
0a0811923cbbd2976425db6f4c78eed811c2825bKnut Anders Hatlen/**
0a0811923cbbd2976425db6f4c78eed811c2825bKnut Anders Hatlen * Get the current server port
0a0811923cbbd2976425db6f4c78eed811c2825bKnut Anders Hatlen * @param The current request
0a0811923cbbd2976425db6f4c78eed811c2825bKnut Anders Hatlen * @return The server's port
0a0811923cbbd2976425db6f4c78eed811c2825bKnut Anders Hatlen * @deffunc apr_port_t ap_get_server_port(const request_rec *r)
0a0811923cbbd2976425db6f4c78eed811c2825bKnut Anders Hatlen */
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders HatlenAP_DECLARE(apr_port_t) ap_get_server_port(const request_rec *r);
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders Hatlen
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders Hatlen/**
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders Hatlen * Return the limit on bytes in request msg body
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders Hatlen * @param r The current request
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders Hatlen * @return the maximum number of bytes in the request msg body
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders Hatlen * @deffunc unsigned long ap_get_limit_req_body(const request_rec *r)
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders Hatlen */
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders HatlenAP_DECLARE(unsigned long) ap_get_limit_req_body(const request_rec *r);
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders Hatlen
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders Hatlen/**
cdf37a6f2e4e7ca653ef8e791cc8e720fa148a39Peter Bray * Return the limit on bytes in XML request msg body
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders Hatlen * @param r The current request
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders Hatlen * @return the maximum number of bytes in XML request msg body
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders Hatlen * @deffunc size_t ap_get_limit_xml_body(const request_rec *r)
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders Hatlen */
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders HatlenAP_DECLARE(size_t) ap_get_limit_xml_body(const request_rec *r);
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders Hatlen
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders Hatlen/**
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders Hatlen * Install a custom response handler for a given status
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders Hatlen * @param r The current request
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders Hatlen * @param status The status for which the custom response should be used
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders Hatlen * @param string The custom response. This can be a static string, a file
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders Hatlen * or a URL
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders Hatlen * @deffunc void ap_custom_response(request_rec *r, int status, char *string)
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders Hatlen */
a07b2874263e3c5f0cd2e83441719415d53059c2Knut Anders HatlenAP_DECLARE(void) ap_custom_response(request_rec *r, int status, char *string);
edcb01bf549171673fd0bb4239f2edfc7a810397Knut Anders Hatlen
edcb01bf549171673fd0bb4239f2edfc7a810397Knut Anders Hatlen/**
edcb01bf549171673fd0bb4239f2edfc7a810397Knut Anders Hatlen * Check for a definition from the server command line
edcb01bf549171673fd0bb4239f2edfc7a810397Knut Anders Hatlen * @param name The define to check for
edcb01bf549171673fd0bb4239f2edfc7a810397Knut Anders Hatlen * @return 1 if defined, 0 otherwise
edcb01bf549171673fd0bb4239f2edfc7a810397Knut Anders Hatlen * @deffunc int ap_exists_config_define(const char *name)
edcb01bf549171673fd0bb4239f2edfc7a810397Knut Anders Hatlen */
edcb01bf549171673fd0bb4239f2edfc7a810397Knut Anders HatlenAP_DECLARE(int) ap_exists_config_define(const char *name);
edcb01bf549171673fd0bb4239f2edfc7a810397Knut Anders Hatlen/* FIXME! See STATUS about how */
85e0595857351c6e22f75b8928967d14cb679ac5Jorgen AustvikAP_DECLARE_NONSTD(int) ap_core_translate(request_rec *r);
85e0595857351c6e22f75b8928967d14cb679ac5Jorgen Austvik
85e0595857351c6e22f75b8928967d14cb679ac5Jorgen Austvik/* Authentication stuff. This is one of the places where compatibility
85e0595857351c6e22f75b8928967d14cb679ac5Jorgen Austvik * with the old config files *really* hurts; they don't discriminate at
85e0595857351c6e22f75b8928967d14cb679ac5Jorgen Austvik * all between different authentication schemes, meaning that we need
85e0595857351c6e22f75b8928967d14cb679ac5Jorgen Austvik * to maintain common state for all of them in the core, and make it
85e0595857351c6e22f75b8928967d14cb679ac5Jorgen Austvik * available to the other modules through interfaces.
85e0595857351c6e22f75b8928967d14cb679ac5Jorgen Austvik */
85e0595857351c6e22f75b8928967d14cb679ac5Jorgen Austviktypedef struct require_line require_line;
85e0595857351c6e22f75b8928967d14cb679ac5Jorgen Austvik
85e0595857351c6e22f75b8928967d14cb679ac5Jorgen Austvik/** A structure to keep track of authorization requirements */
85e0595857351c6e22f75b8928967d14cb679ac5Jorgen Austvikstruct require_line {
85e0595857351c6e22f75b8928967d14cb679ac5Jorgen Austvik /** Where the require line is in the config file. */
85e0595857351c6e22f75b8928967d14cb679ac5Jorgen Austvik apr_int64_t method_mask;
50a8d80b0dcfb193cb17db83610127ef969308d0Jorgen Austvik /** The complete string from the command line */
85e0595857351c6e22f75b8928967d14cb679ac5Jorgen Austvik char *requirement;
85e0595857351c6e22f75b8928967d14cb679ac5Jorgen Austvik};
85e0595857351c6e22f75b8928967d14cb679ac5Jorgen Austvik
85e0595857351c6e22f75b8928967d14cb679ac5Jorgen Austvik/**
85e0595857351c6e22f75b8928967d14cb679ac5Jorgen Austvik * Return the type of authorization required for this request
85e0595857351c6e22f75b8928967d14cb679ac5Jorgen Austvik * @param r The current request
85e0595857351c6e22f75b8928967d14cb679ac5Jorgen Austvik * @return The authorization required
85e0595857351c6e22f75b8928967d14cb679ac5Jorgen Austvik * @deffunc const char *ap_auth_type(request_rec *r)
85e0595857351c6e22f75b8928967d14cb679ac5Jorgen Austvik */
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen AustvikAP_DECLARE(const char *) ap_auth_type(request_rec *r);
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik/**
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik * Return the current Authorization realm
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik * @param r The current request
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik * @return The current authorization realm
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik * @deffunc const char *ap_auth_name(request_rec *r)
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik */
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen AustvikAP_DECLARE(const char *) ap_auth_name(request_rec *r);
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik/**
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik * How the requires lines must be met.
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik * @param r The current request
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik * @return How the requirements must be met. One of:
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik * <pre>
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik * SATISFY_ANY -- any of the requirements must be met.
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik * SATISFY_ALL -- all of the requirements must be met.
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik * SATISFY_NOSPEC -- There are no applicable satisfy lines
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik * </pre>
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik * @deffunc int ap_satisfies(request_rec *r)
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik */
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen AustvikAP_DECLARE(int) ap_satisfies(request_rec *r);
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik/**
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik * Retrieve information about all of the requires directives for this request
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik * @param r The current request
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik * @return An array of all requires directives for this request
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik * @deffunc const apr_array_header_t *ap_requires(request_rec *r)
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik */
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen AustvikAP_DECLARE(const apr_array_header_t *) ap_requires(request_rec *r);
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik#if defined(WIN32)
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik/*
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik * CGI Script stuff for Win32...
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik */
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austviktypedef enum { eFileTypeUNKNOWN, eFileTypeBIN, eFileTypeEXE16, eFileTypeEXE32,
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik eFileTypeSCRIPT } file_type_e;
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austviktypedef enum { INTERPRETER_SOURCE_UNSET, INTERPRETER_SOURCE_REGISTRY_STRICT,
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik INTERPRETER_SOURCE_REGISTRY, INTERPRETER_SOURCE_SHEBANG
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik } interpreter_source_e;
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen AustvikAP_DECLARE(file_type_e) ap_get_win32_interpreter(const request_rec *,
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik char **interpreter,
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik char **arguments);
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik#endif
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik#ifdef CORE_PRIVATE
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik/*
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik * Core is also unlike other modules in being implemented in more than
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik * one file... so, data structures are declared here, even though most of
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik * the code that cares really is in http_core.c. Also, another accessor.
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik */
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen Austvik
2e3c025fdd5908a27cc82eb1d5346368a8be4e0dJorgen AustvikAP_DECLARE_DATA extern module core_module;
64b763950bf11e9357facbd2b5666631a895c085Trond Norbye
/* Per-request configuration */
typedef struct {
/* bucket brigade used by getline for look-ahead and
* ap_get_client_block for holding left-over request body */
struct apr_bucket_brigade *bb;
} core_request_config;
/* Per-directory configuration */
typedef unsigned char allow_options_t;
typedef unsigned char overrides_t;
typedef enum {
srv_sig_unset,
srv_sig_off,
srv_sig_on,
srv_sig_withmail
} server_signature_e;
typedef struct {
/* path of the directory/regex/etc. see also d_is_fnmatch/absolute below */
char *d;
/* the number of slashes in d */
unsigned d_components;
/* If (opts & OPT_UNSET) then no absolute assignment to options has
* been made.
* invariant: (opts_add & opts_remove) == 0
* Which said another way means that the last relative (options + or -)
* assignment made to each bit is recorded in exactly one of opts_add
* or opts_remove.
*/
allow_options_t opts;
allow_options_t opts_add;
allow_options_t opts_remove;
overrides_t override;
/* MIME typing --- the core doesn't do anything at all with this,
* but it does know what to slap on a request for a document which
* goes untyped by other mechanisms before it slips out the door...
*/
char *ap_default_type;
/* Authentication stuff. Groan... */
int satisfy;
char *ap_auth_type;
char *ap_auth_name;
apr_array_header_t *ap_requires;
/* Custom response config. These can contain text or a URL to redirect to.
* if response_code_strings is NULL then there are none in the config,
* if it's not null then it's allocated to sizeof(char*)*RESPONSE_CODES.
* This lets us do quick merges in merge_core_dir_configs().
*/
char **response_code_strings;
/* Hostname resolution etc */
#define HOSTNAME_LOOKUP_OFF 0
#define HOSTNAME_LOOKUP_ON 1
#define HOSTNAME_LOOKUP_DOUBLE 2
#define HOSTNAME_LOOKUP_UNSET 3
unsigned int hostname_lookups : 4;
signed int do_rfc1413 : 2; /* See if client is advertising a username? */
signed int content_md5 : 2; /* calculate Content-MD5? */
#define USE_CANONICAL_NAME_OFF (0)
#define USE_CANONICAL_NAME_ON (1)
#define USE_CANONICAL_NAME_DNS (2)
#define USE_CANONICAL_NAME_UNSET (3)
unsigned use_canonical_name : 2;
/* since is_fnmatch(conf->d) was being called so frequently in
* directory_walk() and its relatives, this field was created and
* is set to the result of that call.
*/
unsigned d_is_fnmatch : 1;
/* should we force a charset on any outgoing parameterless content-type?
* if so, which charset?
*/
#define ADD_DEFAULT_CHARSET_OFF (0)
#define ADD_DEFAULT_CHARSET_ON (1)
#define ADD_DEFAULT_CHARSET_UNSET (2)
unsigned add_default_charset : 2;
const char *add_default_charset_name;
/* System Resource Control */
#ifdef RLIMIT_CPU
struct rlimit *limit_cpu;
#endif
#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS)
struct rlimit *limit_mem;
#endif
#ifdef RLIMIT_NPROC
struct rlimit *limit_nproc;
#endif
unsigned long limit_req_body; /* limit on bytes in request msg body */
long limit_xml_body; /* limit on bytes in XML request msg body */
/* logging options */
server_signature_e server_signature;
int loglevel;
/* Access control */
apr_array_header_t *sec_file;
regex_t *r;
#ifdef WIN32
/* Where to find interpreter to run scripts */
interpreter_source_e script_interpreter_source;
#endif
const char *mime_type; /* forced with ForceType */
const char *handler; /* forced with SetHandler */
const char *output_filters; /* forced with SetOutputFilters */
const char *input_filters; /* forced with SetInputFilters */
} core_dir_config;
/* Per-server core configuration */
typedef struct {
#ifdef GPROF
char *gprof_dir;
#endif
/* Name translations --- we want the core to be able to do *something*
* so it's at least a minimally functional web server on its own (and
* can be tested that way). But let's keep it to the bare minimum:
*/
const char *ap_document_root;
/* Access control */
char *access_name;
apr_array_header_t *sec_dir;
apr_array_header_t *sec_url;
} core_server_config;
/* for http_config.c */
void ap_core_reorder_directories(apr_pool_t *, server_rec *);
/* for mod_perl */
AP_CORE_DECLARE(void) ap_add_per_dir_conf(server_rec *s, void *dir_config);
AP_CORE_DECLARE(void) ap_add_per_url_conf(server_rec *s, void *url_config);
AP_CORE_DECLARE(void) ap_add_file_conf(core_dir_config *conf, void *url_config);
AP_CORE_DECLARE_NONSTD(const char *) ap_limit_section(cmd_parms *cmd, void *dummy, const char *arg);
#endif
/* ----------------------------------------------------------------------
*
* Runtime status/management
*/
typedef enum {
ap_mgmt_type_string,
ap_mgmt_type_long,
ap_mgmt_type_hash
} ap_mgmt_type_e;
typedef union {
const char *s_value;
long i_value;
apr_hash_t *h_value;
} ap_mgmt_value;
typedef struct {
const char *description;
const char *name;
ap_mgmt_type_e vtype;
ap_mgmt_value v;
} ap_mgmt_item_t;
/**
* This hook provdes a way for modules to provide metrics/statistics about
* their operational status.
*
* @param p A pool to use to create entries in the hash table
* @param val The name of the parameter(s) that is wanted. This is
* tree-structured would be in the form ('*' is all the tree,
* 'module.*' all of the module , 'module.foo.*', or
* 'module.foo.bar' )
* @param ht The hash table to store the results. Keys are item names, and
* the values point to ap_mgmt_item_t structures.
* @ingroup hooks
*/
AP_DECLARE_HOOK(int, get_mgmt_items,
(apr_pool_t *p, const char * val, apr_hash_t *ht))
/* ---------------------------------------------------------------------- */
#ifdef __cplusplus
}
#endif
#endif /* !APACHE_HTTP_CORE_H */