Blame include/http_protocol.h

Packit 90a5c9
/* Licensed to the Apache Software Foundation (ASF) under one or more
Packit 90a5c9
 * contributor license agreements.  See the NOTICE file distributed with
Packit 90a5c9
 * this work for additional information regarding copyright ownership.
Packit 90a5c9
 * The ASF licenses this file to You under the Apache License, Version 2.0
Packit 90a5c9
 * (the "License"); you may not use this file except in compliance with
Packit 90a5c9
 * the License.  You may obtain a copy of the License at
Packit 90a5c9
 *
Packit 90a5c9
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit 90a5c9
 *
Packit 90a5c9
 * Unless required by applicable law or agreed to in writing, software
Packit 90a5c9
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 90a5c9
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 90a5c9
 * See the License for the specific language governing permissions and
Packit 90a5c9
 * limitations under the License.
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * @file  http_protocol.h
Packit 90a5c9
 * @brief HTTP protocol handling
Packit 90a5c9
 *
Packit 90a5c9
 * @defgroup APACHE_CORE_PROTO HTTP Protocol Handling
Packit 90a5c9
 * @ingroup  APACHE_CORE
Packit 90a5c9
 * @{
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
#ifndef APACHE_HTTP_PROTOCOL_H
Packit 90a5c9
#define APACHE_HTTP_PROTOCOL_H
Packit 90a5c9
Packit 90a5c9
#include "httpd.h"
Packit 90a5c9
#include "apr_portable.h"
Packit 90a5c9
#include "apr_mmap.h"
Packit 90a5c9
#include "apr_buckets.h"
Packit 90a5c9
#include "util_filter.h"
Packit 90a5c9
Packit 90a5c9
#ifdef __cplusplus
Packit 90a5c9
extern "C" {
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * This hook allows modules to insert filters for the current error response
Packit 90a5c9
 * @param r the current request
Packit 90a5c9
 * @ingroup hooks
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE_HOOK(void,insert_error_filter,(request_rec *r))
Packit 90a5c9
Packit 90a5c9
/** This is an optimization.  We keep a record of the filter_rec that
Packit 90a5c9
 * stores the old_write filter, so that we can avoid strcmp's later.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE_DATA extern ap_filter_rec_t *ap_old_write_func;
Packit 90a5c9
Packit 90a5c9
/*
Packit 90a5c9
 * Prototypes for routines which either talk directly back to the user,
Packit 90a5c9
 * or control the ones that eventually do.
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Read a request and fill in the fields.
Packit 90a5c9
 * @param c The current connection
Packit 90a5c9
 * @return The new request_rec
Packit 90a5c9
 */
