http_request.c revision 81a0e29031b198417bd4c534d326d021c81861e8
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor/* ====================================================================
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * The Apache Software License, Version 1.1
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor *
dfcf800069c4a5afdd843c8f0ae454140df9f26dlgentis * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * reserved.
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor *
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * Redistribution and use in source and binary forms, with or without
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * modification, are permitted provided that the following conditions
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * are met:
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor *
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * 1. Redistributions of source code must retain the above copyright
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * notice, this list of conditions and the following disclaimer.
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor *
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * 2. Redistributions in binary form must reproduce the above copyright
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * notice, this list of conditions and the following disclaimer in
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * the documentation and/or other materials provided with the
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * distribution.
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor *
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * 3. The end-user documentation included with the redistribution,
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * if any, must include the following acknowledgment:
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * "This product includes software developed by the
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * Apache Software Foundation (http://www.apache.org/)."
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * Alternately, this acknowledgment may appear in the software itself,
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * if and wherever such third-party acknowledgments normally appear.
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor *
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * 4. The names "Apache" and "Apache Software Foundation" must
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * not be used to endorse or promote products derived from this
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * software without prior written permission. For written
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * permission, please contact apache@apache.org.
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor *
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * 5. Products derived from this software may not be called "Apache",
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * nor may "Apache" appear in their name, without prior written
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * permission of the Apache Software Foundation.
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor *
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * SUCH DAMAGE.
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * ====================================================================
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor *
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * This software consists of voluntary contributions made by many
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * individuals on behalf of the Apache Software Foundation. For more
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * information on the Apache Software Foundation, please see
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * <http://www.apache.org/>.
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor *
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * Portions of this software are based upon public domain software
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * originally written at the National Center for Supercomputing Applications,
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * University of Illinois, Urbana-Champaign.
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor/*
5a884cb4f4b177e207554c26334ef853c5665e79lgentis * http_request.c: functions to get and process requests
5a884cb4f4b177e207554c26334ef853c5665e79lgentis *
5a884cb4f4b177e207554c26334ef853c5665e79lgentis * Rob McCool 3/21/93
5a884cb4f4b177e207554c26334ef853c5665e79lgentis *
5a884cb4f4b177e207554c26334ef853c5665e79lgentis * Thoroughly revamped by rst for Apache. NB this file reads
5a884cb4f4b177e207554c26334ef853c5665e79lgentis * best from the bottom up.
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis *
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor#include "apr_strings.h"
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor#include "apr_file_io.h"
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor#include "apr_fnmatch.h"
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis#define APR_WANT_STRFUNC
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis#include "apr_want.h"
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor#define CORE_PRIVATE
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis#include "ap_config.h"
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis#include "httpd.h"
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor#include "http_config.h"
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor#include "http_request.h"
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor#include "http_core.h"
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis#include "http_protocol.h"
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor#include "http_log.h"
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor#include "http_main.h"
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor#include "util_filter.h"
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor#include "util_charset.h"
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor#include "mod_core.h"
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor#if APR_HAVE_STDARG_H
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis#include <stdarg.h>
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor#endif
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor/*****************************************************************
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor *
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * Mainline request processing...
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzorAP_DECLARE(void) ap_die(int type, request_rec *r)
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor{
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor int error_index = ap_index_of_response(type);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor char *custom_response = ap_response_code_string(r, error_index);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor int recursive_error = 0;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis if (type == AP_FILTER_ERROR) {
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis return;
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis }
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis if (type == DONE) {
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis ap_finalize_request_protocol(r);
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis return;
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor /*
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * The following takes care of Apache redirects to custom response URLs
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * Note that if we are already dealing with the response to some other
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * error condition, we just report on the original error, and give up on
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * any attempt to handle the other thing "intelligently"...
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor if (r->status != HTTP_OK && !ap_status_drops_connection(type)) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor recursive_error = type;
5a884cb4f4b177e207554c26334ef853c5665e79lgentis
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor while (r->prev && (r->prev->status != HTTP_OK))
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r = r->prev; /* Get back to original error */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor type = r->status;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor custom_response = NULL; /* Do NOT retry the custom thing! */
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->status = type;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor /*
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * This test is done here so that none of the auth modules needs to know
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * about proxy authentication. They treat it like normal auth, and then
1f8ff58254f12b4a0756dc2bd173fcd4a401d3e2lgentis * we tweak the status.
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor if (HTTP_UNAUTHORIZED == r->status && PROXYREQ_PROXY == r->proxyreq) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->status = HTTP_PROXY_AUTHENTICATION_REQUIRED;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor /* If we don't want to keep the connection, make sure we mark that the
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * connection is not eligible for keepalive. If we want to keep the
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * connection, be sure that the request body (if any) has been read.
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor if (ap_status_drops_connection(r->status)) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->connection->keepalive = 0;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis /*
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * Two types of custom redirects --- plain text, and URLs. Plain text has
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * a leading '"', so the URL code, here, is triggered on its absence
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor if (custom_response && custom_response[0] != '"') {
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor if (ap_is_url(custom_response)) {
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis /*
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * The URL isn't local, so lets drop through the rest of this
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * apache code, and continue with the usual REDIRECT handler.
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * But note that the client will ultimately see the wrong
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * status...
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor */
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis r->status = HTTP_MOVED_TEMPORARILY;
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis apr_table_setn(r->headers_out, "Location", custom_response);
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis }
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis else if (custom_response[0] == '/') {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor const char *error_notes;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->no_local_copy = 1; /* Do NOT send HTTP_NOT_MODIFIED for
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * error documents! */
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis /*
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * This redirect needs to be a GET no matter what the original
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * method was.
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor apr_table_setn(r->subprocess_env, "REQUEST_METHOD", r->method);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis /*
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * Provide a special method for modules to communicate
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * more informative (than the plain canned) messages to us.
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * Propagate them to ErrorDocuments via the ERROR_NOTES variable:
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor if ((error_notes = apr_table_get(r->notes,
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis "error-notes")) != NULL) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor apr_table_setn(r->subprocess_env, "ERROR_NOTES", error_notes);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis r->method = apr_pstrdup(r->pool, "GET");
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis r->method_number = M_GET;
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis ap_internal_redirect(custom_response, r);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor return;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor else {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor /*
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * Dumb user has given us a bad url to redirect to --- fake up
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * dying with a recursive server error...
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor recursive_error = HTTP_INTERNAL_SERVER_ERROR;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor "Invalid error redirection directive: %s",
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor custom_response);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor ap_send_error_response(r, recursive_error);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor}
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzorstatic void check_pipeline_flush(request_rec *r)
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis{
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor conn_rec *c = r->connection;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor /* ### if would be nice if we could PEEK without a brigade. that would
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor ### allow us to defer creation of the brigade to when we actually
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor ### need to send a FLUSH. */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor apr_bucket_brigade *bb = apr_brigade_create(r->pool, c->bucket_alloc);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor /* Flush the filter contents if:
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor *
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * 1) the connection will be closed
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * 2) there isn't a request ready to be read
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis */
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis /* ### shouldn't this read from the connection input filters? */
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis /* ### is zero correct? that means "read one line" */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor if (!r->connection->keepalive ||
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor ap_get_brigade(r->input_filters, bb, AP_MODE_EATCRLF,
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor APR_NONBLOCK_READ, 0) != APR_SUCCESS) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor apr_bucket *e = apr_bucket_flush_create(c->bucket_alloc);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor /* We just send directly to the connection based filters. At
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * this point, we know that we have seen all of the data
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * (request finalization sent an EOS bucket, which empties all
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * of the request filters). We just want to flush the buckets
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * if something hasn't been sent to the network yet.
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis */
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis APR_BRIGADE_INSERT_HEAD(bb, e);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor ap_pass_brigade(r->connection->output_filters, bb);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor}
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzorvoid ap_process_request(request_rec *r)
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor{
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor int access_status;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor /* Give quick handlers a shot at serving the request on the fast
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * path, bypassing all of the other Apache hooks.
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor *
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * This hook was added to enable serving files out of a URI keyed
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * content cache ( e.g., Mike Abbott's Quick Shortcut Cache,
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * described here: http://oss.sgi.com/projects/apache/mod_qsc.html )
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor *
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * It may have other uses as well, such as routing requests directly to
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * content handlers that have the ability to grok HTTP and do their
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * own access checking, etc (e.g. servlet engines).
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor *
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * Use this hook with extreme care and only if you know what you are
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * doing.
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor access_status = ap_run_quick_handler(r, 0); /* Not a look-up request */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor if (access_status == DECLINED) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor access_status = ap_process_request_internal(r);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor if (access_status == OK) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor access_status = ap_invoke_handler(r);
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis }
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis }
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis if (access_status == DONE) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor /* e.g., something not in storage like TRACE */
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis access_status = OK;
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis if (access_status == OK) {
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis ap_finalize_request_protocol(r);
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis }
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis else {
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis ap_die(access_status, r);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis /*
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * We want to flush the last packet if this isn't a pipelining connection
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * *before* we start into logging. Suppose that the logging causes a DNS
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * lookup to occur, which may have a high latency. If we hold off on
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * this packet, then it'll appear like the link is stalled when really
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * it's the application that's stalled.
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor check_pipeline_flush(r);
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis ap_run_log_transaction(r);
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis}
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentisstatic apr_table_t *rename_original_env(apr_pool_t *p, apr_table_t *t)
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis{
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis const apr_array_header_t *env_arr = apr_table_elts(t);
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis const apr_table_entry_t *elts = (const apr_table_entry_t *) env_arr->elts;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor apr_table_t *new = apr_table_make(p, env_arr->nalloc);
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis int i;
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis for (i = 0; i < env_arr->nelts; ++i) {
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis if (!elts[i].key)
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor continue;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor apr_table_setn(new, apr_pstrcat(p, "REDIRECT_", elts[i].key, NULL),
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor elts[i].val);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor return new;
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis}
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzorstatic request_rec *internal_internal_redirect(const char *new_uri,
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor request_rec *r) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor int access_status;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor ap_filter_t *f;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor request_rec *new = (request_rec *) apr_pcalloc(r->pool,
1f8ff58254f12b4a0756dc2bd173fcd4a401d3e2lgentis sizeof(request_rec));
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->connection = r->connection;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->server = r->server;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->pool = r->pool;
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis /*
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * A whole lot of this really ought to be shared with http_protocol.c...
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * another missing cleanup. It's particularly inappropriate to be
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * setting header_only, etc., here.
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->method = r->method;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->method_number = r->method_number;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->allowed_methods = ap_make_method_list(new->pool, 2);
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis ap_parse_uri(new, new_uri);
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis new->request_config = ap_create_request_config(r->pool);
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->per_dir_config = r->server->lookup_defaults;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->prev = r;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->next = new;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor /* Must have prev and next pointers set before calling create_request
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * hook.
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor ap_run_create_request(new);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor /* Inherit the rest of the protocol info... */
5a884cb4f4b177e207554c26334ef853c5665e79lgentis
5a884cb4f4b177e207554c26334ef853c5665e79lgentis new->the_request = r->the_request;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->allowed = r->allowed;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->status = r->status;
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis new->assbackwards = r->assbackwards;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->header_only = r->header_only;
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis new->protocol = r->protocol;
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis new->proto_num = r->proto_num;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->hostname = r->hostname;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->request_time = r->request_time;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->main = r->main;
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis new->headers_in = r->headers_in;
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis new->headers_out = apr_table_make(r->pool, 12);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->err_headers_out = r->err_headers_out;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->subprocess_env = rename_original_env(r->pool, r->subprocess_env);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->notes = apr_table_make(r->pool, 5);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->allowed_methods = ap_make_method_list(new->pool, 2);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->htaccess = r->htaccess;
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis new->no_cache = r->no_cache;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->expecting_100 = r->expecting_100;
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis new->no_local_copy = r->no_local_copy;
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis new->read_length = r->read_length; /* We can only read it once */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->vlist_validator = r->vlist_validator;
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->proto_output_filters = r->proto_output_filters;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->proto_input_filters = r->proto_input_filters;
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->output_filters = new->proto_output_filters;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor new->input_filters = new->proto_input_filters;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor f = new->input_filters;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor while (f) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor if (f->r == r) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor f->r = new;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor f = f->next;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor f = new->output_filters;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor while (f) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor if (f->r == r) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor f->r = new;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor f = f->next;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor ap_add_input_filter("HTTP_IN", NULL, new, new->connection);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis apr_table_setn(new->subprocess_env, "REDIRECT_STATUS",
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor apr_itoa(r->pool, r->status));
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor /*
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * XXX: hmm. This is because mod_setenvif and mod_unique_id really need
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * to do their thing on internal redirects as well. Perhaps this is a
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * misnamed function.
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor */
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis if ((access_status = ap_run_post_read_request(new))) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor ap_die(access_status, new);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor return NULL;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor return new;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor}
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor/* XXX: Is this function is so bogus and fragile that we deep-6 it? */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzorAP_DECLARE(void) ap_internal_fast_redirect(request_rec *rr, request_rec *r)
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor{
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor ap_filter_t *filters;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor /* We need to tell POOL_DEBUG that we're guaranteeing that rr->pool
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * will exist as long as r->pool. Otherwise we run into troubles because
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * some values in this request will be allocated in r->pool, and others in
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * rr->pool.
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor apr_pool_join(r->pool, rr->pool);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->mtime = rr->mtime;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->uri = rr->uri;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->filename = rr->filename;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->canonical_filename = rr->canonical_filename;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->path_info = rr->path_info;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->args = rr->args;
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis r->finfo = rr->finfo;
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis r->handler = rr->handler;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor ap_set_content_type(r, rr->content_type);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->content_encoding = rr->content_encoding;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->content_languages = rr->content_languages;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->per_dir_config = rr->per_dir_config;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor /* copy output headers from subrequest, but leave negotiation headers */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->notes = apr_table_overlay(r->pool, rr->notes, r->notes);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->headers_out = apr_table_overlay(r->pool, rr->headers_out,
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->headers_out);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->err_headers_out = apr_table_overlay(r->pool, rr->err_headers_out,
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->err_headers_out);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->subprocess_env = apr_table_overlay(r->pool, rr->subprocess_env,
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->subprocess_env);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->output_filters = rr->output_filters;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->input_filters = rr->input_filters;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis if (r->main) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor ap_add_output_filter_handle(ap_subreq_core_filter_handle,
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor NULL, r, r->connection);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor else if (r->output_filters->frec == ap_subreq_core_filter_handle) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor ap_remove_output_filter(r->output_filters);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor r->output_filters = r->output_filters->next;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis /* If any filters pointed at the now-defunct rr, we must point them
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * at our "new" instance of r. In particular, some of rr's structures
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * will now be bogus (say rr->headers_out). If a filter tried to modify
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * their f->r structure when it is pointing to rr, the real request_rec
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * will not get updated. Fix that here.
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor filters = r->input_filters;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor while (filters) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor if (filters->r == rr) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor filters->r = r;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor filters = filters->next;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor filters = r->output_filters;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor while (filters) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor if (filters->r == rr) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor filters->r = r;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor filters = filters->next;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor}
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentisAP_DECLARE(void) ap_internal_redirect(const char *new_uri, request_rec *r)
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor{
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis request_rec *new = internal_internal_redirect(new_uri, r);
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis int access_status = ap_process_request_internal(new);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor if (access_status == OK) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor if ((access_status = ap_invoke_handler(new)) != 0) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor ap_die(access_status, new);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor return;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor ap_finalize_request_protocol(new);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor else {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor ap_die(access_status, new);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor}
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor/* This function is designed for things like actions or CGI scripts, when
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * using AddHandler, and you want to preserve the content type across
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * an internal redirect.
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzorAP_DECLARE(void) ap_internal_redirect_handler(const char *new_uri, request_rec *r)
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor{
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor int access_status;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor request_rec *new = internal_internal_redirect(new_uri, r);
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis if (r->handler)
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis ap_set_content_type(new, r->content_type);
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis access_status = ap_process_request_internal(new);
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis if (access_status == OK) {
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis if ((access_status = ap_invoke_handler(new)) != 0) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor ap_die(access_status, new);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor return;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor ap_finalize_request_protocol(new);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis else {
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis ap_die(access_status, new);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor}
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzorAP_DECLARE(void) ap_allow_methods(request_rec *r, int reset, ...)
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor{
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor const char *method;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor va_list methods;
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor /*
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor * Get rid of any current settings if requested; not just the
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * well-known methods but any extensions as well.
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor if (reset) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor ap_clear_method_list(r->allowed_methods);
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis }
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis va_start(methods, reset);
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis while ((method = va_arg(methods, const char *)) != NULL) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor ap_method_list_add(r->allowed_methods, method);
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis }
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis}
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentisAP_DECLARE(void) ap_allow_standard_methods(request_rec *r, int reset, ...)
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis{
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor int method;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor va_list methods;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor apr_int64_t mask;
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor /*
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * Get rid of any current settings if requested; not just the
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis * well-known methods but any extensions as well.
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor */
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor if (reset) {
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis ap_clear_method_list(r->allowed_methods);
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis mask = 0;
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis va_start(methods, reset);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor while ((method = va_arg(methods, int)) != -1) {
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor mask |= (AP_METHOD_BIT << method);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor }
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor va_end(methods);
ee310fab1ff1ed24942136c5e7423bfae0ff01eagryzor
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis r->allowed_methods->method_mask |= mask;
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis}
3016c72ae8173bcfc0989ff1b297d4f27f445108lgentis