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