http_protocol.h revision b5c963a560a55d08763229330dc661b16b726da0
f545d156561c08020a67f9640c51454c2df4fb57fabien/* Licensed to the Apache Software Foundation (ASF) under one or more
f545d156561c08020a67f9640c51454c2df4fb57fabien * contributor license agreements. See the NOTICE file distributed with
f545d156561c08020a67f9640c51454c2df4fb57fabien * this work for additional information regarding copyright ownership.
f545d156561c08020a67f9640c51454c2df4fb57fabien * The ASF licenses this file to You under the Apache License, Version 2.0
f545d156561c08020a67f9640c51454c2df4fb57fabien * (the "License"); you may not use this file except in compliance with
f545d156561c08020a67f9640c51454c2df4fb57fabien * the License. You may obtain a copy of the License at
f545d156561c08020a67f9640c51454c2df4fb57fabien *
f545d156561c08020a67f9640c51454c2df4fb57fabien * http://www.apache.org/licenses/LICENSE-2.0
f545d156561c08020a67f9640c51454c2df4fb57fabien *
f545d156561c08020a67f9640c51454c2df4fb57fabien * Unless required by applicable law or agreed to in writing, software
f545d156561c08020a67f9640c51454c2df4fb57fabien * distributed under the License is distributed on an "AS IS" BASIS,
f545d156561c08020a67f9640c51454c2df4fb57fabien * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
f545d156561c08020a67f9640c51454c2df4fb57fabien * See the License for the specific language governing permissions and
f545d156561c08020a67f9640c51454c2df4fb57fabien * limitations under the License.
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * @file http_protocol.h
f545d156561c08020a67f9640c51454c2df4fb57fabien * @brief HTTP protocol handling
f545d156561c08020a67f9640c51454c2df4fb57fabien *
f545d156561c08020a67f9640c51454c2df4fb57fabien * @defgroup APACHE_CORE_PROTO HTTP Protocol Handling
f545d156561c08020a67f9640c51454c2df4fb57fabien * @ingroup APACHE_CORE
f545d156561c08020a67f9640c51454c2df4fb57fabien * @{
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien#ifndef APACHE_HTTP_PROTOCOL_H
f545d156561c08020a67f9640c51454c2df4fb57fabien#define APACHE_HTTP_PROTOCOL_H
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien#include "httpd.h"
f545d156561c08020a67f9640c51454c2df4fb57fabien#include "apr_portable.h"
f545d156561c08020a67f9640c51454c2df4fb57fabien#include "apr_mmap.h"
f545d156561c08020a67f9640c51454c2df4fb57fabien#include "apr_buckets.h"
f545d156561c08020a67f9640c51454c2df4fb57fabien#include "util_filter.h"
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien#ifdef __cplusplus
f545d156561c08020a67f9640c51454c2df4fb57fabienextern "C" {
f545d156561c08020a67f9640c51454c2df4fb57fabien#endif
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * This hook allows modules to insert filters for the current error response
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r the current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @ingroup hooks
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE_HOOK(void,insert_error_filter,(request_rec *r))
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/** This is an optimization. We keep a record of the filter_rec that
f545d156561c08020a67f9640c51454c2df4fb57fabien * stores the old_write filter, so that we can avoid strcmp's later.
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE_DATA extern ap_filter_rec_t *ap_old_write_func;
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/*
f545d156561c08020a67f9640c51454c2df4fb57fabien * Prototypes for routines which either talk directly back to the user,
f545d156561c08020a67f9640c51454c2df4fb57fabien * or control the ones that eventually do.
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Read a request and fill in the fields.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param c The current connection
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return The new request_rec
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienrequest_rec *ap_read_request(conn_rec *c);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Read the mime-encoded headers.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(void) ap_get_mime_headers(request_rec *r);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Optimized version of ap_get_mime_headers() that requires a
f545d156561c08020a67f9640c51454c2df4fb57fabien * temporary brigade to work with
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param bb temp brigade
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(void) ap_get_mime_headers_core(request_rec *r,
f545d156561c08020a67f9640c51454c2df4fb57fabien apr_bucket_brigade *bb);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/* Finish up stuff after a request */
dd1e093863f13a4a3fbf09497cbd5cb039fadd76ylavic
dd1e093863f13a4a3fbf09497cbd5cb039fadd76ylavic/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Called at completion of sending the response. It sends the terminating
f545d156561c08020a67f9640c51454c2df4fb57fabien * protocol information.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(void) ap_finalize_request_protocol(request_rec *r);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Send error back to client.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param recursive_error last arg indicates error status in case we get
f545d156561c08020a67f9640c51454c2df4fb57fabien * an error in the process of trying to deal with an ErrorDocument
f545d156561c08020a67f9640c51454c2df4fb57fabien * to handle some other error. In that case, we print the default
f545d156561c08020a67f9640c51454c2df4fb57fabien * report for the first thing that went wrong, and more briefly report
f545d156561c08020a67f9640c51454c2df4fb57fabien * on the problem with the ErrorDocument.
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(void) ap_send_error_response(request_rec *r, int recursive_error);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/* Set last modified header line from the lastmod date of the associated file.
f545d156561c08020a67f9640c51454c2df4fb57fabien * Also, set content length.
f545d156561c08020a67f9640c51454c2df4fb57fabien *
f545d156561c08020a67f9640c51454c2df4fb57fabien * May return an error status, typically HTTP_NOT_MODIFIED (that when the
f545d156561c08020a67f9640c51454c2df4fb57fabien * permit_cache argument is set to one).
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Set the content length for this request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param length The new content length
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(void) ap_set_content_length(request_rec *r, apr_off_t length);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
a1331861fe0e3903507db8afef5697f0f93bb9ecjailletc * Set the keepalive status for this request
a1331861fe0e3903507db8afef5697f0f93bb9ecjailletc * @param r The current request
a1331861fe0e3903507db8afef5697f0f93bb9ecjailletc * @return 1 if keepalive can be set, 0 otherwise
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(int) ap_set_keepalive(request_rec *r);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Return the latest rational time from a request/mtime pair. Mtime is
f545d156561c08020a67f9640c51454c2df4fb57fabien * returned unless it's in the future, in which case we return the current time.
a1331861fe0e3903507db8afef5697f0f93bb9ecjailletc * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param mtime The last modified time
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return the latest rational time.
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(apr_time_t) ap_rationalize_mtime(request_rec *r, apr_time_t mtime);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Build the content-type that should be sent to the client from the
f545d156561c08020a67f9640c51454c2df4fb57fabien * content-type specified. The following rules are followed:
f545d156561c08020a67f9640c51454c2df4fb57fabien * - if type is NULL or "", return NULL (do not set content-type).
f545d156561c08020a67f9640c51454c2df4fb57fabien * - if charset adding is disabled, stop processing and return type.
f545d156561c08020a67f9640c51454c2df4fb57fabien * - then, if there are no parameters on type, add the default charset
f545d156561c08020a67f9640c51454c2df4fb57fabien * - return type
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param type The content type
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return The content-type
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(const char *) ap_make_content_type(request_rec *r,
f545d156561c08020a67f9640c51454c2df4fb57fabien const char *type);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Precompile metadata structures used by ap_make_content_type()
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param pool The pool to use for allocations
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(void) ap_setup_make_content_type(apr_pool_t *pool);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Construct an entity tag from the resource information. If it's a real
f545d156561c08020a67f9640c51454c2df4fb57fabien * file, build in some of the file characteristics.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param force_weak Force the entity tag to be weak - it could be modified
f545d156561c08020a67f9640c51454c2df4fb57fabien * again in as short an interval.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return The entity tag
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(char *) ap_make_etag(request_rec *r, int force_weak);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Set the E-tag outgoing header
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
a1331861fe0e3903507db8afef5697f0f93bb9ecjailletc */
a1331861fe0e3903507db8afef5697f0f93bb9ecjailletcAP_DECLARE(void) ap_set_etag(request_rec *r);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Set the last modified time for the file being sent
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(void) ap_set_last_modified(request_rec *r);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Implements condition GET rules for HTTP/1.1 specification. This function
f545d156561c08020a67f9640c51454c2df4fb57fabien * inspects the client headers and determines if the response fulfills
f545d156561c08020a67f9640c51454c2df4fb57fabien * the requirements specified.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return OK if the response fulfills the condition GET rules, some
f545d156561c08020a67f9640c51454c2df4fb57fabien * other status code otherwise
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(int) ap_meets_conditions(request_rec *r);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/* Other ways to send stuff at the client. All of these keep track
f545d156561c08020a67f9640c51454c2df4fb57fabien * of bytes_sent automatically. This indirection is intended to make
a1331861fe0e3903507db8afef5697f0f93bb9ecjailletc * it a little more painless to slide things like HTTP-NG packetization
f545d156561c08020a67f9640c51454c2df4fb57fabien * underneath the main body of the code later. In the meantime, it lets
f545d156561c08020a67f9640c51454c2df4fb57fabien * us centralize a bit of accounting (bytes_sent).
f545d156561c08020a67f9640c51454c2df4fb57fabien *
f545d156561c08020a67f9640c51454c2df4fb57fabien * These also return the number of bytes written by the call.
f545d156561c08020a67f9640c51454c2df4fb57fabien * They should only be called with a timeout registered, for obvious reaasons.
f545d156561c08020a67f9640c51454c2df4fb57fabien * (Ditto the send_header stuff).
a1331861fe0e3903507db8afef5697f0f93bb9ecjailletc */
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Send an entire file to the client, using sendfile if supported by the
f545d156561c08020a67f9640c51454c2df4fb57fabien * current platform
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param fd The file to send.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param offset Offset into the file to start sending.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param length Amount of data to send
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param nbytes Amount of data actually sent
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(apr_status_t) ap_send_fd(apr_file_t *fd, request_rec *r, apr_off_t offset,
f545d156561c08020a67f9640c51454c2df4fb57fabien apr_size_t length, apr_size_t *nbytes);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien#if APR_HAS_MMAP
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Send an MMAP'ed file to the client
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param mm The MMAP'ed file to send
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param offset The offset into the MMAP to start sending
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param length The amount of data to send
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return The number of bytes sent
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(size_t) ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset,
f545d156561c08020a67f9640c51454c2df4fb57fabien size_t length);
f545d156561c08020a67f9640c51454c2df4fb57fabien#endif
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Register a new request method, and return the offset that will be
f545d156561c08020a67f9640c51454c2df4fb57fabien * associated with that method.
f545d156561c08020a67f9640c51454c2df4fb57fabien *
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param p The pool to create registered method numbers from.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param methname The name of the new method to register.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return Ab int value representing an offset into a bitmask.
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(int) ap_method_register(apr_pool_t *p, const char *methname);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Initialize the method_registry and allocate memory for it.
f545d156561c08020a67f9640c51454c2df4fb57fabien *
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param p Pool to allocate memory for the registry from.
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(void) ap_method_registry_init(apr_pool_t *p);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * This is a convenience macro to ease with checking a mask
f545d156561c08020a67f9640c51454c2df4fb57fabien * against a method name.
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabien#define AP_METHOD_CHECK_ALLOWED(mask, methname) \
f545d156561c08020a67f9640c51454c2df4fb57fabien ((mask) & (AP_METHOD_BIT << ap_method_number_of((methname))))
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Create a new method list with the specified number of preallocated
f545d156561c08020a67f9640c51454c2df4fb57fabien * slots for extension methods.
f545d156561c08020a67f9640c51454c2df4fb57fabien *
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param p Pointer to a pool in which the structure should be
f545d156561c08020a67f9640c51454c2df4fb57fabien * allocated.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param nelts Number of preallocated extension slots
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return Pointer to the newly created structure.
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(ap_method_list_t *) ap_make_method_list(apr_pool_t *p, int nelts);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
a1331861fe0e3903507db8afef5697f0f93bb9ecjailletc * Copy a method list
f545d156561c08020a67f9640c51454c2df4fb57fabien *
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param dest List to copy to
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param src List to copy from
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(void) ap_copy_method_list(ap_method_list_t *dest,
f545d156561c08020a67f9640c51454c2df4fb57fabien ap_method_list_t *src);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Search for an HTTP method name in an ap_method_list_t structure, and
f545d156561c08020a67f9640c51454c2df4fb57fabien * return true if found.
f545d156561c08020a67f9640c51454c2df4fb57fabien *
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param method String containing the name of the method to check.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param l Pointer to a method list, such as r->allowed_methods.
a1331861fe0e3903507db8afef5697f0f93bb9ecjailletc * @return 1 if method is in the list, otherwise 0
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(int) ap_method_in_list(ap_method_list_t *l, const char *method);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Add an HTTP method name to an ap_method_list_t structure if it isn't
f545d156561c08020a67f9640c51454c2df4fb57fabien * already listed.
f545d156561c08020a67f9640c51454c2df4fb57fabien *
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param method String containing the name of the method to check.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param l Pointer to a method list, such as r->allowed_methods.
a1331861fe0e3903507db8afef5697f0f93bb9ecjailletc * @return None.
a1331861fe0e3903507db8afef5697f0f93bb9ecjailletc */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(void) ap_method_list_add(ap_method_list_t *l, const char *method);
a1331861fe0e3903507db8afef5697f0f93bb9ecjailletc
a1331861fe0e3903507db8afef5697f0f93bb9ecjailletc/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Remove an HTTP method name from an ap_method_list_t structure.
f545d156561c08020a67f9640c51454c2df4fb57fabien *
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param l Pointer to a method list, such as r->allowed_methods.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param method String containing the name of the method to remove.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return None.
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(void) ap_method_list_remove(ap_method_list_t *l,
f545d156561c08020a67f9640c51454c2df4fb57fabien const char *method);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Reset a method list to be completely empty.
f545d156561c08020a67f9640c51454c2df4fb57fabien *
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param l Pointer to a method list, such as r->allowed_methods.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return None.
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(void) ap_clear_method_list(ap_method_list_t *l);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Set the content type for this request (r->content_type).
a1331861fe0e3903507db8afef5697f0f93bb9ecjailletc * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param ct The new content type
f545d156561c08020a67f9640c51454c2df4fb57fabien * @warning This function must be called to set r->content_type in order
f545d156561c08020a67f9640c51454c2df4fb57fabien * for the AddOutputFilterByType directive to work correctly.
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(void) ap_set_content_type(request_rec *r, const char *ct);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/* Hmmm... could macrofy these for now, and maybe forever, though the
f545d156561c08020a67f9640c51454c2df4fb57fabien * definitions of the macros would get a whole lot hairier.
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Output one character for this request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param c the character to output
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r the current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return The number of bytes sent
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(int) ap_rputc(int c, request_rec *r);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Write a buffer for the current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param buf The buffer to write
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param nbyte The number of bytes to send from the buffer
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return The number of bytes sent
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Output a string for the current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param str The string to output
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return The number of bytes sent
f545d156561c08020a67f9640c51454c2df4fb57fabien * @note ap_rputs may be implemented as macro or inline function
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienstatic inline int ap_rputs(const char *str, request_rec *r)
f545d156561c08020a67f9640c51454c2df4fb57fabien{
f545d156561c08020a67f9640c51454c2df4fb57fabien return ap_rwrite(str, strlen(str), r);
f545d156561c08020a67f9640c51454c2df4fb57fabien}
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Write an unspecified number of strings to the request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param ... The strings to write
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return The number of bytes sent
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE_NONSTD(int) ap_rvputs(request_rec *r,...);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Output data to the client in a printf format
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param fmt The format string
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param vlist The arguments to use to fill out the format string
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return The number of bytes sent
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(int) ap_vrprintf(request_rec *r, const char *fmt, va_list vlist);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Output data to the client in a printf format
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param fmt The format string
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param ... The arguments to use to fill out the format string
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return The number of bytes sent
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE_NONSTD(int) ap_rprintf(request_rec *r, const char *fmt,...)
f545d156561c08020a67f9640c51454c2df4fb57fabien __attribute__((format(printf,2,3)));
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Flush all of the data for the current request to the client
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return The number of bytes sent
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(int) ap_rflush(request_rec *r);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Index used in custom_responses array for a specific error code
f545d156561c08020a67f9640c51454c2df4fb57fabien * (only use outside protocol.c is in getting them configured).
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param status HTTP status code
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return The index of the response
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(int) ap_index_of_response(int status);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Return the Status-Line for a given status code (excluding the
f545d156561c08020a67f9640c51454c2df4fb57fabien * HTTP-Version field). If an invalid or unknown status code is
f545d156561c08020a67f9640c51454c2df4fb57fabien * passed, "500 Internal Server Error" will be returned.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param status The HTTP status code
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return The Status-Line
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(const char *) ap_get_status_line(int status);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/* Reading a block of data from the client connection (e.g., POST arg) */
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Setup the client to allow Apache to read the request body.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param read_policy How the server should interpret a chunked
f545d156561c08020a67f9640c51454c2df4fb57fabien * transfer-encoding. One of: <pre>
f545d156561c08020a67f9640c51454c2df4fb57fabien * REQUEST_NO_BODY Send 413 error if message has any body
f545d156561c08020a67f9640c51454c2df4fb57fabien * REQUEST_CHUNKED_ERROR Send 411 error if body without Content-Length
f545d156561c08020a67f9640c51454c2df4fb57fabien * REQUEST_CHUNKED_DECHUNK If chunked, remove the chunks for me.
f545d156561c08020a67f9640c51454c2df4fb57fabien * </pre>
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return either OK or an error code
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(int) ap_setup_client_block(request_rec *r, int read_policy);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Determine if the client has sent any data. This also sends a
f545d156561c08020a67f9640c51454c2df4fb57fabien * 100 Continue response to HTTP/1.1 clients, so modules should not be called
f545d156561c08020a67f9640c51454c2df4fb57fabien * until the module is ready to read content.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @warning Never call this function more than once.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return 0 if there is no message to read, 1 otherwise
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(int) ap_should_client_block(request_rec *r);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Call this in a loop. It will put data into a buffer and return the length
f545d156561c08020a67f9640c51454c2df4fb57fabien * of the input block
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param buffer The buffer in which to store the data
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param bufsiz The size of the buffer
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return Number of bytes inserted into the buffer. When done reading, 0
f545d156561c08020a67f9640c51454c2df4fb57fabien * if EOF, or -1 if there was an error
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer, apr_size_t bufsiz);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * In HTTP/1.1, any method can have a body. However, most GET handlers
f545d156561c08020a67f9640c51454c2df4fb57fabien * wouldn't know what to do with a request body if they received one.
f545d156561c08020a67f9640c51454c2df4fb57fabien * This helper routine tests for and reads any message body in the request,
f545d156561c08020a67f9640c51454c2df4fb57fabien * simply discarding whatever it receives. We need to do this because
f545d156561c08020a67f9640c51454c2df4fb57fabien * failing to read the request body would cause it to be interpreted
f545d156561c08020a67f9640c51454c2df4fb57fabien * as the next request on a persistent connection.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return error status if request is malformed, OK otherwise
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(int) ap_discard_request_body(request_rec *r);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Setup the output headers so that the client knows how to authenticate
f545d156561c08020a67f9640c51454c2df4fb57fabien * itself the next time, if an authentication request failed.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(void) ap_note_auth_failure(request_rec *r);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * @deprecated @see ap_note_auth_failure
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(void) ap_note_basic_auth_failure(request_rec *r);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * @deprecated @see ap_note_auth_failure
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(void) ap_note_digest_auth_failure(request_rec *r);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * This hook allows modules to add support for a specific auth type to
f545d156561c08020a67f9640c51454c2df4fb57fabien * ap_note_auth_failure
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r the current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param auth_type the configured auth_type
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return OK, DECLINED
f545d156561c08020a67f9640c51454c2df4fb57fabien */
41d495a8492878e8fae61cb0b2645cb154802728jailletcAP_DECLARE_HOOK(int, note_auth_failure, (request_rec *r, const char *auth_type))
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Get the password from the request headers
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param pw The password as set in the headers
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return 0 (OK) if it set the 'pw' argument (and assured
f545d156561c08020a67f9640c51454c2df4fb57fabien * a correct value in r->user); otherwise it returns
f545d156561c08020a67f9640c51454c2df4fb57fabien * an error code, either HTTP_INTERNAL_SERVER_ERROR if things are
f545d156561c08020a67f9640c51454c2df4fb57fabien * really confused, HTTP_UNAUTHORIZED if no authentication at all
f545d156561c08020a67f9640c51454c2df4fb57fabien * seemed to be in use, or DECLINED if there was authentication but
f545d156561c08020a67f9640c51454c2df4fb57fabien * it wasn't Basic (in which case, the caller should presumably
f545d156561c08020a67f9640c51454c2df4fb57fabien * decline as well).
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(int) ap_get_basic_auth_pw(request_rec *r, const char **pw);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * parse_uri: break apart the uri
f545d156561c08020a67f9640c51454c2df4fb57fabien * @warning Side Effects:
f545d156561c08020a67f9640c51454c2df4fb57fabien * @li sets r->args to rest after '?' (or NULL if no '?')
f545d156561c08020a67f9640c51454c2df4fb57fabien * @li sets r->uri to request uri (without r->args part)
f545d156561c08020a67f9640c51454c2df4fb57fabien * @li sets r->hostname (if not set already) from request (scheme://host:port)
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param uri The uri to break apart
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_CORE_DECLARE(void) ap_parse_uri(request_rec *r, const char *uri);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Get the next line of input for the request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param s The buffer into which to read the line
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param n The size of the buffer
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param fold Whether to merge continuation lines
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return The length of the line, if successful
f545d156561c08020a67f9640c51454c2df4fb57fabien * n, if the line is too big to fit in the buffer
f545d156561c08020a67f9640c51454c2df4fb57fabien * -1 for miscellaneous errors
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(int) ap_getline(char *s, int n, request_rec *r, int fold);
a1331861fe0e3903507db8afef5697f0f93bb9ecjailletc
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Get the next line of input for the request
f545d156561c08020a67f9640c51454c2df4fb57fabien *
f545d156561c08020a67f9640c51454c2df4fb57fabien * Note: on ASCII boxes, ap_rgetline is a macro which simply calls
f545d156561c08020a67f9640c51454c2df4fb57fabien * ap_rgetline_core to get the line of input.
f545d156561c08020a67f9640c51454c2df4fb57fabien *
f545d156561c08020a67f9640c51454c2df4fb57fabien * on EBCDIC boxes, ap_rgetline is a wrapper function which
f545d156561c08020a67f9640c51454c2df4fb57fabien * translates ASCII protocol lines to the local EBCDIC code page
f545d156561c08020a67f9640c51454c2df4fb57fabien * after getting the line of input.
f545d156561c08020a67f9640c51454c2df4fb57fabien *
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param s Pointer to the pointer to the buffer into which the line
f545d156561c08020a67f9640c51454c2df4fb57fabien * should be read; if *s==NULL, a buffer of the necessary size
f545d156561c08020a67f9640c51454c2df4fb57fabien * to hold the data will be allocated from the request pool
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param n The size of the buffer
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param read The length of the line.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param fold Whether to merge continuation lines
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param bb Working brigade to use when reading buckets
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return APR_SUCCESS, if successful
a1331861fe0e3903507db8afef5697f0f93bb9ecjailletc * APR_ENOSPC, if the line is too big to fit in the buffer
f545d156561c08020a67f9640c51454c2df4fb57fabien * Other errors where appropriate
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabien#if APR_CHARSET_EBCDIC
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(apr_status_t) ap_rgetline(char **s, apr_size_t n,
f545d156561c08020a67f9640c51454c2df4fb57fabien apr_size_t *read,
f545d156561c08020a67f9640c51454c2df4fb57fabien request_rec *r, int fold,
f545d156561c08020a67f9640c51454c2df4fb57fabien apr_bucket_brigade *bb);
f545d156561c08020a67f9640c51454c2df4fb57fabien#else /* ASCII box */
f545d156561c08020a67f9640c51454c2df4fb57fabien#define ap_rgetline(s, n, read, r, fold, bb) \
f545d156561c08020a67f9640c51454c2df4fb57fabien ap_rgetline_core((s), (n), (read), (r), (fold), (bb))
f545d156561c08020a67f9640c51454c2df4fb57fabien#endif
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/** @see ap_rgetline */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n,
f545d156561c08020a67f9640c51454c2df4fb57fabien apr_size_t *read,
f545d156561c08020a67f9640c51454c2df4fb57fabien request_rec *r, int fold,
f545d156561c08020a67f9640c51454c2df4fb57fabien apr_bucket_brigade *bb);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Get the method number associated with the given string, assumed to
f545d156561c08020a67f9640c51454c2df4fb57fabien * contain an HTTP method. Returns M_INVALID if not recognized.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param method A string containing a valid HTTP method
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return The method number
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(int) ap_method_number_of(const char *method);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Get the method name associated with the given internal method
f545d156561c08020a67f9640c51454c2df4fb57fabien * number. Returns NULL if not recognized.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param p A pool to use for temporary allocations.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param methnum An integer value corresponding to an internal method number
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return The name corresponding to the method number
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(const char *) ap_method_name_of(apr_pool_t *p, int methnum);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/* Hooks */
f545d156561c08020a67f9640c51454c2df4fb57fabien/*
f545d156561c08020a67f9640c51454c2df4fb57fabien * pre_read_request --- run right before read_request_line(),
f545d156561c08020a67f9640c51454c2df4fb57fabien * and not run during any subrequests.
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * This hook allows modules to affect the request or connection immediately before
f545d156561c08020a67f9640c51454c2df4fb57fabien * the request has been read, and before any other phases have been processes.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request of the soon-to-be-read request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param c The connection
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return None/void
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE_HOOK(void,pre_read_request,(request_rec *r, conn_rec *c))
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/*
f545d156561c08020a67f9640c51454c2df4fb57fabien * post_read_request --- run right after read_request or internal_redirect,
f545d156561c08020a67f9640c51454c2df4fb57fabien * and not run during any subrequests.
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * This hook allows modules to affect the request immediately after the request
f545d156561c08020a67f9640c51454c2df4fb57fabien * has been read, and before any other phases have been processes. This allows
f545d156561c08020a67f9640c51454c2df4fb57fabien * modules to make decisions based upon the input header fields
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return OK or DECLINED
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE_HOOK(int,post_read_request,(request_rec *r))
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * This hook allows modules to perform any module-specific logging activities
f545d156561c08020a67f9640c51454c2df4fb57fabien * over and above the normal server things.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return OK, DECLINED, or HTTP_...
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE_HOOK(int,log_transaction,(request_rec *r))
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * This hook allows modules to retrieve the http scheme for a request. This
f545d156561c08020a67f9640c51454c2df4fb57fabien * allows Apache modules to easily extend the schemes that Apache understands
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return The http scheme from the request
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE_HOOK(const char *,http_scheme,(const request_rec *r))
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Return the default port from the current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The current request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return The current port
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE_HOOK(apr_port_t,default_port,(const request_rec *r))
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/** @see ap_bucket_type_error */
f545d156561c08020a67f9640c51454c2df4fb57fabientypedef struct ap_bucket_error ap_bucket_error;
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * @struct ap_bucket_error
f545d156561c08020a67f9640c51454c2df4fb57fabien * @brief A bucket referring to an HTTP error
f545d156561c08020a67f9640c51454c2df4fb57fabien *
f545d156561c08020a67f9640c51454c2df4fb57fabien * This bucket can be passed down the filter stack to indicate that an
f545d156561c08020a67f9640c51454c2df4fb57fabien * HTTP error occurred while running a filter. In order for this bucket
f545d156561c08020a67f9640c51454c2df4fb57fabien * to be used successfully, it MUST be sent as the first bucket in the
f545d156561c08020a67f9640c51454c2df4fb57fabien * first brigade to be sent from a given filter.
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienstruct ap_bucket_error {
f545d156561c08020a67f9640c51454c2df4fb57fabien /** Number of buckets using this memory */
f545d156561c08020a67f9640c51454c2df4fb57fabien apr_bucket_refcount refcount;
f545d156561c08020a67f9640c51454c2df4fb57fabien /** The error code */
f545d156561c08020a67f9640c51454c2df4fb57fabien int status;
f545d156561c08020a67f9640c51454c2df4fb57fabien /** The error string */
f545d156561c08020a67f9640c51454c2df4fb57fabien const char *data;
f545d156561c08020a67f9640c51454c2df4fb57fabien};
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/** @see ap_bucket_type_error */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE_DATA extern const apr_bucket_type_t ap_bucket_type_error;
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Determine if a bucket is an error bucket
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param e The bucket to inspect
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return true or false
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabien#define AP_BUCKET_IS_ERROR(e) (e->type == &ap_bucket_type_error)
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Make the bucket passed in an error bucket
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param b The bucket to make into an error bucket
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param error The HTTP error code to put in the bucket.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param buf An optional error string to put in the bucket.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param p A pool to allocate out of.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return The new bucket, or NULL if allocation failed
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(apr_bucket *) ap_bucket_error_make(apr_bucket *b, int error,
f545d156561c08020a67f9640c51454c2df4fb57fabien const char *buf, apr_pool_t *p);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Create a bucket referring to an HTTP error.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param error The HTTP error code to put in the bucket.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param buf An optional error string to put in the bucket.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param p A pool to allocate the error string out of.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param list The bucket allocator from which to allocate the bucket
f545d156561c08020a67f9640c51454c2df4fb57fabien * @return The new bucket, or NULL if allocation failed
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(apr_bucket *) ap_bucket_error_create(int error, const char *buf,
f545d156561c08020a67f9640c51454c2df4fb57fabien apr_pool_t *p,
f545d156561c08020a67f9640c51454c2df4fb57fabien apr_bucket_alloc_t *list);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE_NONSTD(apr_status_t) ap_byterange_filter(ap_filter_t *f, apr_bucket_brigade *b);
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, apr_bucket_brigade *b);
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE_NONSTD(apr_status_t) ap_content_length_filter(ap_filter_t *,
f545d156561c08020a67f9640c51454c2df4fb57fabien apr_bucket_brigade *);
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE_NONSTD(apr_status_t) ap_old_write_filter(ap_filter_t *f, apr_bucket_brigade *b);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Sett up the protocol fields for subsidiary requests
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param rnew New Sub Request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r current request
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(void) ap_set_sub_req_protocol(request_rec *rnew, const request_rec *r);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * A wrapup function to keep the internal accounting straight.
f545d156561c08020a67f9640c51454c2df4fb57fabien * Indicates that there is no more content coming.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param sub_r Subrequest that is now compete
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(void) ap_finalize_sub_req_protocol(request_rec *sub_r);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien/**
f545d156561c08020a67f9640c51454c2df4fb57fabien * Send an interim (HTTP 1xx) response immediately.
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param r The request
f545d156561c08020a67f9640c51454c2df4fb57fabien * @param send_headers Whether to send&clear headers in r->headers_out
f545d156561c08020a67f9640c51454c2df4fb57fabien */
f545d156561c08020a67f9640c51454c2df4fb57fabienAP_DECLARE(void) ap_send_interim_response(request_rec *r, int send_headers);
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien#ifdef __cplusplus
f545d156561c08020a67f9640c51454c2df4fb57fabien}
f545d156561c08020a67f9640c51454c2df4fb57fabien#endif
f545d156561c08020a67f9640c51454c2df4fb57fabien
f545d156561c08020a67f9640c51454c2df4fb57fabien#endif /* !APACHE_HTTP_PROTOCOL_H */
f545d156561c08020a67f9640c51454c2df4fb57fabien/** @} */
f545d156561c08020a67f9640c51454c2df4fb57fabien