http_request.c revision e0d102c882a7ed34d3eec24b36da49f097066a36
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*/
/*
* http_request.c: functions to get and process requests
*
* Rob McCool 3/21/93
*
* Thoroughly revamped by rst for Apache. NB this file reads
* best from the bottom up.
*
*/
#include "apr_strings.h"
#include "apr_file_io.h"
#include "apr_fnmatch.h"
#define APR_WANT_STRFUNC
#include "apr_want.h"
#define CORE_PRIVATE
#include "ap_config.h"
#include "httpd.h"
#include "http_config.h"
#include "http_request.h"
#include "http_core.h"
#include "http_protocol.h"
#include "http_log.h"
#include "http_main.h"
#include "util_filter.h"
#include "util_charset.h"
#include "mod_core.h"
#include <stdarg.h>
#endif
/*****************************************************************
*
* Mainline request processing...
*/
{
int recursive_error = 0;
if (type == AP_FILTER_ERROR) {
return;
}
return;
}
/*
* The following takes care of Apache redirects to custom response URLs
* Note that if we are already dealing with the response to some other
* error condition, we just report on the original error, and give up on
* any attempt to handle the other thing "intelligently"...
*/
r = r->prev; /* Get back to original error */
}
/*
* This test is done here so that none of the auth modules needs to know
* about proxy authentication. They treat it like normal auth, and then
* we tweak the status.
*/
}
/*
* If we want to keep the connection, be sure that the request body
* (if any) has been read.
*/
&& !ap_status_drops_connection(r->status)
(void) ap_discard_request_body(r);
}
/*
* Two types of custom redirects --- plain text, and URLs. Plain text has
* a leading '"', so the URL code, here, is triggered on its absence
*/
if (ap_is_url(custom_response)) {
/*
* The URL isn't local, so lets drop through the rest of this
* apache code, and continue with the usual REDIRECT handler.
* But note that the client will ultimately see the wrong
* status...
*/
r->status = HTTP_MOVED_TEMPORARILY;
}
else if (custom_response[0] == '/') {
const char *error_notes;
* error documents! */
/*
* This redirect needs to be a GET no matter what the original
* method was.
*/
/*
* Provide a special method for modules to communicate
* more informative (than the plain canned) messages to us.
* Propagate them to ErrorDocuments via the ERROR_NOTES variable:
*/
"error-notes")) != NULL) {
}
r->method_number = M_GET;
return;
}
else {
/*
* Dumb user has given us a bad url to redirect to --- fake up
* dying with a recursive server error...
*/
"Invalid error redirection directive: %s",
}
}
}
static void check_pipeline_flush(request_rec *r)
{
/* ### if would be nice if we could PEEK without a brigade. that would
### allow us to defer creation of the brigade to when we actually
### need to send a FLUSH. */
/* Flush the filter contents if:
*
* 1) the connection will be closed
* 2) there isn't a request ready to be read
*/
/* ### shouldn't this read from the connection input filters? */
/* ### is zero correct? that means "read one line" */
if (!r->connection->keepalive ||
APR_NONBLOCK_READ, 0) != APR_SUCCESS) {
apr_bucket *e = apr_bucket_flush_create();
/* We just send directly to the connection based filters. At
* this point, we know that we have seen all of the data
* (request finalization sent an EOS bucket, which empties all
* of the request filters). We just want to flush the buckets
* if something hasn't been sent to the network yet.
*/
}
}
void ap_process_request(request_rec *r)
{
int access_status;
if (access_status == OK) {
}
else if (access_status == DONE) {
/* e.g., something not in storage like TRACE */
access_status = OK;
}
if (access_status == OK) {
}
else {
ap_die(access_status, r);
}
/*
* We want to flush the last packet if this isn't a pipelining connection
* *before* we start into logging. Suppose that the logging causes a DNS
* lookup to occur, which may have a high latency. If we hold off on
* this packet, then it'll appear like the link is stalled when really
* it's the application that's stalled.
*/
}
{
int i;
continue;
}
return new;
}
request_rec *r) {
int access_status;
sizeof(request_rec));
/*
* A whole lot of this really ought to be shared with http_protocol.c...
* another missing cleanup. It's particularly inappropriate to be
* setting header_only, etc., here.
*/
/* Must have prev and next pointers set before calling create_request
* hook.
*/
/* Inherit the rest of the protocol info... */
/*
* XXX: hmm. This is because mod_setenvif and mod_unique_id really need
* to do their thing on internal redirects as well. Perhaps this is a
* misnamed function.
*/
return NULL;
}
return new;
}
/* XXX: Is this function is so bogus and fragile that we deep-6 it? */
{
/* We need to tell POOL_DEBUG that we're guaranteeing that rr->pool
* will exist as long as r->pool. Otherwise we run into troubles because
* some values in this request will be allocated in r->pool, and others in
* rr->pool.
*/
/* copy output headers from subrequest, but leave negotiation headers */
r->headers_out);
r->err_headers_out);
r->subprocess_env);
}
{
if (access_status == OK) {
return;
}
}
else {
}
}
/* This function is designed for things like actions or CGI scripts, when
* using AddHandler, and you want to preserve the content type across
* an internal redirect.
*/
{
int access_status;
if (r->handler)
if (access_status == OK) {
return;
}
}
else {
}
}
{
const char *method;
/*
* Get rid of any current settings if requested; not just the
* well-known methods but any extensions as well.
*/
if (reset) {
}
}
}
{
int method;
/*
* Get rid of any current settings if requested; not just the
* well-known methods but any extensions as well.
*/
if (reset) {
}
mask = 0;
}
}