http_protocol.h revision ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dc
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder/* Copyright 2000-2004 Apache Software Foundation
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
3f69b6948966979163bdfe8331c38833d5d90ecdChristian Maeder * http://www.apache.org/licenses/LICENSE-2.0
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.
434c11a96bc623ebd5b60781efabef319bb15b0eChristian Maeder * @package HTTP protocol handling
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
ccd28c25c1aee73a195053e677eca17e20917d84Christian MaederAP_DECLARE_HOOK(void,insert_error_filter,(request_rec *r))
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 MaederAP_DECLARE_DATA extern ap_filter_rec_t *ap_old_write_func;
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * Prototypes for routines which either talk directly back to the user,
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * or control the ones that eventually do.
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 * Read the mime-encoded headers.
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * @param r The current request
ccd28c25c1aee73a195053e677eca17e20917d84Christian MaederAP_DECLARE(void) ap_get_mime_headers(request_rec *r);
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
1aee531e3fe5a94300ddc7933c1983a38a76316eChristian MaederAP_DECLARE(void) ap_get_mime_headers_core(request_rec *r,
c7f5076658d72ea340d7fd8a648908f961af682dChristian Maeder/* Finish up stuff after a request */
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 MaederAP_DECLARE(void) ap_finalize_request_protocol(request_rec *r);
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)
ccd28c25c1aee73a195053e677eca17e20917d84Christian MaederAP_DECLARE(void) ap_send_error_response(request_rec *r, int recursive_error);
a571b691ac0da91a895c33f250509622004dcf03Christian Maeder/* Set last modified header line from the lastmod date of the associated file.
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * Also, set content length.
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * May return an error status, typically HTTP_NOT_MODIFIED (that when the
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang * permit_cache argument is set to one).
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)
4674b607529c8eab497240da6da1ef9ae786611cChristian MaederAP_DECLARE(void) ap_set_content_length(request_rec *r, apr_off_t length);
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)
ccd28c25c1aee73a195053e677eca17e20917d84Christian MaederAP_DECLARE(int) ap_set_keepalive(request_rec *r);
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)
fef03b64e3b1d7d3a8e098f62ef2e7687a433f09Christian MaederAP_DECLARE(apr_time_t) ap_rationalize_mtime(request_rec *r, apr_time_t mtime);
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);
264b794970b6f2bd437f14233f367f1067565728Jian Chun WangAP_DECLARE(const char *) ap_make_content_type(request_rec *r,
264b794970b6f2bd437f14233f367f1067565728Jian Chun Wang const char *type);
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)
8c4c53f1d84490c7eac208905e92964c6508c1d6Christian MaederAP_DECLARE(void) ap_setup_make_content_type(apr_pool_t *pool);
8519df804b37f95a2394a6cd5662da02efa3400bChristian Maeder#endif /* CORE_PRIVATE */
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 WangAP_DECLARE(char *) ap_make_etag(request_rec *r, int force_weak);
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * Set the E-tag outgoing header
66939c546b3eaf25eb34d1dc36c0c82943f85552Christian Maeder * @param The current request
e92e93922166c81167de83cc7400403c5d9bb26cChristian Maeder * @deffunc void ap_set_etag(request_rec *r)
66939c546b3eaf25eb34d1dc36c0c82943f85552Christian MaederAP_DECLARE(void) ap_set_etag(request_rec *r);
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)
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun WangAP_DECLARE(void) ap_set_last_modified(request_rec *r);
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)
0015e1756b734b34d4b550318c078f9a0c585611Christian MaederAP_DECLARE(int) ap_meets_conditions(request_rec *r);
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).
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).
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);
479da8506f391abe070ced2fb93c9759a280fa68Christian MaederAP_DECLARE(apr_status_t) ap_send_fd(apr_file_t *fd, request_rec *r, apr_off_t offset,
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)
0015e1756b734b34d4b550318c078f9a0c585611Christian MaederAP_DECLARE(size_t) ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset,
434c11a96bc623ebd5b60781efabef319bb15b0eChristian Maeder * Register a new request method, and return the offset that will be
51b1633dc0785a542da974fae21fa7d6622c934eChristian Maeder * associated with that method.
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 MaederAP_DECLARE(int) ap_method_register(apr_pool_t *p, const char *methname);
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * Initialize the method_registry and allocate memory for it.
b65890a7645b96eb0d5c334c81ba9dca86d556bfChristian Maeder * @param p Pool to allocate memory for the registry from.
c4a8059d0469a85bb58c28ac66729ac19d743d3cChristian MaederAP_DECLARE(void) ap_method_registry_init(apr_pool_t *p);
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * This is a convenience macro to ease with checking a mask
ccd28c25c1aee73a195053e677eca17e20917d84Christian Maeder * against a method name.
5be2fb5bcfaa6abbb6043d679a1d536b4878b789Jian Chun Wang#define AP_METHOD_CHECK_ALLOWED(mask, methname) \
d06598e0c310f65ab552ca55626c2f7694ffd5e3Christian Maeder ((mask) & (AP_METHOD_BIT << ap_method_number_of((methname))))
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * Create a new method list with the specified number of preallocated
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * slots for extension methods.
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * @param p Pointer to a pool in which the structure should be
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)
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,
f799084b320209cdd71a29e74fff1be054c1d342Christian MaederAP_DECLARE_NONSTD(void) ap_method_list_do(int (*comp) (void *urec, const char *mname,
f799084b320209cdd71a29e74fff1be054c1d342Christian MaederAP_DECLARE(void) ap_method_list_vdo(int (*comp) (void *urec, const char *mname,
d06598e0c310f65ab552ca55626c2f7694ffd5e3Christian Maeder * Search for an HTTP method name in an ap_method_list_t structure, and
d06598e0c310f65ab552ca55626c2f7694ffd5e3Christian Maeder * return true if found.
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)
d06598e0c310f65ab552ca55626c2f7694ffd5e3Christian MaederAP_DECLARE(int) ap_method_in_list(ap_method_list_t *l, const char *method);
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * Add an HTTP method name to an ap_method_list_t structure if it isn't
f799084b320209cdd71a29e74fff1be054c1d342Christian Maeder * already listed.
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 MaederAP_DECLARE(void) ap_method_list_add(ap_method_list_t *l, const char *method);
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang * Remove an HTTP method name from an ap_method_list_t structure.
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 WangAP_DECLARE(void) ap_method_list_remove(ap_method_list_t *l,
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang const char *method);
224e5f347275f5e9ada6cd976f195de2e77e41cbChristian Maeder * Reset a method list to be completely empty.
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 WangAP_DECLARE(void) ap_clear_method_list(ap_method_list_t *l);
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 WangAP_DECLARE(void) ap_set_content_type(request_rec *r, const char *ct);
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.
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)
8c4c53f1d84490c7eac208905e92964c6508c1d6Christian MaederAP_DECLARE(int) ap_rputc(int c, request_rec *r);
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 WangAP_DECLARE(int) ap_rputs(const char *str, request_rec *r);
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 MaederAP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r);
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, ...)
ccd28c25c1aee73a195053e677eca17e20917d84Christian MaederAP_DECLARE_NONSTD(int) ap_rvputs(request_rec *r,...);
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 MaederAP_DECLARE(int) ap_vrprintf(request_rec *r, const char *fmt, va_list vlist);
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, ...)
1c53d99313dcdd6e1ba0022689aa97de1b064a67Christian MaederAP_DECLARE_NONSTD(int) ap_rprintf(request_rec *r, const char *fmt,...)
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)
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)
9031d53c51b21d50ff4af9e8a365f0252401539fChristian MaederAP_DECLARE(int) ap_index_of_response(int status);
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)
9ba43c9323dc1a4bb1e684d87370b43468ab9096Christian MaederAP_DECLARE(const char *) ap_get_status_line(int status);
9c06522a04b3f7bc904091ca1abaa2f956113c94Christian Maeder/* Reading a block of data from the client connection (e.g., POST arg) */
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.
4674b607529c8eab497240da6da1ef9ae786611cChristian Maeder * @return either OK or an error code
1c53d99313dcdd6e1ba0022689aa97de1b064a67Christian Maeder * @deffunc int ap_setup_client_block(request_rec *r, int read_policy)
1c53d99313dcdd6e1ba0022689aa97de1b064a67Christian MaederAP_DECLARE(int) ap_setup_client_block(request_rec *r, int read_policy);
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 MaederAP_DECLARE(int) ap_should_client_block(request_rec *r);
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)
fef03b64e3b1d7d3a8e098f62ef2e7687a433f09Christian MaederAP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer, apr_size_t bufsiz);
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)
f799084b320209cdd71a29e74fff1be054c1d342Christian MaederAP_DECLARE(int) ap_discard_request_body(request_rec *r);
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)
ccd28c25c1aee73a195053e677eca17e20917d84Christian MaederAP_DECLARE(void) ap_note_auth_failure(request_rec *r);
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)
2344f16936f5b31c9530d0cafb3838e9df3f3644Christian MaederAP_DECLARE(void) ap_note_basic_auth_failure(request_rec *r);
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)
f799084b320209cdd71a29e74fff1be054c1d342Christian MaederAP_DECLARE(void) ap_note_digest_auth_failure(request_rec *r);
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)
94e112d16f89130a688db8b03ad3224903f5e97eChristian MaederAP_DECLARE(int) ap_get_basic_auth_pw(request_rec *r, const char **pw);
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)
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 MaederAP_CORE_DECLARE(void) ap_parse_uri(request_rec *r, const char *uri);
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 MaederAP_DECLARE(int) ap_getline(char *s, int n, request_rec *r, int fold);
9ba43c9323dc1a4bb1e684d87370b43468ab9096Christian Maeder * Get the next line of input for the request
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.
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.
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 WangAP_DECLARE(apr_status_t) ap_rgetline(char **s, apr_size_t n,
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))
8c6b80162937eae0fe868c3b52bda6b50a153478Christian MaederAP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n,
struct ap_bucket_error {
int status;
const char *data;
* @deffunc apr_bucket *ap_bucket_error_make(apr_bucket *b, int error, const char *buf, apr_pool_t *p)
* @deffunc apr_bucket *ap_bucket_error_create(int error, const char *buf, apr_pool_t *p, apr_bucket_alloc_t *list)
apr_pool_t *p,
#ifdef __cplusplus