http_request.h revision c3e342e5b0b9fea6617ee16d2da02c3ef2108126
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq/* ====================================================================
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * The Apache Software License, Version 1.1
1c6c57c5efaae13729ff45427c8aebef7219a7e4nd * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * reserved.
031b91a62d25106ae69d4693475c79618dd5e884fielding * Redistribution and use in source and binary forms, with or without
031b91a62d25106ae69d4693475c79618dd5e884fielding * modification, are permitted provided that the following conditions
031b91a62d25106ae69d4693475c79618dd5e884fielding * 1. Redistributions of source code must retain the above copyright
031b91a62d25106ae69d4693475c79618dd5e884fielding * notice, this list of conditions and the following disclaimer.
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * 2. Redistributions in binary form must reproduce the above copyright
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * notice, this list of conditions and the following disclaimer in
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * the documentation and/or other materials provided with the
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * distribution.
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * 3. The end-user documentation included with the redistribution,
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * if any, must include the following acknowledgment:
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * "This product includes software developed by the
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * Apache Software Foundation (http://www.apache.org/)."
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * Alternately, this acknowledgment may appear in the software itself,
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * if and wherever such third-party acknowledgments normally appear.
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * 4. The names "Apache" and "Apache Software Foundation" must
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * not be used to endorse or promote products derived from this
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * software without prior written permission. For written
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * permission, please contact apache@apache.org.
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * 5. Products derived from this software may not be called "Apache",
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * nor may "Apache" appear in their name, without prior written
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * permission of the Apache Software Foundation.
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * SUCH DAMAGE.
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * ====================================================================
9cd3b05d7b70f07a742bbaf548fa4fa2bdbe5ce6noodl * This software consists of voluntary contributions made by many
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * individuals on behalf of the Apache Software Foundation. For more
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * information on the Apache Software Foundation, please see
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * Portions of this software are based upon public domain software
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * originally written at the National Center for Supercomputing Applications,
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * University of Illinois, Urbana-Champaign.
fd4eea74d45a37ea68b516ade5efa9e95f990dacniqextern "C" {
3a2a3f1d2e2620e074b39a4f92a327aee66aa1a4niq * @brief Apache Request library
ada9e05683e8b4580beda83723137878c14a7ddcigalic/* http_request.c is the code which handles the main line of request
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * processing, once a request has been read in (finding the right per-
fd4eea74d45a37ea68b516ade5efa9e95f990dacniq * directory configuration, building it if necessary, and calling all
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * the module dispatch functions in the right order).
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * The pieces here which are public to the modules, allow them to learn
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * how the server would handle some other file or URI, or perhaps even
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * direct the server to serve that other file instead of the one the
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * client requested directly.
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * There are two ways to do that. The first is the sub_request mechanism,
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar * which handles looking up files and URIs as adjuncts to some other
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * request (e.g., directory entries for multiviews and directory listings);
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * the lookup functions stop short of actually running the request, but
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * (e.g., for includes), a module may call for the request to be run
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * by calling run_sub_req. The space allocated to create sub_reqs can be
fd4eea74d45a37ea68b516ade5efa9e95f990dacniq * reclaimed by calling destroy_sub_req --- be sure to copy anything you care
fd4eea74d45a37ea68b516ade5efa9e95f990dacniq * about which was allocated in its apr_pool_t elsewhere before doing this.
135e1d6a301398168e3b2e5125508828591e1673niq * Create a sub request from the given URI. This sub request can be
fd4eea74d45a37ea68b516ade5efa9e95f990dacniq * inspected to find information about the requested URI
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * @param new_file The URI to lookup
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * @param r The current request
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * @param next_filter The first filter the sub_request should use. If this is
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * NULL, it defaults to the first filter for the main request
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * @return The new request record
ada9e05683e8b4580beda83723137878c14a7ddcigalic * @deffunc request_rec * ap_sub_req_lookup_uri(const char *new_file, const request_rec *r)
ada9e05683e8b4580beda83723137878c14a7ddcigalicAP_DECLARE(request_rec *) ap_sub_req_lookup_uri(const char *new_file,
9eaff9e86614321f448012369e1828ebfae1e96fminfrin * Create a sub request for the given file. This sub request can be
7ddb12eb8231b3b82b907341b4611d15ecd7e203chrisd * inspected to find information about the requested file
7ddb12eb8231b3b82b907341b4611d15ecd7e203chrisd * @param new_file The URI to lookup
7ddb12eb8231b3b82b907341b4611d15ecd7e203chrisd * @param r The current request
7ddb12eb8231b3b82b907341b4611d15ecd7e203chrisd * @param next_filter The first filter the sub_request should use. If this is
9eaff9e86614321f448012369e1828ebfae1e96fminfrin * NULL, it defaults to the first filter for the main request
9eaff9e86614321f448012369e1828ebfae1e96fminfrin * @return The new request record
9eaff9e86614321f448012369e1828ebfae1e96fminfrin * @deffunc request_rec * ap_sub_req_lookup_file(const char *new_file, const request_rec *r)
9eaff9e86614321f448012369e1828ebfae1e96fminfrinAP_DECLARE(request_rec *) ap_sub_req_lookup_file(const char *new_file,
9eaff9e86614321f448012369e1828ebfae1e96fminfrin * Create a sub request for the given URI using a specific method. This
9eaff9e86614321f448012369e1828ebfae1e96fminfrin * sub request can be inspected to find information about the requested URI
0c0d43f1fe70a4015b6a21bbbd423c3b4d9f17a2gryzor * @param method The method to use in the new sub request
0c0d43f1fe70a4015b6a21bbbd423c3b4d9f17a2gryzor * @param new_file The URI to lookup
a0041cd68daaafdff8582777b159982504782124gryzor * @param r The current request
a0041cd68daaafdff8582777b159982504782124gryzor * @param next_filter The first filter the sub_request should use. If this is
a0041cd68daaafdff8582777b159982504782124gryzor * NULL, it defaults to the first filter for the main request
a0041cd68daaafdff8582777b159982504782124gryzor * @return The new request record
a0041cd68daaafdff8582777b159982504782124gryzor * @deffunc request_rec * ap_sub_req_method_uri(const char *method, const char *new_file, const request_rec *r)
0c0d43f1fe70a4015b6a21bbbd423c3b4d9f17a2gryzorAP_DECLARE(request_rec *) ap_sub_req_method_uri(const char *method,
0c0d43f1fe70a4015b6a21bbbd423c3b4d9f17a2gryzor const char *new_file,
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * An output filter to strip EOS buckets from sub-requests. This always
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * has to be inserted at the end of a sub-requests filter stack.
494d04a123ada4f92bbf7a41e067d9c7b1c50418niq * @param f The current filter
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * @param bb The brigade to filter
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * @deffunc apr_status_t ap_sub_req_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
53463cef28766dd8c9cc3c5948569b7cc1d898c0niqAP_CORE_DECLARE_NONSTD(apr_status_t) ap_sub_req_output_filter(ap_filter_t *f,
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * Run the handler for the sub request
ada9e05683e8b4580beda83723137878c14a7ddcigalic * @param r The sub request to run
ada9e05683e8b4580beda83723137878c14a7ddcigalic * @return The return code for the sub request
ada9e05683e8b4580beda83723137878c14a7ddcigalic * @deffunc int ap_run_sub_req(request_rec *r)
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * Free the memory associated with a sub request
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * @param r The sub request to finish
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * @deffunc void ap_destroy_sub_req(request_rec *r)
b575597dd920816d764150343e7986e20a10c112niq * Then there's the case that you want some other request to be served
bd053cae10b2a4dd7262359c896b43d32617ea86poirier * as the top-level request INSTEAD of what the client requested directly.
bd053cae10b2a4dd7262359c896b43d32617ea86poirier * If so, call this from a handler, and then immediately return OK.
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * Redirect the current request to some other uri
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * @param new_uri The URI to replace the current request with
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * @param r The current request
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * @deffunc void ap_internal_redirect(const char *new_uri, request_rec *r)
494d04a123ada4f92bbf7a41e067d9c7b1c50418niqAP_DECLARE(void) ap_internal_redirect(const char *new_uri, request_rec *r);
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * This function is designed for things like actions or CGI scripts, when
a3ccecfa0798e5a5895c55d2b0adb3a226194880niq * using AddHandler, and you want to preserve the content type across
0c0d43f1fe70a4015b6a21bbbd423c3b4d9f17a2gryzor * an internal redirect.
adc528ddc219915d3a52bc68a1e2cd7768b37a19humbedooh * @param new_uri The URI to replace the current request with.
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * @param r The current request
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * @deffunc void ap_internal_redirect_handler(const char *new_uri, request_rec *r)
ada9e05683e8b4580beda83723137878c14a7ddcigalicAP_DECLARE(void) ap_internal_redirect_handler(const char *new_uri, request_rec *r);
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * Can be used within any handler to determine if any authentication
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * is required for the current request
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * @param r The current request
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * @return 1 if authentication is required, 0 otherwise
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisd * @deffunc int ap_some_auth_required(request_rec *r)
ba428b299d693a5be94d0c3d8b096e9c1c494646chrisdAP_DECLARE(int) ap_some_auth_required(request_rec *r);
bd053cae10b2a4dd7262359c896b43d32617ea86poirier * Determine if the current request is the main request or a sub requests
b575597dd920816d764150343e7986e20a10c112niq * @param r The current request
b575597dd920816d764150343e7986e20a10c112niq * @retrn 1 if this is a main request, 0 otherwise
bd053cae10b2a4dd7262359c896b43d32617ea86poirier * @deffunc int ap_is_initial_req(request_rec *r)
53463cef28766dd8c9cc3c5948569b7cc1d898c0niq * Function to set the r->mtime field to the specified value if it's later
#define MERGE_ALLOW 0
#ifdef CORE_PRIVATE
/* Function called by main.c to handle first-level request */
#ifdef __cplusplus