http_protocol.h revision ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dc
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder/* Copyright 2000-2004 Apache Software Foundation
e9458b1a7a19a63aa4c179f9ab20f4d50681c168Jens Elkner *
7895bc4f90d3ea250877c02a897f5dcca4590a89Christian Maeder * Licensed under the Apache License, Version 2.0 (the "License");
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * you may not use this file except in compliance with the License.
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu Prodescu * You may obtain a copy of the License at
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder *
3f69b6948966979163bdfe8331c38833d5d90ecdChristian Maeder * http://www.apache.org/licenses/LICENSE-2.0
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder *
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * Unless required by applicable law or agreed to in writing, software
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * distributed under the License is distributed on an "AS IS" BASIS,
e6d40133bc9f858308654afb1262b8b483ec5922Till Mossakowski * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * See the License for the specific language governing permissions and
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * limitations under the License.
8adae8b1eb0dd8562f0d1541b9ecb2fd80bda7e7Christian Maeder */
8adae8b1eb0dd8562f0d1541b9ecb2fd80bda7e7Christian Maeder
8adae8b1eb0dd8562f0d1541b9ecb2fd80bda7e7Christian Maeder#ifndef APACHE_HTTP_PROTOCOL_H
8adae8b1eb0dd8562f0d1541b9ecb2fd80bda7e7Christian Maeder#define APACHE_HTTP_PROTOCOL_H
8adae8b1eb0dd8562f0d1541b9ecb2fd80bda7e7Christian Maeder
ab0274ab68a174d3e92235b4c4ca865c03901583Christian Maeder#include "httpd.h"
8adae8b1eb0dd8562f0d1541b9ecb2fd80bda7e7Christian Maeder#include "apr_hooks.h"
9ba43c9323dc1a4bb1e684d87370b43468ab9096Christian Maeder#include "apr_portable.h"
cbe26e1cedf1e305b077afa82cb5f46850cdb8b1Christian Maeder#include "apr_mmap.h"
21095d13d876edd444df223f34d14efa85ba58c1Christian Maeder#include "apr_buckets.h"
b65890a7645b96eb0d5c334c81ba9dca86d556bfChristian Maeder#include "util_filter.h"
62d5dbbceb675837039e6bad0971c324cce96a21Mihai Codescu
62d5dbbceb675837039e6bad0971c324cce96a21Mihai Codescu#ifdef __cplusplus
7d6fdc539541f38639e20b45bba29e39bd201c3fChristian Maederextern "C" {
7d6fdc539541f38639e20b45bba29e39bd201c3fChristian Maeder#endif
3b5d1e9f95905d6595b3bb01b54499a37a3d82acChristian Maeder
941254a2daaf605bda18be25358f4e1322e94ec9Christian Maeder/**
434c11a96bc623ebd5b60781efabef319bb15b0eChristian Maeder * @package HTTP protocol handling
7d6fdc539541f38639e20b45bba29e39bd201c3fChristian Maeder */
7d6fdc539541f38639e20b45bba29e39bd201c3fChristian Maeder
7d6fdc539541f38639e20b45bba29e39bd201c3fChristian Maeder/**
0d72630889db51ffe7a0336cbb7fde5dbe415e9dEwaryst Schulz * This hook allows modules to insert filters for the current error response
7447e9fcbe38c1d04effa0df67f49240bd9963d6Liam O'Reilly * @param r the current request
0d72630889db51ffe7a0336cbb7fde5dbe415e9dEwaryst Schulz * @ingroup hooks
3b5d1e9f95905d6595b3bb01b54499a37a3d82acChristian Maeder */
ccd28c25c1aee73a195053e677eca17e20917d84Christian MaederAP_DECLARE_HOOK(void,insert_error_filter,(request_rec *r))
b2542911be8b16ffb988c3abe09ee63be98e119fChristian Maeder
8adae8b1eb0dd8562f0d1541b9ecb2fd80bda7e7Christian Maeder/* This is an optimization. We keep a record of the filter_rec that
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * stores the old_write filter, so that we can avoid strcmp's later.
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder */
f799084b320209cdd71a29e74fff1be054c1d342Christian MaederAP_DECLARE_DATA extern ap_filter_rec_t *ap_old_write_func;
3ab1e7a18f3fc3eb004464bc54b7df4483f1f060Christian Maeder
c438c79d00fc438f99627e612498744bdc0d0c89Christian Maeder/*
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * Prototypes for routines which either talk directly back to the user,
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * or control the ones that eventually do.
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder */
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder/**
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * Read a request and fill in the fields.
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * @param c The current connection
8c4c53f1d84490c7eac208905e92964c6508c1d6Christian Maeder * @return The new request_rec
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder */
1aee531e3fe5a94300ddc7933c1983a38a76316eChristian Maederrequest_rec *ap_read_request(conn_rec *c);
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang/**
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * Read the mime-encoded headers.
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * @param r The current request
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder */
ccd28c25c1aee73a195053e677eca17e20917d84Christian MaederAP_DECLARE(void) ap_get_mime_headers(request_rec *r);
8c4c53f1d84490c7eac208905e92964c6508c1d6Christian Maeder
c7f5076658d72ea340d7fd8a648908f961af682dChristian Maeder/**
c7f5076658d72ea340d7fd8a648908f961af682dChristian Maeder * Optimized version of ap_get_mime_headers() that requires a
c7f5076658d72ea340d7fd8a648908f961af682dChristian Maeder * temporary brigade to work with
9ba43c9323dc1a4bb1e684d87370b43468ab9096Christian Maeder * @param r The current request
c7f5076658d72ea340d7fd8a648908f961af682dChristian Maeder * @param bb temp brigade
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder */
1aee531e3fe5a94300ddc7933c1983a38a76316eChristian MaederAP_DECLARE(void) ap_get_mime_headers_core(request_rec *r,
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder apr_bucket_brigade *bb);
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder
c7f5076658d72ea340d7fd8a648908f961af682dChristian Maeder/* Finish up stuff after a request */
c7f5076658d72ea340d7fd8a648908f961af682dChristian Maeder
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang/**
c7f5076658d72ea340d7fd8a648908f961af682dChristian Maeder * Called at completion of sending the response. It sends the terminating
eab576044505ba1fbc64610323053490fbd9e82cChristian Maeder * protocol information.
eab576044505ba1fbc64610323053490fbd9e82cChristian Maeder * @param r The current request
c7f5076658d72ea340d7fd8a648908f961af682dChristian Maeder * @deffunc void ap_finalize_request_protocol(request_rec *r)
eab576044505ba1fbc64610323053490fbd9e82cChristian Maeder */
eab576044505ba1fbc64610323053490fbd9e82cChristian MaederAP_DECLARE(void) ap_finalize_request_protocol(request_rec *r);
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder
941254a2daaf605bda18be25358f4e1322e94ec9Christian Maeder/**
b65890a7645b96eb0d5c334c81ba9dca86d556bfChristian Maeder * Send error back to client.
941254a2daaf605bda18be25358f4e1322e94ec9Christian Maeder * @param r The current request
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * @param recursive_error last arg indicates error status in case we get
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * an error in the process of trying to deal with an ErrorDocument
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * to handle some other error. In that case, we print the default
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * report for the first thing that went wrong, and more briefly report
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * on the problem with the ErrorDocument.
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * @deffunc void ap_send_error_response(request_rec *r, int recursive_error)
842a6d146e8d1023c9cc54e9064ae93be2daf831Christian Maeder */
ccd28c25c1aee73a195053e677eca17e20917d84Christian MaederAP_DECLARE(void) ap_send_error_response(request_rec *r, int recursive_error);
842a6d146e8d1023c9cc54e9064ae93be2daf831Christian Maeder
a571b691ac0da91a895c33f250509622004dcf03Christian Maeder/* Set last modified header line from the lastmod date of the associated file.
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * Also, set content length.
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder *
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * May return an error status, typically HTTP_NOT_MODIFIED (that when the
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * permit_cache argument is set to one).
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder */
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder
4d4ec273e5cb1f17985c6edcf90a295a8b612cefChristian Maeder/**
4d4ec273e5cb1f17985c6edcf90a295a8b612cefChristian Maeder * Set the content length for this request
4d4ec273e5cb1f17985c6edcf90a295a8b612cefChristian Maeder * @param r The current request
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * @param length The new content length
b65890a7645b96eb0d5c334c81ba9dca86d556bfChristian Maeder * @deffunc void ap_set_content_length(request_rec *r, apr_off_t length)
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder */
4674b607529c8eab497240da6da1ef9ae786611cChristian MaederAP_DECLARE(void) ap_set_content_length(request_rec *r, apr_off_t length);
4674b607529c8eab497240da6da1ef9ae786611cChristian Maeder
a571b691ac0da91a895c33f250509622004dcf03Christian Maeder/**
842a6d146e8d1023c9cc54e9064ae93be2daf831Christian Maeder * Set the keepalive status for this request
a571b691ac0da91a895c33f250509622004dcf03Christian Maeder * @param r The current request
4674b607529c8eab497240da6da1ef9ae786611cChristian Maeder * @return 1 if keepalive can be set, 0 otherwise
842a6d146e8d1023c9cc54e9064ae93be2daf831Christian Maeder * @deffunc int ap_set_keepalive(request_rec *r)
eab576044505ba1fbc64610323053490fbd9e82cChristian Maeder */
ccd28c25c1aee73a195053e677eca17e20917d84Christian MaederAP_DECLARE(int) ap_set_keepalive(request_rec *r);
4674b607529c8eab497240da6da1ef9ae786611cChristian Maeder
842a6d146e8d1023c9cc54e9064ae93be2daf831Christian Maeder/**
4674b607529c8eab497240da6da1ef9ae786611cChristian Maeder * Return the latest rational time from a request/mtime pair. Mtime is
842a6d146e8d1023c9cc54e9064ae93be2daf831Christian Maeder * returned unless it's in the future, in which case we return the current time.
c7f5076658d72ea340d7fd8a648908f961af682dChristian Maeder * @param r The current request
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * @param mtime The last modified time
8c4c53f1d84490c7eac208905e92964c6508c1d6Christian Maeder * @return the latest rational time.
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * @deffunc apr_time_t ap_rationalize_mtime(request_rec *r, apr_time_t mtime)
b65890a7645b96eb0d5c334c81ba9dca86d556bfChristian Maeder */
fef03b64e3b1d7d3a8e098f62ef2e7687a433f09Christian MaederAP_DECLARE(apr_time_t) ap_rationalize_mtime(request_rec *r, apr_time_t mtime);
9aef2f9a1f6d7557bc31bf4f9db235f7f0d5170dChristian Maeder
fef03b64e3b1d7d3a8e098f62ef2e7687a433f09Christian Maeder/**
b65890a7645b96eb0d5c334c81ba9dca86d556bfChristian Maeder * Build the content-type that should be sent to the client from the
ade1f65c2bb98fbf45f8ef16bed4fa50802225a4Christian Maeder * content-type specified. The following rules are followed:
9aef2f9a1f6d7557bc31bf4f9db235f7f0d5170dChristian Maeder * - if type is NULL, type is set to ap_default_type(r)
264b794970b6f2bd437f14233f367f1067565728Jian Chun Wang * - if charset adding is disabled, stop processing and return type.
264b794970b6f2bd437f14233f367f1067565728Jian Chun Wang * - then, if there are no parameters on type, add the default charset
264b794970b6f2bd437f14233f367f1067565728Jian Chun Wang * - return type
264b794970b6f2bd437f14233f367f1067565728Jian Chun Wang * @param r The current request
b65890a7645b96eb0d5c334c81ba9dca86d556bfChristian Maeder * @return The content-type
57d9ffd4f0d821632c5dd116a5301c3305599b19Christian Maeder * @deffunc const char *ap_make_content_type(request_rec *r, const char *type);
66939c546b3eaf25eb34d1dc36c0c82943f85552Christian Maeder */
264b794970b6f2bd437f14233f367f1067565728Jian Chun WangAP_DECLARE(const char *) ap_make_content_type(request_rec *r,
264b794970b6f2bd437f14233f367f1067565728Jian Chun Wang const char *type);
eab576044505ba1fbc64610323053490fbd9e82cChristian Maeder
57d9ffd4f0d821632c5dd116a5301c3305599b19Christian Maeder#ifdef CORE_PRIVATE
264b794970b6f2bd437f14233f367f1067565728Jian Chun Wang/**
b65890a7645b96eb0d5c334c81ba9dca86d556bfChristian Maeder * Precompile metadata structures used by ap_make_content_type()
264b794970b6f2bd437f14233f367f1067565728Jian Chun Wang * @param r The pool to use for allocations
264b794970b6f2bd437f14233f367f1067565728Jian Chun Wang * @deffunc void ap_setup_make_content_type(apr_pool_t *pool)
b65890a7645b96eb0d5c334c81ba9dca86d556bfChristian Maeder */
8c4c53f1d84490c7eac208905e92964c6508c1d6Christian MaederAP_DECLARE(void) ap_setup_make_content_type(apr_pool_t *pool);
8519df804b37f95a2394a6cd5662da02efa3400bChristian Maeder#endif /* CORE_PRIVATE */
66939c546b3eaf25eb34d1dc36c0c82943f85552Christian Maeder
66939c546b3eaf25eb34d1dc36c0c82943f85552Christian Maeder/**
8519df804b37f95a2394a6cd5662da02efa3400bChristian Maeder * Construct an entity tag from the resource information. If it's a real
264b794970b6f2bd437f14233f367f1067565728Jian Chun Wang * file, build in some of the file characteristics.
264b794970b6f2bd437f14233f367f1067565728Jian Chun Wang * @param r The current request
eab576044505ba1fbc64610323053490fbd9e82cChristian Maeder * @param force_weak Force the entity tag to be weak - it could be modified
eab576044505ba1fbc64610323053490fbd9e82cChristian Maeder * again in as short an interval.
8519df804b37f95a2394a6cd5662da02efa3400bChristian Maeder * @return The entity tag
264b794970b6f2bd437f14233f367f1067565728Jian Chun Wang * @deffunc char *ap_make_etag(request_rec *r, int force_weak)
264b794970b6f2bd437f14233f367f1067565728Jian Chun Wang */
264b794970b6f2bd437f14233f367f1067565728Jian Chun WangAP_DECLARE(char *) ap_make_etag(request_rec *r, int force_weak);
264b794970b6f2bd437f14233f367f1067565728Jian Chun Wang
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder/**
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * Set the E-tag outgoing header
66939c546b3eaf25eb34d1dc36c0c82943f85552Christian Maeder * @param The current request
e92e93922166c81167de83cc7400403c5d9bb26cChristian Maeder * @deffunc void ap_set_etag(request_rec *r)
e92e93922166c81167de83cc7400403c5d9bb26cChristian Maeder */
66939c546b3eaf25eb34d1dc36c0c82943f85552Christian MaederAP_DECLARE(void) ap_set_etag(request_rec *r);
4674b607529c8eab497240da6da1ef9ae786611cChristian Maeder
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder/**
184449040f3b741bbb6a2e881415b30d624e2c63Christian Maeder * Set the last modified time for the file being sent
03a6bbff551286168d0b15dc53476c2ede4e60d0Christian Maeder * @param r The current request
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * @deffunc void ap_set_last_modified(request_rec *r)
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder */
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun WangAP_DECLARE(void) ap_set_last_modified(request_rec *r);
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder/**
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * Implements condition GET rules for HTTP/1.1 specification. This function
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * inspects the client headers and determines if the response fulfills
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * the requirements specified.
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * @param r The current request
0015e1756b734b34d4b550318c078f9a0c585611Christian Maeder * @return 1 if the response fulfills the condition GET rules, 0 otherwise
479da8506f391abe070ced2fb93c9759a280fa68Christian Maeder * @deffunc int ap_meets_conditions(request_rec *r)
e92e93922166c81167de83cc7400403c5d9bb26cChristian Maeder */
0015e1756b734b34d4b550318c078f9a0c585611Christian MaederAP_DECLARE(int) ap_meets_conditions(request_rec *r);
941254a2daaf605bda18be25358f4e1322e94ec9Christian Maeder
941254a2daaf605bda18be25358f4e1322e94ec9Christian Maeder/* Other ways to send stuff at the client. All of these keep track
941254a2daaf605bda18be25358f4e1322e94ec9Christian Maeder * of bytes_sent automatically. This indirection is intended to make
941254a2daaf605bda18be25358f4e1322e94ec9Christian Maeder * it a little more painless to slide things like HTTP-NG packetization
941254a2daaf605bda18be25358f4e1322e94ec9Christian Maeder * underneath the main body of the code later. In the meantime, it lets
941254a2daaf605bda18be25358f4e1322e94ec9Christian Maeder * us centralize a bit of accounting (bytes_sent).
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder *
0015e1756b734b34d4b550318c078f9a0c585611Christian Maeder * These also return the number of bytes written by the call.
0015e1756b734b34d4b550318c078f9a0c585611Christian Maeder * They should only be called with a timeout registered, for obvious reaasons.
6c4ee04931dded62728f3a9954b2799beed536e9Christian Maeder * (Ditto the send_header stuff).
6c4ee04931dded62728f3a9954b2799beed536e9Christian Maeder */
0015e1756b734b34d4b550318c078f9a0c585611Christian Maeder
434c11a96bc623ebd5b60781efabef319bb15b0eChristian Maeder/**
434c11a96bc623ebd5b60781efabef319bb15b0eChristian Maeder * Send an entire file to the client, using sendfile if supported by the
434c11a96bc623ebd5b60781efabef319bb15b0eChristian Maeder * current platform
0015e1756b734b34d4b550318c078f9a0c585611Christian Maeder * @param fd The file to send.
0015e1756b734b34d4b550318c078f9a0c585611Christian Maeder * @param r The current request
0015e1756b734b34d4b550318c078f9a0c585611Christian Maeder * @param offset Offset into the file to start sending.
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * @param length Amount of data to send
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * @param nbytes Amount of data actually sent
e92e93922166c81167de83cc7400403c5d9bb26cChristian Maeder * @deffunc apr_status_t ap_send_fd(apr_file_t *fd, request_rec *r, apr_off_t offset, apr_size_t length, apr_size_t *nbytes);
e92e93922166c81167de83cc7400403c5d9bb26cChristian Maeder */
479da8506f391abe070ced2fb93c9759a280fa68Christian MaederAP_DECLARE(apr_status_t) ap_send_fd(apr_file_t *fd, request_rec *r, apr_off_t offset,
b65890a7645b96eb0d5c334c81ba9dca86d556bfChristian Maeder apr_size_t length, apr_size_t *nbytes);
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder
0015e1756b734b34d4b550318c078f9a0c585611Christian Maeder#if APR_HAS_MMAP
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder/**
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * Send an MMAP'ed file to the client
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * @param mm The MMAP'ed file to send
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * @param r The current request
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * @param offset The offset into the MMAP to start sending
0015e1756b734b34d4b550318c078f9a0c585611Christian Maeder * @param length The amount of data to send
0015e1756b734b34d4b550318c078f9a0c585611Christian Maeder * @return The number of bytes sent
0015e1756b734b34d4b550318c078f9a0c585611Christian Maeder * @deffunc size_t ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset, size_t length)
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder */
0015e1756b734b34d4b550318c078f9a0c585611Christian MaederAP_DECLARE(size_t) ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset,
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder size_t length);
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder#endif
03a6bbff551286168d0b15dc53476c2ede4e60d0Christian Maeder
0015e1756b734b34d4b550318c078f9a0c585611Christian Maeder
51b1633dc0785a542da974fae21fa7d6622c934eChristian Maeder/**
434c11a96bc623ebd5b60781efabef319bb15b0eChristian Maeder * Register a new request method, and return the offset that will be
51b1633dc0785a542da974fae21fa7d6622c934eChristian Maeder * associated with that method.
51b1633dc0785a542da974fae21fa7d6622c934eChristian Maeder *
0015e1756b734b34d4b550318c078f9a0c585611Christian Maeder * @param p The pool to create registered method numbers from.
4bfb376555741367711b45323007f7375958530eChristian Maeder * @param methname The name of the new method to register.
0015e1756b734b34d4b550318c078f9a0c585611Christian Maeder * @return Ab int value representing an offset into a bitmask.
03a6bbff551286168d0b15dc53476c2ede4e60d0Christian Maeder */
03a6bbff551286168d0b15dc53476c2ede4e60d0Christian MaederAP_DECLARE(int) ap_method_register(apr_pool_t *p, const char *methname);
03a6bbff551286168d0b15dc53476c2ede4e60d0Christian Maeder
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder/**
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * Initialize the method_registry and allocate memory for it.
e92e93922166c81167de83cc7400403c5d9bb26cChristian Maeder *
b65890a7645b96eb0d5c334c81ba9dca86d556bfChristian Maeder * @param p Pool to allocate memory for the registry from.
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder */
c4a8059d0469a85bb58c28ac66729ac19d743d3cChristian MaederAP_DECLARE(void) ap_method_registry_init(apr_pool_t *p);
4bfb376555741367711b45323007f7375958530eChristian Maeder
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder/*
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * This is a convenience macro to ease with checking a mask
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * against a method name.
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder */
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang#define AP_METHOD_CHECK_ALLOWED(mask, methname) \
d06598e0c310f65ab552ca55626c2f7694ffd5e3Christian Maeder ((mask) & (AP_METHOD_BIT << ap_method_number_of((methname))))
d06598e0c310f65ab552ca55626c2f7694ffd5e3Christian Maeder
d06598e0c310f65ab552ca55626c2f7694ffd5e3Christian Maeder/**
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * Create a new method list with the specified number of preallocated
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * slots for extension methods.
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder *
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * @param p Pointer to a pool in which the structure should be
37354e3ed68875fb527338105a610df481f98cb0Christian Maeder * allocated.
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * @param nelts Number of preallocated extension slots
8c4c53f1d84490c7eac208905e92964c6508c1d6Christian Maeder * @return Pointer to the newly created structure.
50ed946595d60c06f773e73bb22b21f5cf1199caChristian Maeder * @deffunc ap_method_list_t ap_make_method_list(apr_pool_t *p, int nelts)
50ed946595d60c06f773e73bb22b21f5cf1199caChristian Maeder */
f799084b320209cdd71a29e74fff1be054c1d342Christian MaederAP_DECLARE(ap_method_list_t *) ap_make_method_list(apr_pool_t *p, int nelts);
f799084b320209cdd71a29e74fff1be054c1d342Christian MaederAP_DECLARE(void) ap_copy_method_list(ap_method_list_t *dest,
50ed946595d60c06f773e73bb22b21f5cf1199caChristian Maeder ap_method_list_t *src);
f799084b320209cdd71a29e74fff1be054c1d342Christian MaederAP_DECLARE_NONSTD(void) ap_method_list_do(int (*comp) (void *urec, const char *mname,
d06598e0c310f65ab552ca55626c2f7694ffd5e3Christian Maeder int mnum),
d06598e0c310f65ab552ca55626c2f7694ffd5e3Christian Maeder void *rec,
d06598e0c310f65ab552ca55626c2f7694ffd5e3Christian Maeder const ap_method_list_t *ml, ...);
f799084b320209cdd71a29e74fff1be054c1d342Christian MaederAP_DECLARE(void) ap_method_list_vdo(int (*comp) (void *urec, const char *mname,
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder int mnum),
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder void *rec, const ap_method_list_t *ml,
690e4ab8f298d9cff3803316cda70ad9b98e9c43Christian Maeder va_list vp);
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder/**
d06598e0c310f65ab552ca55626c2f7694ffd5e3Christian Maeder * Search for an HTTP method name in an ap_method_list_t structure, and
d06598e0c310f65ab552ca55626c2f7694ffd5e3Christian Maeder * return true if found.
d06598e0c310f65ab552ca55626c2f7694ffd5e3Christian Maeder *
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * @param method String containing the name of the method to check.
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * @param l Pointer to a method list, such as cmd->methods_limited.
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * @return 1 if method is in the list, otherwise 0
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * @deffunc int ap_method_in_list(const char *method, ap_method_list_t *l)
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder */
d06598e0c310f65ab552ca55626c2f7694ffd5e3Christian MaederAP_DECLARE(int) ap_method_in_list(ap_method_list_t *l, const char *method);
d06598e0c310f65ab552ca55626c2f7694ffd5e3Christian Maeder
d06598e0c310f65ab552ca55626c2f7694ffd5e3Christian Maeder/**
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * Add an HTTP method name to an ap_method_list_t structure if it isn't
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * already listed.
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder *
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * @param method String containing the name of the method to check.
8c4c53f1d84490c7eac208905e92964c6508c1d6Christian Maeder * @param l Pointer to a method list, such as cmd->methods_limited.
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * @return None.
d06598e0c310f65ab552ca55626c2f7694ffd5e3Christian Maeder * @deffunc void ap_method_in_list(ap_method_list_t *l, const char *method)
d06598e0c310f65ab552ca55626c2f7694ffd5e3Christian Maeder */
d06598e0c310f65ab552ca55626c2f7694ffd5e3Christian MaederAP_DECLARE(void) ap_method_list_add(ap_method_list_t *l, const char *method);
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang/**
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang * Remove an HTTP method name from an ap_method_list_t structure.
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang *
8c4c53f1d84490c7eac208905e92964c6508c1d6Christian Maeder * @param l Pointer to a method list, such as cmd->methods_limited.
9031d53c51b21d50ff4af9e8a365f0252401539fChristian Maeder * @param method String containing the name of the method to remove.
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang * @return None.
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang * @deffunc void ap_method_list_remove(ap_method_list_t *l, const char *method)
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang */
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun WangAP_DECLARE(void) ap_method_list_remove(ap_method_list_t *l,
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang const char *method);
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang/**
224e5f347275f5e9ada6cd976f195de2e77e41cbChristian Maeder * Reset a method list to be completely empty.
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang *
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang * @param l Pointer to a method list, such as cmd->methods_limited.
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang * @return None.
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang * @deffunc void ap_clear_method_list(ap_method_list_t *l)
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang */
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun WangAP_DECLARE(void) ap_clear_method_list(ap_method_list_t *l);
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang
224e5f347275f5e9ada6cd976f195de2e77e41cbChristian Maeder/**
b65890a7645b96eb0d5c334c81ba9dca86d556bfChristian Maeder * Set the content type for this request (r->content_type).
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang * @param r The current request
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang * @param ct The new content type
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang * @deffunc void ap_set_content_type(request_rec *r, const char* ct)
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang * @warning This function must be called to set r->content_type in order
8c4c53f1d84490c7eac208905e92964c6508c1d6Christian Maeder * for the AddOutputFilterByType directive to work correctly.
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang */
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun WangAP_DECLARE(void) ap_set_content_type(request_rec *r, const char *ct);
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang/* Hmmm... could macrofy these for now, and maybe forever, though the
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang * definitions of the macros would get a whole lot hairier.
b65890a7645b96eb0d5c334c81ba9dca86d556bfChristian Maeder */
ab0274ab68a174d3e92235b4c4ca865c03901583Christian Maeder
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang/**
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang * Output one character for this request
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang * @param c the character to output
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang * @param r the current request
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang * @return The number of bytes sent
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang * @deffunc int ap_rputc(int c, request_rec *r)
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang */
8c4c53f1d84490c7eac208905e92964c6508c1d6Christian MaederAP_DECLARE(int) ap_rputc(int c, request_rec *r);
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang/**
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang * Output a string for the current request
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang * @param str The string to output
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang * @param r The current request
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang * @return The number of bytes sent
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang * @deffunc int ap_rputs(const char *str, request_rec *r)
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang */
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun WangAP_DECLARE(int) ap_rputs(const char *str, request_rec *r);
8c4c53f1d84490c7eac208905e92964c6508c1d6Christian Maeder
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang/**
8c4c53f1d84490c7eac208905e92964c6508c1d6Christian Maeder * Write a buffer for the current request
9031d53c51b21d50ff4af9e8a365f0252401539fChristian Maeder * @param buf The buffer to write
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang * @param nbyte The number of bytes to send from the buffer
b65890a7645b96eb0d5c334c81ba9dca86d556bfChristian Maeder * @param r The current request
b65890a7645b96eb0d5c334c81ba9dca86d556bfChristian Maeder * @return The number of bytes sent
b65890a7645b96eb0d5c334c81ba9dca86d556bfChristian Maeder * @deffunc int ap_rwrite(const void *buf, int nbyte, request_rec *r)
b65890a7645b96eb0d5c334c81ba9dca86d556bfChristian Maeder */
b65890a7645b96eb0d5c334c81ba9dca86d556bfChristian MaederAP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r);
b65890a7645b96eb0d5c334c81ba9dca86d556bfChristian Maeder
b65890a7645b96eb0d5c334c81ba9dca86d556bfChristian Maeder/**
b65890a7645b96eb0d5c334c81ba9dca86d556bfChristian Maeder * Write an unspecified number of strings to the request
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * @param r The current request
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * @param ... The strings to write
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * @return The number of bytes sent
8c6b80162937eae0fe868c3b52bda6b50a153478Christian Maeder * @deffunc int ap_rvputs(request_rec *r, ...)
8c6b80162937eae0fe868c3b52bda6b50a153478Christian Maeder */
ccd28c25c1aee73a195053e677eca17e20917d84Christian MaederAP_DECLARE_NONSTD(int) ap_rvputs(request_rec *r,...);
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder/**
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * Output data to the client in a printf format
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * @param r The current request
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * @param fmt The format string
941254a2daaf605bda18be25358f4e1322e94ec9Christian Maeder * @param vlist The arguments to use to fill out the format string
84855a862ab77950c0c5059b1bba98cce0fb8ac3Christian Maeder * @return The number of bytes sent
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder * @deffunc int ap_vrprintf(request_rec *r, const char *fmt, va_list vlist)
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder */
94e112d16f89130a688db8b03ad3224903f5e97eChristian MaederAP_DECLARE(int) ap_vrprintf(request_rec *r, const char *fmt, va_list vlist);
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder/**
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder * Output data to the client in a printf format
aaae8c00d7868d09d8bf52acd7d93ac39eaff5b5Christian Maeder * @param r The current request
aaae8c00d7868d09d8bf52acd7d93ac39eaff5b5Christian Maeder * @param fmt The format string
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder * @param ... The arguments to use to fill out the format string
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder * @return The number of bytes sent
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder * @deffunc int ap_rprintf(request_rec *r, const char *fmt, ...)
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder */
1c53d99313dcdd6e1ba0022689aa97de1b064a67Christian MaederAP_DECLARE_NONSTD(int) ap_rprintf(request_rec *r, const char *fmt,...)
aaae8c00d7868d09d8bf52acd7d93ac39eaff5b5Christian Maeder __attribute__((format(printf,2,3)));
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder/**
aaae8c00d7868d09d8bf52acd7d93ac39eaff5b5Christian Maeder * Flush all of the data for the current request to the client
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder * @param r The current request
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder * @return The number of bytes sent
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder * @deffunc int ap_rflush(request_rec *r)
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder */
94e112d16f89130a688db8b03ad3224903f5e97eChristian MaederAP_DECLARE(int) ap_rflush(request_rec *r);
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder
1c53d99313dcdd6e1ba0022689aa97de1b064a67Christian Maeder/**
1c53d99313dcdd6e1ba0022689aa97de1b064a67Christian Maeder * Index used in custom_responses array for a specific error code
1c53d99313dcdd6e1ba0022689aa97de1b064a67Christian Maeder * (only use outside protocol.c is in getting them configured).
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder * @param status HTTP status code
1c53d99313dcdd6e1ba0022689aa97de1b064a67Christian Maeder * @return The index of the response
1c53d99313dcdd6e1ba0022689aa97de1b064a67Christian Maeder * @deffunc int ap_index_of_response(int status)
1c53d99313dcdd6e1ba0022689aa97de1b064a67Christian Maeder */
9031d53c51b21d50ff4af9e8a365f0252401539fChristian MaederAP_DECLARE(int) ap_index_of_response(int status);
c26ff5708c4a855bf9503b3001bcc19e5fd6286fChristian Maeder
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder/**
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder * Return the Status-Line for a given status code (excluding the
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder * HTTP-Version field). If an invalid or unknown status code is
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * passed, "500 Internal Server Error" will be returned.
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * @param status The HTTP status code
1c53d99313dcdd6e1ba0022689aa97de1b064a67Christian Maeder * @return The Status-Line
1c53d99313dcdd6e1ba0022689aa97de1b064a67Christian Maeder * @deffunc const char *ap_get_status_line(int status)
1c53d99313dcdd6e1ba0022689aa97de1b064a67Christian Maeder */
9ba43c9323dc1a4bb1e684d87370b43468ab9096Christian MaederAP_DECLARE(const char *) ap_get_status_line(int status);
f91429a7a295a517eda0dc70f590e44e3b71fa79Christian Maeder
9c06522a04b3f7bc904091ca1abaa2f956113c94Christian Maeder/* Reading a block of data from the client connection (e.g., POST arg) */
e92e93922166c81167de83cc7400403c5d9bb26cChristian Maeder
e92e93922166c81167de83cc7400403c5d9bb26cChristian Maeder/**
fed28ca105e1d669eef1781b1fb45d29cabd9e06Christian Maeder * Setup the client to allow Apache to read the request body.
e92e93922166c81167de83cc7400403c5d9bb26cChristian Maeder * @param r The current request
e92e93922166c81167de83cc7400403c5d9bb26cChristian Maeder * @param read_policy How the server should interpret a chunked
e92e93922166c81167de83cc7400403c5d9bb26cChristian Maeder * transfer-encoding. One of: <pre>
fed28ca105e1d669eef1781b1fb45d29cabd9e06Christian Maeder * REQUEST_NO_BODY Send 413 error if message has any body
e92e93922166c81167de83cc7400403c5d9bb26cChristian Maeder * REQUEST_CHUNKED_ERROR Send 411 error if body without Content-Length
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * REQUEST_CHUNKED_DECHUNK If chunked, remove the chunks for me.
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * </pre>
4674b607529c8eab497240da6da1ef9ae786611cChristian Maeder * @return either OK or an error code
1c53d99313dcdd6e1ba0022689aa97de1b064a67Christian Maeder * @deffunc int ap_setup_client_block(request_rec *r, int read_policy)
1c53d99313dcdd6e1ba0022689aa97de1b064a67Christian Maeder */
1c53d99313dcdd6e1ba0022689aa97de1b064a67Christian MaederAP_DECLARE(int) ap_setup_client_block(request_rec *r, int read_policy);
9031d53c51b21d50ff4af9e8a365f0252401539fChristian Maeder
b65890a7645b96eb0d5c334c81ba9dca86d556bfChristian Maeder/**
479da8506f391abe070ced2fb93c9759a280fa68Christian Maeder * Determine if the client has sent any data. This also sends a
b65890a7645b96eb0d5c334c81ba9dca86d556bfChristian Maeder * 100 Continue response to HTTP/1.1 clients, so modules should not be called
1c53d99313dcdd6e1ba0022689aa97de1b064a67Christian Maeder * until the module is ready to read content.
1c53d99313dcdd6e1ba0022689aa97de1b064a67Christian Maeder * @warning Never call this function more than once.
19c2d25601388b3d93c0784b944eddc81f8746b7Christian Maeder * @param r The current request
1c53d99313dcdd6e1ba0022689aa97de1b064a67Christian Maeder * @return 0 if there is no message to read, 1 otherwise
e92e93922166c81167de83cc7400403c5d9bb26cChristian Maeder * @deffunc int ap_should_client_block(request_rec *r)
1c53d99313dcdd6e1ba0022689aa97de1b064a67Christian Maeder */
1c53d99313dcdd6e1ba0022689aa97de1b064a67Christian MaederAP_DECLARE(int) ap_should_client_block(request_rec *r);
abcb1baa565c878598d732d0aa7724f474c9265cChristian Maeder
e92e93922166c81167de83cc7400403c5d9bb26cChristian Maeder/**
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * Call this in a loop. It will put data into a buffer and return the length
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * of the input block
9031d53c51b21d50ff4af9e8a365f0252401539fChristian Maeder * @param r The current request
9031d53c51b21d50ff4af9e8a365f0252401539fChristian Maeder * @param buffer The buffer in which to store the data
6e538f8086fb560f0b88d49581f0006d6323bdc0Christian Maeder * @param bufsiz The size of the buffer
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * @return Number of bytes inserted into the buffer. When done reading, 0
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * if EOF, or -1 if there was an error
f91429a7a295a517eda0dc70f590e44e3b71fa79Christian Maeder * @deffunc long ap_get_client_block(request_rec *r, char *buffer, apr_size_t bufsiz)
f91429a7a295a517eda0dc70f590e44e3b71fa79Christian Maeder */
fef03b64e3b1d7d3a8e098f62ef2e7687a433f09Christian MaederAP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer, apr_size_t bufsiz);
d8f14f4b0bc8d94b61a10c1d268ac33c8e43cca0Christian Maeder
4b960c5e777824979d5126bbde17f21d969a795bChristian Maeder/**
f91429a7a295a517eda0dc70f590e44e3b71fa79Christian Maeder * In HTTP/1.1, any method can have a body. However, most GET handlers
f91429a7a295a517eda0dc70f590e44e3b71fa79Christian Maeder * wouldn't know what to do with a request body if they received one.
f91429a7a295a517eda0dc70f590e44e3b71fa79Christian Maeder * This helper routine tests for and reads any message body in the request,
fef03b64e3b1d7d3a8e098f62ef2e7687a433f09Christian Maeder * simply discarding whatever it receives. We need to do this because
f91429a7a295a517eda0dc70f590e44e3b71fa79Christian Maeder * failing to read the request body would cause it to be interpreted
8adae8b1eb0dd8562f0d1541b9ecb2fd80bda7e7Christian Maeder * as the next request on a persistent connection.
8adae8b1eb0dd8562f0d1541b9ecb2fd80bda7e7Christian Maeder * @param r The current request
8adae8b1eb0dd8562f0d1541b9ecb2fd80bda7e7Christian Maeder * @return error status if request is malformed, OK otherwise
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * @deffunc int ap_discard_request_body(request_rec *r)
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder */
f799084b320209cdd71a29e74fff1be054c1d342Christian MaederAP_DECLARE(int) ap_discard_request_body(request_rec *r);
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder
d06598e0c310f65ab552ca55626c2f7694ffd5e3Christian Maeder/**
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * Setup the output headers so that the client knows how to authenticate
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * itself the next time, if an authentication request failed. This function
3ab1e7a18f3fc3eb004464bc54b7df4483f1f060Christian Maeder * works for both basic and digest authentication
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * @param r The current request
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * @deffunc void ap_note_auth_failure(request_rec *r)
d06598e0c310f65ab552ca55626c2f7694ffd5e3Christian Maeder */
ccd28c25c1aee73a195053e677eca17e20917d84Christian MaederAP_DECLARE(void) ap_note_auth_failure(request_rec *r);
2344f16936f5b31c9530d0cafb3838e9df3f3644Christian Maeder
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder/**
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * Setup the output headers so that the client knows how to authenticate
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder * itself the next time, if an authentication request failed. This function
aaae8c00d7868d09d8bf52acd7d93ac39eaff5b5Christian Maeder * works only for basic authentication
aaae8c00d7868d09d8bf52acd7d93ac39eaff5b5Christian Maeder * @param r The current request
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder * @deffunc void ap_note_basic_auth_failure(request_rec *r)
aaae8c00d7868d09d8bf52acd7d93ac39eaff5b5Christian Maeder */
2344f16936f5b31c9530d0cafb3838e9df3f3644Christian MaederAP_DECLARE(void) ap_note_basic_auth_failure(request_rec *r);
2344f16936f5b31c9530d0cafb3838e9df3f3644Christian Maeder
8adae8b1eb0dd8562f0d1541b9ecb2fd80bda7e7Christian Maeder/**
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * Setup the output headers so that the client knows how to authenticate
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder * itself the next time, if an authentication request failed. This function
aaae8c00d7868d09d8bf52acd7d93ac39eaff5b5Christian Maeder * works only for digest authentication
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * @param r The current request
8adae8b1eb0dd8562f0d1541b9ecb2fd80bda7e7Christian Maeder * @deffunc void ap_note_digest_auth_failure(request_rec *r)
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder */
f799084b320209cdd71a29e74fff1be054c1d342Christian MaederAP_DECLARE(void) ap_note_digest_auth_failure(request_rec *r);
8adae8b1eb0dd8562f0d1541b9ecb2fd80bda7e7Christian Maeder
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder/**
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder * Get the password from the request headers
abcb1baa565c878598d732d0aa7724f474c9265cChristian Maeder * @param r The current request
abcb1baa565c878598d732d0aa7724f474c9265cChristian Maeder * @param pw The password as set in the headers
aaae8c00d7868d09d8bf52acd7d93ac39eaff5b5Christian Maeder * @return 0 (OK) if it set the 'pw' argument (and assured
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * a correct value in r->user); otherwise it returns
aaae8c00d7868d09d8bf52acd7d93ac39eaff5b5Christian Maeder * an error code, either HTTP_INTERNAL_SERVER_ERROR if things are
690e4ab8f298d9cff3803316cda70ad9b98e9c43Christian Maeder * really confused, HTTP_UNAUTHORIZED if no authentication at all
690e4ab8f298d9cff3803316cda70ad9b98e9c43Christian Maeder * seemed to be in use, or DECLINED if there was authentication but
690e4ab8f298d9cff3803316cda70ad9b98e9c43Christian Maeder * it wasn't Basic (in which case, the caller should presumably
690e4ab8f298d9cff3803316cda70ad9b98e9c43Christian Maeder * decline as well).
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder * @deffunc int ap_get_basic_auth_pw(request_rec *r, const char **pw)
abcb1baa565c878598d732d0aa7724f474c9265cChristian Maeder */
94e112d16f89130a688db8b03ad3224903f5e97eChristian MaederAP_DECLARE(int) ap_get_basic_auth_pw(request_rec *r, const char **pw);
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder/**
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * parse_uri: break apart the uri
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * @warning Side Effects: <pre>
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder * - sets r->args to rest after '?' (or NULL if no '?')
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * - sets r->uri to request uri (without r->args part)
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * - sets r->hostname (if not set already) from request (scheme://host:port)
1c53d99313dcdd6e1ba0022689aa97de1b064a67Christian Maeder * </pre>
47d6bc7bc9a708427f96be8d805f712697ad3d9eChristian Maeder * @param r The current request
47d6bc7bc9a708427f96be8d805f712697ad3d9eChristian Maeder * @param uri The uri to break apart
47d6bc7bc9a708427f96be8d805f712697ad3d9eChristian Maeder * @deffunc void ap_parse_uri(request_rec *r, const char *uri)
47d6bc7bc9a708427f96be8d805f712697ad3d9eChristian Maeder */
47d6bc7bc9a708427f96be8d805f712697ad3d9eChristian MaederAP_CORE_DECLARE(void) ap_parse_uri(request_rec *r, const char *uri);
47d6bc7bc9a708427f96be8d805f712697ad3d9eChristian Maeder
47d6bc7bc9a708427f96be8d805f712697ad3d9eChristian Maeder/**
47d6bc7bc9a708427f96be8d805f712697ad3d9eChristian Maeder * Get the next line of input for the request
47d6bc7bc9a708427f96be8d805f712697ad3d9eChristian Maeder * @param s The buffer into which to read the line
47d6bc7bc9a708427f96be8d805f712697ad3d9eChristian Maeder * @param n The size of the buffer
47d6bc7bc9a708427f96be8d805f712697ad3d9eChristian Maeder * @param r The request
47d6bc7bc9a708427f96be8d805f712697ad3d9eChristian Maeder * @param fold Whether to merge continuation lines
1c53d99313dcdd6e1ba0022689aa97de1b064a67Christian Maeder * @return The length of the line, if successful
47d6bc7bc9a708427f96be8d805f712697ad3d9eChristian Maeder * n, if the line is too big to fit in the buffer
47d6bc7bc9a708427f96be8d805f712697ad3d9eChristian Maeder * -1 for miscellaneous errors
47d6bc7bc9a708427f96be8d805f712697ad3d9eChristian Maeder * @deffunc int ap_method_number_of(const char *method)
25d255de248ab96a6c750309192b7217061e186dChristian Maeder */
25d255de248ab96a6c750309192b7217061e186dChristian MaederAP_DECLARE(int) ap_getline(char *s, int n, request_rec *r, int fold);
47d6bc7bc9a708427f96be8d805f712697ad3d9eChristian Maeder
9ba43c9323dc1a4bb1e684d87370b43468ab9096Christian Maeder/**
9ba43c9323dc1a4bb1e684d87370b43468ab9096Christian Maeder * Get the next line of input for the request
9ba43c9323dc1a4bb1e684d87370b43468ab9096Christian Maeder *
9ba43c9323dc1a4bb1e684d87370b43468ab9096Christian Maeder * Note: on ASCII boxes, ap_rgetline is a macro which simply calls
47d6bc7bc9a708427f96be8d805f712697ad3d9eChristian Maeder * ap_rgetline_core to get the line of input.
9c06522a04b3f7bc904091ca1abaa2f956113c94Christian Maeder *
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * on EBCDIC boxes, ap_rgetline is a wrapper function which
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * translates ASCII protocol lines to the local EBCDIC code page
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * after getting the line of input.
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang *
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder * @param s Pointer to the pointer to the buffer into which the line
25d255de248ab96a6c750309192b7217061e186dChristian Maeder * should be read; if *s==NULL, a buffer of the necessary size
25d255de248ab96a6c750309192b7217061e186dChristian Maeder * to hold the data will be allocated from the request pool
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * @param n The size of the buffer
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * @param read The length of the line.
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * @param r The request
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder * @param fold Whether to merge continuation lines
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * @param bb Working brigade to use when reading buckets
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * @return APR_SUCCESS, if successful
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * APR_ENOSPC, if the line is too big to fit in the buffer
94e112d16f89130a688db8b03ad3224903f5e97eChristian Maeder * Other errors where appropriate
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang */
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang#if APR_CHARSET_EBCDIC
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun WangAP_DECLARE(apr_status_t) ap_rgetline(char **s, apr_size_t n,
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang apr_size_t *read,
9c06522a04b3f7bc904091ca1abaa2f956113c94Christian Maeder request_rec *r, int fold,
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder apr_bucket_brigade *bb);
9c06522a04b3f7bc904091ca1abaa2f956113c94Christian Maeder#else /* ASCII box */
9c06522a04b3f7bc904091ca1abaa2f956113c94Christian Maeder#define ap_rgetline(s, n, read, r, fold, bb) \
9c06522a04b3f7bc904091ca1abaa2f956113c94Christian Maeder ap_rgetline_core((s), (n), (read), (r), (fold), (bb))
9c06522a04b3f7bc904091ca1abaa2f956113c94Christian Maeder#endif
8c6b80162937eae0fe868c3b52bda6b50a153478Christian MaederAP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n,
9c06522a04b3f7bc904091ca1abaa2f956113c94Christian Maeder apr_size_t *read,
request_rec *r, int fold,
apr_bucket_brigade *bb);
/**
* Get the method number associated with the given string, assumed to
* contain an HTTP method. Returns M_INVALID if not recognized.
* @param method A string containing a valid HTTP method
* @return The method number
*/
AP_DECLARE(int) ap_method_number_of(const char *method);
/**
* Get the method name associated with the given internal method
* number. Returns NULL if not recognized.
* @param p A pool to use for temporary allocations.
* @param methnum An integer value corresponding to an internal method number
* @return The name corresponding to the method number
*/
AP_DECLARE(const char *) ap_method_name_of(apr_pool_t *p, int methnum);
/* Hooks */
/*
* post_read_request --- run right after read_request or internal_redirect,
* and not run during any subrequests.
*/
/**
* This hook allows modules to affect the request immediately after the request
* has been read, and before any other phases have been processes. This allows
* modules to make decisions based upon the input header fields
* @param r The current request
* @return OK or DECLINED
* @deffunc ap_run_post_read_request(request_rec *r)
*/
AP_DECLARE_HOOK(int,post_read_request,(request_rec *r))
/**
* This hook allows modules to perform any module-specific logging activities
* over and above the normal server things.
* @param r The current request
* @return OK, DECLINED, or HTTP_...
* @deffunc int ap_run_log_transaction(request_rec *r)
*/
AP_DECLARE_HOOK(int,log_transaction,(request_rec *r))
/**
* This hook allows modules to retrieve the http method from a request. This
* allows Apache modules to easily extend the methods that Apache understands
* @param r The current request
* @return The http method from the request
* @deffunc const char *ap_run_http_method(const request_rec *r)
*/
AP_DECLARE_HOOK(const char *,http_method,(const request_rec *r))
/**
* Return the default port from the current request
* @param r The current request
* @return The current port
* @deffunc apr_port_t ap_run_default_port(const request_rec *r)
*/
AP_DECLARE_HOOK(apr_port_t,default_port,(const request_rec *r))
typedef struct ap_bucket_error ap_bucket_error;
/**
* A bucket referring to an HTTP error
* This bucket can be passed down the filter stack to indicate that an
* HTTP error occurred while running a filter. In order for this bucket
* to be used successfully, it MUST be sent as the first bucket in the
* first brigade to be sent from a given filter.
*/
struct ap_bucket_error {
/** Number of buckets using this memory */
apr_bucket_refcount refcount;
/** The error code */
int status;
/** The error string */
const char *data;
};
AP_DECLARE_DATA extern const apr_bucket_type_t ap_bucket_type_error;
/**
* Determine if a bucket is an error bucket
* @param e The bucket to inspect
* @return true or false
*/
#define AP_BUCKET_IS_ERROR(e) (e->type == &ap_bucket_type_error)
/**
* Make the bucket passed in an error bucket
* @param b The bucket to make into an error bucket
* @param error The HTTP error code to put in the bucket.
* @param buf An optional error string to put in the bucket.
* @param p A pool to allocate out of.
* @return The new bucket, or NULL if allocation failed
* @deffunc apr_bucket *ap_bucket_error_make(apr_bucket *b, int error, const char *buf, apr_pool_t *p)
*/
AP_DECLARE(apr_bucket *) ap_bucket_error_make(apr_bucket *b, int error,
const char *buf, apr_pool_t *p);
/**
* Create a bucket referring to an HTTP error.
* @param error The HTTP error code to put in the bucket.
* @param buf An optional error string to put in the bucket.
* @param p A pool to allocate the error string out of.
* @param list The bucket allocator from which to allocate the bucket
* @return The new bucket, or NULL if allocation failed
* @deffunc apr_bucket *ap_bucket_error_create(int error, const char *buf, apr_pool_t *p, apr_bucket_alloc_t *list)
*/
AP_DECLARE(apr_bucket *) ap_bucket_error_create(int error, const char *buf,
apr_pool_t *p,
apr_bucket_alloc_t *list);
AP_DECLARE_NONSTD(apr_status_t) ap_byterange_filter(ap_filter_t *f, apr_bucket_brigade *b);
AP_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, apr_bucket_brigade *b);
AP_DECLARE_NONSTD(apr_status_t) ap_content_length_filter(ap_filter_t *,
apr_bucket_brigade *);
AP_DECLARE_NONSTD(apr_status_t) ap_old_write_filter(ap_filter_t *f, apr_bucket_brigade *b);
/*
* Setting up the protocol fields for subsidiary requests...
* Also, a wrapup function to keep the internal accounting straight.
*/
void ap_set_sub_req_protocol(request_rec *rnew, const request_rec *r);
void ap_finalize_sub_req_protocol(request_rec *sub_r);
#ifdef __cplusplus
}
#endif
#endif /* !APACHE_HTTP_PROTOCOL_H */