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