Packit 90a5c9
request_rec *ap_read_request(conn_rec *c);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Read the mime-encoded headers.
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_get_mime_headers(request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Optimized version of ap_get_mime_headers() that requires a
Packit 90a5c9
 * temporary brigade to work with
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @param bb temp brigade
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_get_mime_headers_core(request_rec *r,
Packit 90a5c9
                                          apr_bucket_brigade *bb);
Packit 90a5c9
Packit 90a5c9
/* Finish up stuff after a request */
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Called at completion of sending the response.  It sends the terminating
Packit 90a5c9
 * protocol information.
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_finalize_request_protocol(request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Send error back to client.
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @param recursive_error last arg indicates error status in case we get
Packit 90a5c9
 *      an error in the process of trying to deal with an ErrorDocument
Packit 90a5c9
 *      to handle some other error.  In that case, we print the default
Packit 90a5c9
 *      report for the first thing that went wrong, and more briefly report
Packit 90a5c9
 *      on the problem with the ErrorDocument.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_send_error_response(request_rec *r, int recursive_error);
Packit 90a5c9
Packit 90a5c9
/* Set last modified header line from the lastmod date of the associated file.
Packit 90a5c9
 * Also, set content length.
Packit 90a5c9
 *
Packit 90a5c9
 * May return an error status, typically HTTP_NOT_MODIFIED (that when the
Packit 90a5c9
 * permit_cache argument is set to one).
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Set the content length for this request
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @param length The new content length
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_set_content_length(request_rec *r, apr_off_t length);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Set the keepalive status for this request
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return 1 if keepalive can be set, 0 otherwise
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(int) ap_set_keepalive(request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Return the latest rational time from a request/mtime pair.  Mtime is
Packit 90a5c9
 * returned unless it's in the future, in which case we return the current time.
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @param mtime The last modified time
Packit 90a5c9
 * @return the latest rational time.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_time_t) ap_rationalize_mtime(request_rec *r, apr_time_t mtime);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Build the content-type that should be sent to the client from the
Packit 90a5c9
 * content-type specified.  The following rules are followed:
Packit 90a5c9
 *    - if type is NULL or "", return NULL (do not set content-type).
Packit 90a5c9
 *    - if charset adding is disabled, stop processing and return type.
Packit 90a5c9
 *    - then, if there are no parameters on type, add the default charset
Packit 90a5c9
 *    - return type
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @param type The content type
Packit 90a5c9
 * @return The content-type
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(const char *) ap_make_content_type(request_rec *r,
Packit 90a5c9
                                              const char *type);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Precompile metadata structures used by ap_make_content_type()
Packit 90a5c9
 * @param pool The pool to use for allocations
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_setup_make_content_type(apr_pool_t *pool);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Construct an entity tag from the resource information.  If it's a real
Packit 90a5c9
 * file, build in some of the file characteristics.
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @param force_weak Force the entity tag to be weak - it could be modified
Packit 90a5c9
 *                   again in as short an interval.
Packit 90a5c9
 * @return The entity tag
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(char *) ap_make_etag(request_rec *r, int force_weak);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Set the E-tag outgoing header
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_set_etag(request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Set the last modified time for the file being sent
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_set_last_modified(request_rec *r);
Packit 90a5c9
Packit 90a5c9
typedef enum {
Packit 90a5c9
    AP_CONDITION_NONE,
Packit 90a5c9
    AP_CONDITION_NOMATCH,
Packit 90a5c9
    AP_CONDITION_WEAK,
Packit 90a5c9
    AP_CONDITION_STRONG
Packit 90a5c9
} ap_condition_e;
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Tests conditional request rules for the If-Match header.
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @param headers The response headers to check against
Packit 90a5c9
 * @return AP_CONDITION_NONE if the header is missing, AP_CONDITION_NOMATCH
Packit 90a5c9
 *         if the header does not match, AP_CONDITION_STRONG for a strong
Packit 90a5c9
 *         match. Weak matches are not permitted for the If-Match header.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(ap_condition_e) ap_condition_if_match(request_rec *r,
Packit 90a5c9
        apr_table_t *headers);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Tests conditional request rules for the If-Unmodified-Since header.
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @param headers The response headers to check against
Packit 90a5c9
 * @return AP_CONDITION_NONE if the header is missing, AP_CONDITION_NOMATCH
Packit 90a5c9
 *         if the header does not match, AP_CONDITION_WEAK if a weak match
Packit 90a5c9
 *         was present and allowed by RFC2616, AP_CONDITION_STRONG for a
Packit 90a5c9
 *         strong match.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(ap_condition_e) ap_condition_if_unmodified_since(request_rec *r,
Packit 90a5c9
        apr_table_t *headers);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Tests conditional request rules for the If-None-Match header.
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @param headers The response headers to check against
Packit 90a5c9
 * @return AP_CONDITION_NONE if the header is missing, AP_CONDITION_NOMATCH
Packit 90a5c9
 *         if the header does not match, AP_CONDITION_WEAK if a weak match
Packit 90a5c9
 *         was present and allowed by RFC2616, AP_CONDITION_STRONG for a
Packit 90a5c9
 *         strong match.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(ap_condition_e) ap_condition_if_none_match(request_rec *r,
Packit 90a5c9
        apr_table_t *headers);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Tests conditional request rules for the If-Modified-Since header.
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @param headers The response headers to check against
Packit 90a5c9
 * @return AP_CONDITION_NONE if the header is missing, AP_CONDITION_NOMATCH
Packit 90a5c9
 *         if the header does not match, AP_CONDITION_WEAK if a weak match
Packit 90a5c9
 *         was present and allowed by RFC2616, AP_CONDITION_STRONG for a
Packit 90a5c9
 *         strong match.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(ap_condition_e) ap_condition_if_modified_since(request_rec *r,
Packit 90a5c9
        apr_table_t *headers);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Tests conditional request rules for the If-Range header.
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @param headers The response headers to check against
Packit 90a5c9
 * @return AP_CONDITION_NONE if either the If-Range or Range header is
Packit 90a5c9
 *         missing, AP_CONDITION_NOMATCH if the header does not match,
Packit 90a5c9
 *         AP_CONDITION_STRONG for a strong match. Weak matches are not
Packit 90a5c9
 *         permitted for the If-Range header.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(ap_condition_e) ap_condition_if_range(request_rec *r,
Packit 90a5c9
        apr_table_t *headers);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Implements condition GET rules for HTTP/1.1 specification.  This function
Packit 90a5c9
 * inspects the client headers and determines if the response fulfills
Packit 90a5c9
 * the requirements specified.
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return OK if the response fulfills the condition GET rules, some
Packit 90a5c9
 *         other status code otherwise
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(int) ap_meets_conditions(request_rec *r);
Packit 90a5c9
Packit 90a5c9
/* Other ways to send stuff at the client.  All of these keep track
Packit 90a5c9
 * of bytes_sent automatically.  This indirection is intended to make
Packit 90a5c9
 * it a little more painless to slide things like HTTP-NG packetization
Packit 90a5c9
 * underneath the main body of the code later.  In the meantime, it lets
Packit 90a5c9
 * us centralize a bit of accounting (bytes_sent).
Packit 90a5c9
 *
Packit 90a5c9
 * These also return the number of bytes written by the call.
Packit 90a5c9
 * They should only be called with a timeout registered, for obvious reaasons.
Packit 90a5c9
 * (Ditto the send_header stuff).
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Send an entire file to the client, using sendfile if supported by the
Packit 90a5c9
 * current platform
Packit 90a5c9
 * @param fd The file to send.
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @param offset Offset into the file to start sending.
Packit 90a5c9
 * @param length Amount of data to send
Packit 90a5c9
 * @param nbytes Amount of data actually sent
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_status_t) ap_send_fd(apr_file_t *fd, request_rec *r, apr_off_t offset,
Packit 90a5c9
                                   apr_size_t length, apr_size_t *nbytes);
Packit 90a5c9
Packit 90a5c9
#if APR_HAS_MMAP
Packit 90a5c9
/**
Packit 90a5c9
 * Send an MMAP'ed file to the client
Packit 90a5c9
 * @param mm The MMAP'ed file to send
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @param offset The offset into the MMAP to start sending
Packit 90a5c9
 * @param length The amount of data to send
Packit 90a5c9
 * @return The number of bytes sent
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_size_t) ap_send_mmap(apr_mmap_t *mm,
Packit 90a5c9
                                    request_rec *r,
Packit 90a5c9
                                    apr_size_t offset,
Packit 90a5c9
                                    apr_size_t length);
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Register a new request method, and return the offset that will be
Packit 90a5c9
 * associated with that method.
Packit 90a5c9
 *
Packit 90a5c9
 * @param p        The pool to create registered method numbers from.
Packit 90a5c9
 * @param methname The name of the new method to register.
Packit 90a5c9
 * @return         An int value representing an offset into a bitmask.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(int) ap_method_register(apr_pool_t *p, const char *methname);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Initialize the method_registry and allocate memory for it.
Packit 90a5c9
 *
Packit 90a5c9
 * @param p Pool to allocate memory for the registry from.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_method_registry_init(apr_pool_t *p);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * This is a convenience macro to ease with checking a mask
Packit 90a5c9
 * against a method name.
Packit 90a5c9
 */
Packit 90a5c9
#define AP_METHOD_CHECK_ALLOWED(mask, methname) \
Packit 90a5c9
    ((mask) & (AP_METHOD_BIT << ap_method_number_of((methname))))
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Create a new method list with the specified number of preallocated
Packit 90a5c9
 * slots for extension methods.
Packit 90a5c9
 *
Packit 90a5c9
 * @param   p       Pointer to a pool in which the structure should be
Packit 90a5c9
 *                  allocated.
Packit 90a5c9
 * @param   nelts   Number of preallocated extension slots
Packit 90a5c9
 * @return  Pointer to the newly created structure.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(ap_method_list_t *) ap_make_method_list(apr_pool_t *p, int nelts);
Packit 90a5c9
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Copy a method list
Packit 90a5c9
 *
Packit 90a5c9
 * @param   dest List to copy to
Packit 90a5c9
 * @param   src  List to copy from
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_copy_method_list(ap_method_list_t *dest,
Packit 90a5c9
                                     ap_method_list_t *src);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Search for an HTTP method name in an ap_method_list_t structure, and
Packit 90a5c9
 * return true if found.
Packit 90a5c9
 *
Packit 90a5c9
 * @param   method  String containing the name of the method to check.
Packit 90a5c9
 * @param   l       Pointer to a method list, such as r->allowed_methods.
Packit 90a5c9
 * @return  1 if method is in the list, otherwise 0
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(int) ap_method_in_list(ap_method_list_t *l, const char *method);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Add an HTTP method name to an ap_method_list_t structure if it isn't
Packit 90a5c9
 * already listed.
Packit 90a5c9
 *
Packit 90a5c9
 * @param   method  String containing the name of the method to check.
Packit 90a5c9
 * @param   l       Pointer to a method list, such as r->allowed_methods.
Packit 90a5c9
 * @return  None.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_method_list_add(ap_method_list_t *l, const char *method);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Remove an HTTP method name from an ap_method_list_t structure.
Packit 90a5c9
 *
Packit 90a5c9
 * @param   l       Pointer to a method list, such as r->allowed_methods.
Packit 90a5c9
 * @param   method  String containing the name of the method to remove.
Packit 90a5c9
 * @return  None.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_method_list_remove(ap_method_list_t *l,
Packit 90a5c9
                                       const char *method);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Reset a method list to be completely empty.
Packit 90a5c9
 *
Packit 90a5c9
 * @param   l       Pointer to a method list, such as r->allowed_methods.
Packit 90a5c9
 * @return  None.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_clear_method_list(ap_method_list_t *l);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Set the content type for this request (r->content_type).
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @param ct The new content type
Packit 90a5c9
 * @warning This function must be called to set r->content_type in order
Packit 90a5c9
 * for the AddOutputFilterByType directive to work correctly.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_set_content_type(request_rec *r, const char *ct);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Set the Accept-Ranges header for this response
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_set_accept_ranges(request_rec *r);
Packit 90a5c9
Packit 90a5c9
Packit 90a5c9
/* Hmmm... could macrofy these for now, and maybe forever, though the
Packit 90a5c9
 * definitions of the macros would get a whole lot hairier.
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Output one character for this request
Packit 90a5c9
 * @param c the character to output
Packit 90a5c9
 * @param r the current request
Packit 90a5c9
 * @return The number of bytes sent
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(int) ap_rputc(int c, request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Write a buffer for the current request
Packit 90a5c9
 * @param buf The buffer to write
Packit 90a5c9
 * @param nbyte The number of bytes to send from the buffer
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return The number of bytes sent
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Output a string for the current request
Packit 90a5c9
 * @param str The string to output
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return The number of bytes sent
Packit 90a5c9
 * @note ap_rputs may be implemented as macro or inline function
Packit 90a5c9
 */
Packit 90a5c9
static APR_INLINE int ap_rputs(const char *str, request_rec *r)
Packit 90a5c9
{
Packit 90a5c9
    return ap_rwrite(str, (int)strlen(str), r);
Packit 90a5c9
}
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Write an unspecified number of strings to the request
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @param ... The strings to write
Packit 90a5c9
 * @return The number of bytes sent
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE_NONSTD(int) ap_rvputs(request_rec *r,...)
Packit 90a5c9
                       AP_FN_ATTR_SENTINEL;
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Output data to the client in a printf format
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @param fmt The format string
Packit 90a5c9
 * @param vlist The arguments to use to fill out the format string
Packit 90a5c9
 * @return The number of bytes sent
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(int) ap_vrprintf(request_rec *r, const char *fmt, va_list vlist);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Output data to the client in a printf format
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @param fmt The format string
Packit 90a5c9
 * @param ... The arguments to use to fill out the format string
Packit 90a5c9
 * @return The number of bytes sent
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE_NONSTD(int) ap_rprintf(request_rec *r, const char *fmt,...)
Packit 90a5c9
                                __attribute__((format(printf,2,3)));
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Flush all of the data for the current request to the client
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return 0 on success, -1 if an error occurred
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(int) ap_rflush(request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Index used in custom_responses array for a specific error code
Packit 90a5c9
 * (only use outside protocol.c is in getting them configured).
Packit 90a5c9
 * @param status HTTP status code
Packit 90a5c9
 * @return The index of the response
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(int) ap_index_of_response(int status);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Return the Status-Line for a given status code (excluding the
Packit 90a5c9
 * HTTP-Version field). If an invalid or unknown status code is
Packit 90a5c9
 * passed, "500 Internal Server Error" will be returned.
Packit 90a5c9
 * @param status The HTTP status code
Packit 90a5c9
 * @return The Status-Line
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(const char *) ap_get_status_line(int status);
Packit 90a5c9
Packit 90a5c9
/* Reading a block of data from the client connection (e.g., POST arg) */
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Setup the client to allow Apache to read the request body.
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @param read_policy How the server should interpret a chunked
Packit 90a5c9
 *                    transfer-encoding.  One of: 
Packit 90a5c9
 *    REQUEST_NO_BODY          Send 413 error if message has any body
Packit 90a5c9
 *    REQUEST_CHUNKED_ERROR    Send 411 error if body without Content-Length
Packit 90a5c9
 *    REQUEST_CHUNKED_DECHUNK  If chunked, remove the chunks for me.
Packit 90a5c9
 * 
Packit 90a5c9
 * @return either OK or an error code
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(int) ap_setup_client_block(request_rec *r, int read_policy);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Determine if the client has sent any data.  This also sends a
Packit 90a5c9
 * 100 Continue response to HTTP/1.1 clients, so modules should not be called
Packit 90a5c9
 * until the module is ready to read content.
Packit 90a5c9
 * @warning Never call this function more than once.
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return 0 if there is no message to read, 1 otherwise
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(int) ap_should_client_block(request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Call this in a loop.  It will put data into a buffer and return the length
Packit 90a5c9
 * of the input block
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @param buffer The buffer in which to store the data
Packit 90a5c9
 * @param bufsiz The size of the buffer
Packit 90a5c9
 * @return Number of bytes inserted into the buffer.  When done reading, 0
Packit 90a5c9
 *         if EOF, or -1 if there was an error
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer, apr_size_t bufsiz);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Map specific APR codes returned by the filter stack to HTTP error
Packit 90a5c9
 * codes, or the default status code provided. Use it as follows:
Packit 90a5c9
 *
Packit 90a5c9
 * return ap_map_http_request_error(rv, HTTP_BAD_REQUEST);
Packit 90a5c9
 *
Packit 90a5c9
 * If the filter has already handled the error, AP_FILTER_ERROR will
Packit 90a5c9
 * be returned, which is cleanly passed through.
Packit 90a5c9
 *
Packit 90a5c9
 * These mappings imply that the filter stack is reading from the
Packit 90a5c9
 * downstream client, the proxy will map these codes differently.
Packit 90a5c9
 * @param rv APR status code
Packit 90a5c9
 * @param status Default HTTP code should the APR code not be recognised
Packit 90a5c9
 * @return Mapped HTTP status code
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(int) ap_map_http_request_error(apr_status_t rv, int status);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * In HTTP/1.1, any method can have a body.  However, most GET handlers
Packit 90a5c9
 * wouldn't know what to do with a request body if they received one.
Packit 90a5c9
 * This helper routine tests for and reads any message body in the request,
Packit 90a5c9
 * simply discarding whatever it receives.  We need to do this because
Packit 90a5c9
 * failing to read the request body would cause it to be interpreted
Packit 90a5c9
 * as the next request on a persistent connection.
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return error status if request is malformed, OK otherwise
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(int) ap_discard_request_body(request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Setup the output headers so that the client knows how to authenticate
Packit 90a5c9
 * itself the next time, if an authentication request failed.
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_note_auth_failure(request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * @deprecated @see ap_note_auth_failure
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_note_basic_auth_failure(request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * @deprecated @see ap_note_auth_failure
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_note_digest_auth_failure(request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * This hook allows modules to add support for a specific auth type to
Packit 90a5c9
 * ap_note_auth_failure
Packit 90a5c9
 * @param r the current request
Packit 90a5c9
 * @param auth_type the configured auth_type
Packit 90a5c9
 * @return OK, DECLINED
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE_HOOK(int, note_auth_failure, (request_rec *r, const char *auth_type))
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Get the password from the request headers. This function has multiple side
Packit 90a5c9
 * effects due to its prior use in the old authentication framework.
Packit 90a5c9
 * ap_get_basic_auth_components() should be preferred.
Packit 90a5c9
 *
Packit 90a5c9
 * @deprecated @see ap_get_basic_auth_components
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @param pw The password as set in the headers
Packit 90a5c9
 * @return 0 (OK) if it set the 'pw' argument (and assured
Packit 90a5c9
 *         a correct value in r->user); otherwise it returns
Packit 90a5c9
 *         an error code, either HTTP_INTERNAL_SERVER_ERROR if things are
Packit 90a5c9
 *         really confused, HTTP_UNAUTHORIZED if no authentication at all
Packit 90a5c9
 *         seemed to be in use, or DECLINED if there was authentication but
Packit 90a5c9
 *         it wasn't Basic (in which case, the caller should presumably
Packit 90a5c9
 *         decline as well).
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(int) ap_get_basic_auth_pw(request_rec *r, const char **pw);
Packit 90a5c9
Packit 90a5c9
#define AP_GET_BASIC_AUTH_PW_NOTE "AP_GET_BASIC_AUTH_PW_NOTE"
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Get the username and/or password from the request's Basic authentication
Packit 90a5c9
 * headers. Unlike ap_get_basic_auth_pw(), calling this function has no side
Packit 90a5c9
 * effects on the passed request_rec.
Packit 90a5c9
 *
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @param username If not NULL, set to the username sent by the client
Packit 90a5c9
 * @param password If not NULL, set to the password sent by the client
Packit 90a5c9
 * @return APR_SUCCESS if the credentials were successfully parsed and returned;
Packit 90a5c9
 *         APR_EINVAL if there was no authentication header sent or if the
Packit 90a5c9
 *         client was not using the Basic authentication scheme. username and
Packit 90a5c9
 *         password are unchanged on failure.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_status_t) ap_get_basic_auth_components(const request_rec *r,
Packit 90a5c9
                                                      const char **username,
Packit 90a5c9
                                                      const char **password);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * parse_uri: break apart the uri
Packit 90a5c9
 * @warning Side Effects:
Packit 90a5c9
 *    @li sets r->args to rest after '?' (or NULL if no '?')
Packit 90a5c9
 *    @li sets r->uri to request uri (without r->args part)
Packit 90a5c9
 *    @li sets r->hostname (if not set already) from request (scheme://host:port)
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @param uri The uri to break apart
Packit 90a5c9
 */
Packit 90a5c9
AP_CORE_DECLARE(void) ap_parse_uri(request_rec *r, const char *uri);
Packit 90a5c9
Packit 90a5c9
#define AP_GETLINE_FOLD 1 /* Whether to merge continuation lines */
Packit 90a5c9
#define AP_GETLINE_CRLF 2 /* Whether line ends must be in the form CR LF */
Packit 90a5c9
#define AP_GETLINE_NOSPC_EOL 4 /* Whether to consume up to and including the
Packit 90a5c9
                                  end of line on APR_ENOSPC */
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Get the next line of input for the request
Packit 90a5c9
 * @param s The buffer into which to read the line
Packit 90a5c9
 * @param n The size of the buffer
Packit 90a5c9
 * @param r The request
Packit 90a5c9
 * @param flags Bit flag of multiple parsing options
Packit 90a5c9
 *              AP_GETLINE_FOLD Whether to merge continuation lines
Packit 90a5c9
 *              AP_GETLINE_CRLF Whether line ends must be in the form CR LF
Packit 90a5c9
 * @return The length of the line, if successful
Packit 90a5c9
 *         n, if the line is too big to fit in the buffer
Packit 90a5c9
 *         -1 for miscellaneous errors
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(int) ap_getline(char *s, int n, request_rec *r, int flags);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Get the next line of input for the request
Packit 90a5c9
 *
Packit 90a5c9
 * Note: on ASCII boxes, ap_rgetline is a macro which simply calls
Packit 90a5c9
 *       ap_rgetline_core to get the line of input.
Packit 90a5c9
 *
Packit 90a5c9
 *       on EBCDIC boxes, ap_rgetline is a wrapper function which
Packit 90a5c9
 *       translates ASCII protocol lines to the local EBCDIC code page
Packit 90a5c9
 *       after getting the line of input.
Packit 90a5c9
 *
Packit 90a5c9
 * @param s Pointer to the pointer to the buffer into which the line
Packit 90a5c9
 *          should be read; if *s==NULL, a buffer of the necessary size
Packit 90a5c9
 *          to hold the data will be allocated from the request pool
Packit 90a5c9
 * @param n The size of the buffer
Packit 90a5c9
 * @param read The length of the line.
Packit 90a5c9
 * @param r The request
Packit 90a5c9
 * @param flags Bit flag of multiple parsing options
Packit 90a5c9
 *              AP_GETLINE_FOLD Whether to merge continuation lines
Packit 90a5c9
 *              AP_GETLINE_CRLF Whether line ends must be in the form CR LF
Packit 90a5c9
 * @param bb Working brigade to use when reading buckets
Packit 90a5c9
 * @return APR_SUCCESS, if successful
Packit 90a5c9
 *         APR_ENOSPC, if the line is too big to fit in the buffer
Packit 90a5c9
 *         Other errors where appropriate
Packit 90a5c9
 */
Packit 90a5c9
#if APR_CHARSET_EBCDIC
Packit 90a5c9
AP_DECLARE(apr_status_t) ap_rgetline(char **s, apr_size_t n,
Packit 90a5c9
                                     apr_size_t *read,
Packit 90a5c9
                                     request_rec *r, int flags,
Packit 90a5c9
                                     apr_bucket_brigade *bb);
Packit 90a5c9
#else /* ASCII box */
Packit 90a5c9
#define ap_rgetline(s, n, read, r, fold, bb) \
Packit 90a5c9
        ap_rgetline_core((s), (n), (read), (r), (fold), (bb))
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
/** @see ap_rgetline */
Packit 90a5c9
AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n,
Packit 90a5c9
                                          apr_size_t *read,
Packit 90a5c9
                                          request_rec *r, int flags,
Packit 90a5c9
                                          apr_bucket_brigade *bb);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Get the method number associated with the given string, assumed to
Packit 90a5c9
 * contain an HTTP method.  Returns M_INVALID if not recognized.
Packit 90a5c9
 * @param method A string containing a valid HTTP method
Packit 90a5c9
 * @return The method number
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(int) ap_method_number_of(const char *method);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Get the method name associated with the given internal method
Packit 90a5c9
 * number.  Returns NULL if not recognized.
Packit 90a5c9
 * @param p A pool to use for temporary allocations.
Packit 90a5c9
 * @param methnum An integer value corresponding to an internal method number
Packit 90a5c9
 * @return The name corresponding to the method number
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(const char *) ap_method_name_of(apr_pool_t *p, int methnum);
Packit 90a5c9
Packit 90a5c9
Packit 90a5c9
/* Hooks */
Packit 90a5c9
/*
Packit 90a5c9
 * pre_read_request --- run right before read_request_line(),
Packit 90a5c9
 *                  and not run during any subrequests.
Packit 90a5c9
 */
Packit 90a5c9
/**
Packit 90a5c9
 * This hook allows modules to affect the request or connection immediately before
Packit 90a5c9
 * the request has been read, and before any other phases have been processes.
Packit 90a5c9
 * @param r The current request of the soon-to-be-read request
Packit 90a5c9
 * @param c The connection
Packit 90a5c9
 * @return None/void
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE_HOOK(void,pre_read_request,(request_rec *r, conn_rec *c))
Packit 90a5c9
Packit 90a5c9
/*
Packit 90a5c9
 * post_read_request --- run right after read_request or internal_redirect,
Packit 90a5c9
 *                  and not run during any subrequests.
Packit 90a5c9
 */
Packit 90a5c9
/**
Packit 90a5c9
 * This hook allows modules to affect the request immediately after the request
Packit 90a5c9
 * has been read, and before any other phases have been processes.  This allows
Packit 90a5c9
 * modules to make decisions based upon the input header fields
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return OK or DECLINED
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE_HOOK(int,post_read_request,(request_rec *r))
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * This hook allows modules to perform any module-specific logging activities
Packit 90a5c9
 * over and above the normal server things.
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return OK, DECLINED, or HTTP_...
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE_HOOK(int,log_transaction,(request_rec *r))
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * This hook allows modules to retrieve the http scheme for a request.  This
Packit 90a5c9
 * allows Apache modules to easily extend the schemes that Apache understands
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return The http scheme from the request
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE_HOOK(const char *,http_scheme,(const request_rec *r))
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Return the default port from the current request
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return The current port
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE_HOOK(apr_port_t,default_port,(const request_rec *r))
Packit 90a5c9
Packit 90a5c9
Packit 90a5c9
#define AP_PROTOCOL_HTTP1		"http/1.1"
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Determine the list of protocols available for a connection/request. This may
Packit 90a5c9
 * be collected with or without any request sent, in which case the request is 
Packit 90a5c9
 * NULL. Or it may be triggered by the request received, e.g. through the 
Packit 90a5c9
 * "Upgrade" header.
Packit 90a5c9
 *
Packit 90a5c9
 * This hook will be run whenever protocols are being negotiated (ALPN as
Packit 90a5c9
 * one example). It may also be invoked at other times, e.g. when the server
Packit 90a5c9
 * wants to advertise protocols it is capable of switching to.
Packit 90a5c9
 * 
Packit 90a5c9
 * The identifiers for protocols are taken from the TLS extension type ALPN:
Packit 90a5c9
 * https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xml
Packit 90a5c9
 *
Packit 90a5c9
 * If no protocols are added to the proposals, the server not perform any
Packit 90a5c9
 * switch. If the protocol selected from the proposals is the protocol
Packit 90a5c9
 * already in place, also no protocol switch will be invoked.
Packit 90a5c9
 *
Packit 90a5c9
 * The client may already have announced the protocols it is willing to
Packit 90a5c9
 * accept. These will then be listed as offers. This parameter may also
Packit 90a5c9
 * be NULL, indicating that offers from the client are not known and
Packit 90a5c9
 * the hooks should propose all protocols that are valid for the
Packit 90a5c9
 * current connection/request.
Packit 90a5c9
 *
Packit 90a5c9
 * All hooks are run, unless one returns an error. Proposals may contain
Packit 90a5c9
 * duplicates. The order in which proposals are added is usually ignored.
Packit 90a5c9
 * 
Packit 90a5c9
 * @param c The current connection
Packit 90a5c9
 * @param r The current request or NULL
Packit 90a5c9
 * @param s The server/virtual host selected
Packit 90a5c9
 * @param offers A list of protocol identifiers offered by the client or
Packit 90a5c9
 *               NULL to indicated that the hooks are free to propose 
Packit 90a5c9
 * @param proposals The list of protocol identifiers proposed by the hooks
Packit 90a5c9
 * @return OK or DECLINED
Packit 90a5c9
 * @bug This API or implementation and order of operations should be considered
Packit 90a5c9
 * experimental and will continue to evolve in future 2.4 releases, with
Packit 90a5c9
 * a corresponding minor module magic number (MMN) bump to indicate the
Packit 90a5c9
 * API revision level.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE_HOOK(int,protocol_propose,(conn_rec *c, request_rec *r,
Packit 90a5c9
                                      server_rec *s,
Packit 90a5c9
                                      const apr_array_header_t *offers,
Packit 90a5c9
                                      apr_array_header_t *proposals))
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Perform a protocol switch on the connection. The exact requirements for
Packit 90a5c9
 * that depend on the protocol in place and the one switched to. The first 
Packit 90a5c9
 * protocol module to handle the switch is the last module run.
Packit 90a5c9
 * 
Packit 90a5c9
 * For a connection level switch (r == NULL), the handler must on return
Packit 90a5c9
 * leave the conn_rec in a state suitable for processing the switched
Packit 90a5c9
 * protocol, e.g. correct filters in place.
Packit 90a5c9
 *
Packit 90a5c9
 * For a request triggered switch (r != NULL), the protocol switch is done
Packit 90a5c9
 * before the response is sent out. When switching from "http/1.1" via Upgrade
Packit 90a5c9
 * header, the 101 intermediate response will have been sent. The
Packit 90a5c9
 * hook needs then to process the connection until it can be closed. Which
Packit 90a5c9
 * the server will enforce on hook return.
Packit 90a5c9
 * Any error the hook might encounter must already be sent by the hook itself
Packit 90a5c9
 * to the client in whatever form the new protocol requires.
Packit 90a5c9
 *
Packit 90a5c9
 * @param c The current connection
Packit 90a5c9
 * @param r The current request or NULL
Packit 90a5c9
 * @param s The server/virtual host selected
Packit 90a5c9
 * @param choices A list of protocol identifiers, normally the clients whishes
Packit 90a5c9
 * @param proposals the list of protocol identifiers proposed by the hooks
Packit 90a5c9
 * @return OK or DECLINED
Packit 90a5c9
 * @bug This API or implementation and order of operations should be considered
Packit 90a5c9
 * experimental and will continue to evolve in future 2.4 releases, with
Packit 90a5c9
 * a corresponding minor module magic number (MMN) bump to indicate the
Packit 90a5c9
 * API revision level.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE_HOOK(int,protocol_switch,(conn_rec *c, request_rec *r,
Packit 90a5c9
                                     server_rec *s,
Packit 90a5c9
                                     const char *protocol))
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Return the protocol used on the connection. Modules implementing
Packit 90a5c9
 * protocol switching must register here and return the correct protocol
Packit 90a5c9
 * identifier for connections they switched.
Packit 90a5c9
 *
Packit 90a5c9
 * To find out the protocol for the current connection, better call
Packit 90a5c9
 * @see ap_get_protocol which internally uses this hook.
Packit 90a5c9
 *
Packit 90a5c9
 * @param c The current connection
Packit 90a5c9
 * @return The identifier of the protocol in place or NULL
Packit 90a5c9
 * @bug This API or implementation and order of operations should be considered
Packit 90a5c9
 * experimental and will continue to evolve in future 2.4 releases, with
Packit 90a5c9
 * a corresponding minor module magic number (MMN) bump to indicate the
Packit 90a5c9
 * API revision level.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE_HOOK(const char *,protocol_get,(const conn_rec *c))
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Get the protocols that the connection and optional request may
Packit 90a5c9
 * upgrade to - besides the protocol currently active on the connection. These
Packit 90a5c9
 * values may be used to announce to a client what choices it has.
Packit 90a5c9
 *
Packit 90a5c9
 * If report_all == 0, only protocols more preferable than the one currently
Packit 90a5c9
 * being used, are reported. Otherwise, all available protocols beside the
Packit 90a5c9
 * current one are being reported.
Packit 90a5c9
 *
Packit 90a5c9
 * @param c The current connection
Packit 90a5c9
 * @param r The current request or NULL
Packit 90a5c9
 * @param s The server/virtual host selected or NULL
Packit 90a5c9
 * @param report_all include also protocols less preferred than the current one
Packit 90a5c9
 * @param pupgrades on return, possible protocols to upgrade to in descending order 
Packit 90a5c9
 *                 of preference. Maybe NULL if none are available.    
Packit 90a5c9
 * @bug This API or implementation and order of operations should be considered
Packit 90a5c9
 * experimental and will continue to evolve in future 2.4 releases, with
Packit 90a5c9
 * a corresponding minor module magic number (MMN) bump to indicate the
Packit 90a5c9
 * API revision level.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_status_t) ap_get_protocol_upgrades(conn_rec *c, request_rec *r, 
Packit 90a5c9
                                                  server_rec *s, int report_all, 
Packit 90a5c9
                                                  const apr_array_header_t **pupgrades);
Packit 90a5c9
                                                  
Packit 90a5c9
/**
Packit 90a5c9
 * Select a protocol for the given connection and optional request. Will return
Packit 90a5c9
 * the protocol identifier selected which may be the protocol already in place
Packit 90a5c9
 * on the connection. The selected protocol will be NULL if non of the given
Packit 90a5c9
 * choices could be agreed upon (e.g. no proposal as made).
Packit 90a5c9
 *
Packit 90a5c9
 * A special case is where the choices itself is NULL (instead of empty). In
Packit 90a5c9
 * this case there are no restrictions imposed on protocol selection.
Packit 90a5c9
 *
Packit 90a5c9
 * @param c The current connection
Packit 90a5c9
 * @param r The current request or NULL
Packit 90a5c9
 * @param s The server/virtual host selected
Packit 90a5c9
 * @param choices A list of protocol identifiers, normally the clients whishes
Packit 90a5c9
 * @return The selected protocol or NULL if no protocol could be agreed upon
Packit 90a5c9
 * @bug This API or implementation and order of operations should be considered
Packit 90a5c9
 * experimental and will continue to evolve in future 2.4 releases, with
Packit 90a5c9
 * a corresponding minor module magic number (MMN) bump to indicate the
Packit 90a5c9
 * API revision level.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(const char *) ap_select_protocol(conn_rec *c, request_rec *r, 
Packit 90a5c9
                                            server_rec *s,
Packit 90a5c9
                                            const apr_array_header_t *choices);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Perform the actual protocol switch. The protocol given must have been
Packit 90a5c9
 * selected before on the very same connection and request pair.
Packit 90a5c9
 *
Packit 90a5c9
 * @param c The current connection
Packit 90a5c9
 * @param r The current request or NULL
Packit 90a5c9
 * @param s The server/virtual host selected
Packit 90a5c9
 * @param protocol the protocol to switch to
Packit 90a5c9
 * @return APR_SUCCESS, if caller may continue processing as usual
Packit 90a5c9
 *         APR_EOF,     if caller needs to stop processing the connection
Packit 90a5c9
 *         APR_EINVAL,  if the protocol is already in place
Packit 90a5c9
 *         APR_NOTIMPL, if no module performed the switch
Packit 90a5c9
 *         Other errors where appropriate
Packit 90a5c9
 * @bug This API or implementation and order of operations should be considered
Packit 90a5c9
 * experimental and will continue to evolve in future 2.4 releases, with
Packit 90a5c9
 * a corresponding minor module magic number (MMN) bump to indicate the
Packit 90a5c9
 * API revision level.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_status_t) ap_switch_protocol(conn_rec *c, request_rec *r, 
Packit 90a5c9
                                            server_rec *s,
Packit 90a5c9
                                            const char *protocol);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Call the protocol_get hook to determine the protocol currently in use
Packit 90a5c9
 * for the given connection.
Packit 90a5c9
 *
Packit 90a5c9
 * Unless another protocol has been switch to, will default to
Packit 90a5c9
 * @see AP_PROTOCOL_HTTP1 and modules implementing a  new protocol must
Packit 90a5c9
 * report a switched connection via the protocol_get hook.
Packit 90a5c9
 *
Packit 90a5c9
 * @param c The connection to determine the protocol for
Packit 90a5c9
 * @return the protocol in use, never NULL
Packit 90a5c9
 * @bug This API or implementation and order of operations should be considered
Packit 90a5c9
 * experimental and will continue to evolve in future 2.4 releases, with
Packit 90a5c9
 * a corresponding minor module magic number (MMN) bump to indicate the
Packit 90a5c9
 * API revision level.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(const char *) ap_get_protocol(conn_rec *c);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Check if the given protocol is an allowed choice on the given
Packit 90a5c9
 * combination of connection, request and server. 
Packit 90a5c9
 *
Packit 90a5c9
 * When server is NULL, it is taken from request_rec, unless
Packit 90a5c9
 * request_rec is NULL. Then it is taken from the connection base
Packit 90a5c9
 * server.
Packit 90a5c9
 *
Packit 90a5c9
 * @param c The current connection
Packit 90a5c9
 * @param r The current request or NULL
Packit 90a5c9
 * @param s The server/virtual host selected or NULL
Packit 90a5c9
 * @param protocol the protocol to switch to
Packit 90a5c9
 * @return != 0 iff protocol is allowed
Packit 90a5c9
 * @bug This API or implementation and order of operations should be considered
Packit 90a5c9
 * experimental and will continue to evolve in future 2.4 releases, with
Packit 90a5c9
 * a corresponding minor module magic number (MMN) bump to indicate the
Packit 90a5c9
 * API revision level.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(int) ap_is_allowed_protocol(conn_rec *c, request_rec *r,
Packit 90a5c9
                                       server_rec *s, const char *protocol);
Packit 90a5c9
Packit 90a5c9
/** @see ap_bucket_type_error */
Packit 90a5c9
typedef struct ap_bucket_error ap_bucket_error;
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * @struct ap_bucket_error
Packit 90a5c9
 * @brief  A bucket referring to an HTTP error
Packit 90a5c9
 *
Packit 90a5c9
 * This bucket can be passed down the filter stack to indicate that an
Packit 90a5c9
 * HTTP error occurred while running a filter.  In order for this bucket
Packit 90a5c9
 * to be used successfully, it MUST be sent as the first bucket in the
Packit 90a5c9
 * first brigade to be sent from a given filter.
Packit 90a5c9
 */
Packit 90a5c9
struct ap_bucket_error {
Packit 90a5c9
    /** Number of buckets using this memory */
Packit 90a5c9
    apr_bucket_refcount refcount;
Packit 90a5c9
    /** The error code */
Packit 90a5c9
    int status;
Packit 90a5c9
    /** The error string */
Packit 90a5c9
    const char    *data;
Packit 90a5c9
};
Packit 90a5c9
Packit 90a5c9
/** @see ap_bucket_type_error */
Packit 90a5c9
AP_DECLARE_DATA extern const apr_bucket_type_t ap_bucket_type_error;
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Determine if a bucket is an error bucket
Packit 90a5c9
 * @param e The bucket to inspect
Packit 90a5c9
 * @return true or false
Packit 90a5c9
 */
Packit 90a5c9
#define AP_BUCKET_IS_ERROR(e)         (e->type == &ap_bucket_type_error)
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Make the bucket passed in an error bucket
Packit 90a5c9
 * @param b The bucket to make into an error bucket
Packit 90a5c9
 * @param error The HTTP error code to put in the bucket.
Packit 90a5c9
 * @param buf An optional error string to put in the bucket.
Packit 90a5c9
 * @param p A pool to allocate out of.
Packit 90a5c9
 * @return The new bucket, or NULL if allocation failed
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_bucket *) ap_bucket_error_make(apr_bucket *b, int error,
Packit 90a5c9
                const char *buf, apr_pool_t *p);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Create a bucket referring to an HTTP error.
Packit 90a5c9
 * @param error The HTTP error code to put in the bucket.
Packit 90a5c9
 * @param buf An optional error string to put in the bucket.
Packit 90a5c9
 * @param p A pool to allocate the error string out of.
Packit 90a5c9
 * @param list The bucket allocator from which to allocate the bucket
Packit 90a5c9
 * @return The new bucket, or NULL if allocation failed
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_bucket *) ap_bucket_error_create(int error, const char *buf,
Packit 90a5c9
                                                apr_pool_t *p,
Packit 90a5c9
                                                apr_bucket_alloc_t *list);
Packit 90a5c9
Packit 90a5c9
AP_DECLARE_NONSTD(apr_status_t) ap_byterange_filter(ap_filter_t *f, apr_bucket_brigade *b);
Packit 90a5c9
AP_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, apr_bucket_brigade *b);
Packit 90a5c9
AP_DECLARE_NONSTD(apr_status_t) ap_content_length_filter(ap_filter_t *,
Packit 90a5c9
                                                              apr_bucket_brigade *);
Packit 90a5c9
AP_DECLARE_NONSTD(apr_status_t) ap_old_write_filter(ap_filter_t *f, apr_bucket_brigade *b);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Sett up the protocol fields for subsidiary requests
Packit 90a5c9
 * @param rnew New Sub Request
Packit 90a5c9
 * @param r current request
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_set_sub_req_protocol(request_rec *rnew, const request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * A wrapup function to keep the internal accounting straight.
Packit 90a5c9
 * Indicates that there is no more content coming.
Packit 90a5c9
 * @param sub_r Subrequest that is now compete
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_finalize_sub_req_protocol(request_rec *sub_r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Send an interim (HTTP 1xx) response immediately.
Packit 90a5c9
 * @param r The request
Packit 90a5c9
 * @param send_headers Whether to send&clear headers in r->headers_out
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_send_interim_response(request_rec *r, int send_headers);
Packit 90a5c9
Packit 90a5c9
#ifdef __cplusplus
Packit 90a5c9
}
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#endif  /* !APACHE_HTTP_PROTOCOL_H */
Packit 90a5c9
/** @} */