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