http_protocol.h revision 5265b551dc32f2618e7d72e2744dde6cacf6fb9a
2d2eda71267231c2526be701fe655db125852c1ffielding/* ====================================================================
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * The Apache Software License, Version 1.1
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * Copyright (c) 2000 The Apache Software Foundation. All rights
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * reserved.
2d2eda71267231c2526be701fe655db125852c1ffielding * Redistribution and use in source and binary forms, with or without
2d2eda71267231c2526be701fe655db125852c1ffielding * modification, are permitted provided that the following conditions
2d2eda71267231c2526be701fe655db125852c1ffielding * 1. Redistributions of source code must retain the above copyright
2d2eda71267231c2526be701fe655db125852c1ffielding * notice, this list of conditions and the following disclaimer.
2d2eda71267231c2526be701fe655db125852c1ffielding * 2. Redistributions in binary form must reproduce the above copyright
2d2eda71267231c2526be701fe655db125852c1ffielding * notice, this list of conditions and the following disclaimer in
2d2eda71267231c2526be701fe655db125852c1ffielding * the documentation and/or other materials provided with the
2d2eda71267231c2526be701fe655db125852c1ffielding * distribution.
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * 3. The end-user documentation included with the redistribution,
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * if any, must include the following acknowledgment:
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * "This product includes software developed by the
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * Apache Software Foundation (http://www.apache.org/)."
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * Alternately, this acknowledgment may appear in the software itself,
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * if and wherever such third-party acknowledgments normally appear.
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * 4. The names "Apache" and "Apache Software Foundation" must
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * not be used to endorse or promote products derived from this
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * software without prior written permission. For written
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * permission, please contact apache@apache.org.
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * 5. Products derived from this software may not be called "Apache",
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * nor may "Apache" appear in their name, without prior written
64185f9824e42f21ca7b9ae6c004484215c031a7rbb * permission of the Apache Software Foundation.
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
2d2eda71267231c2526be701fe655db125852c1ffielding * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * SUCH DAMAGE.
2d2eda71267231c2526be701fe655db125852c1ffielding * ====================================================================
2d2eda71267231c2526be701fe655db125852c1ffielding * This software consists of voluntary contributions made by many
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * individuals on behalf of the Apache Software Foundation. For more
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * information on the Apache Software Foundation, please see
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * Portions of this software are based upon public domain software
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * originally written at the National Center for Supercomputing Applications,
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * University of Illinois, Urbana-Champaign.
fd0edaa8e3d4dd67d0604ccef2e96b071db96643fieldingextern "C" {
2d2eda71267231c2526be701fe655db125852c1ffielding * Prototypes for routines which either talk directly back to the user,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * or control the ones that eventually do.
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/* Read a request and fill in the fields. */
2d2eda71267231c2526be701fe655db125852c1ffielding/* Send a single HTTP header field */
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAPI_EXPORT_NONSTD(int) ap_send_header_field(request_rec *r, const char *fieldname,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb const char *fieldval);
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/* Send the minimal part of an HTTP response header... but modules should be
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * very careful about using this, and should prefer ap_send_http_header().
2d2eda71267231c2526be701fe655db125852c1ffielding * Much of the HTTP/1.1 implementation correctness depends on code in
2d2eda71267231c2526be701fe655db125852c1ffielding * ap_send_http_header().
25df3685b2db529aee4482fab28f87dd282681f6rbb/* Send the Status-Line and header fields for HTTP response */
25df3685b2db529aee4482fab28f87dd282681f6rbb/* Send the response to special method requests */
bfb62a96023822c56c9120e4ee627d4091cc59c2rbb/* Finish up stuff after a request */
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAPI_EXPORT(void) ap_finalize_request_protocol(request_rec *r);
3d96ee83babeec32482c9082c9426340cee8c44dwrowe/* Send error back to client... last arg indicates error status in case
2d2eda71267231c2526be701fe655db125852c1ffielding * we get an error in the process of trying to deal with an ErrorDocument
c9b85d26144df8738f9635ad72381232bb5f1e9brbb * to handle some other error. In that case, we print the default report
b7e71d1823387b9354a1105c6b5837b0715b8d8etrawick * for the first thing that went wrong, and more briefly report on the
d5df46b7972c0c4a5ca0ba5068e238f6053c2e6ftrawick * problem with the ErrorDocument.
2d2eda71267231c2526be701fe655db125852c1ffieldingAPI_EXPORT(void) ap_send_error_response(request_rec *r, int recursive_error);
3d96ee83babeec32482c9082c9426340cee8c44dwrowe/* Set last modified header line from the lastmod date of the associated file.
2d2eda71267231c2526be701fe655db125852c1ffielding * Also, set content length.
bfb62a96023822c56c9120e4ee627d4091cc59c2rbb * May return an error status, typically HTTP_NOT_MODIFIED (that when the
bfb62a96023822c56c9120e4ee627d4091cc59c2rbb * permit_cache argument is set to one).
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAPI_EXPORT(int) ap_set_content_length(request_rec *r, long length);
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAPI_EXPORT(ap_time_t) ap_rationalize_mtime(request_rec *r, ap_time_t mtime);
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAPI_EXPORT(char *) ap_make_etag(request_rec *r, int force_weak);
2d2eda71267231c2526be701fe655db125852c1ffieldingAPI_EXPORT(void) ap_set_last_modified(request_rec *r);
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/* Other ways to send stuff at the client. All of these keep track
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * of bytes_sent automatically. This indirection is intended to make
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * it a little more painless to slide things like HTTP-NG packetization
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * underneath the main body of the code later. In the meantime, it lets
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * us centralize a bit of accounting (bytes_sent).
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * These also return the number of bytes written by the call.
2d2eda71267231c2526be701fe655db125852c1ffielding * They should only be called with a timeout registered, for obvious reaasons.
3d96ee83babeec32482c9082c9426340cee8c44dwrowe * (Ditto the send_header stuff).
2d2eda71267231c2526be701fe655db125852c1ffieldingAPI_EXPORT(ap_status_t) ap_send_fd(ap_file_t *fd, request_rec *r, ap_off_t offset,
2d2eda71267231c2526be701fe655db125852c1ffieldingAPI_EXPORT(long) ap_send_fb(BUFF *f, request_rec *r);
2d2eda71267231c2526be701fe655db125852c1ffieldingAPI_EXPORT(long) ap_send_fb_length(BUFF *f, request_rec *r, long length);
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAPI_EXPORT(size_t) ap_send_mmap(ap_mmap_t *mm, request_rec *r, size_t offset,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/* Hmmm... could macrofy these for now, and maybe forever, though the
7bdef86e15d47d16dcbe7a5611683191774bd5fbgstein * definitions of the macros would get a whole lot hairier.
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAPI_EXPORT(int) ap_rputs(const char *str, request_rec *r);
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAPI_EXPORT(int) ap_rwrite(const void *buf, int nbyte, request_rec *r);
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAPI_EXPORT(int) ap_vrprintf(request_rec *r, const char *fmt, va_list vlist);
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAPI_EXPORT_NONSTD(int) ap_rprintf(request_rec *r, const char *fmt,...)
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * Index used in custom_responses array for a specific error code
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * (only use outside protocol.c is in getting them configured).
3d96ee83babeec32482c9082c9426340cee8c44dwrowe * Return the Status-Line for a given status code (excluding the
7bdef86e15d47d16dcbe7a5611683191774bd5fbgstein * HTTP-Version field). If an invalid or unknown status code is
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * passed, "500 Internal Server Error" will be returned.
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/* Reading a block of data from the client connection (e.g., POST arg) */
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAPI_EXPORT(int) ap_setup_client_block(request_rec *r, int read_policy);
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAPI_EXPORT(long) ap_get_client_block(request_rec *r, char *buffer, int bufsiz);
3d96ee83babeec32482c9082c9426340cee8c44dwroweAPI_EXPORT(int) ap_discard_request_body(request_rec *r);
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/* Sending a byterange */
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAPI_EXPORT(int) ap_each_byterange(request_rec *r, ap_off_t *offset,
7bdef86e15d47d16dcbe7a5611683191774bd5fbgstein/* Support for the Basic authentication protocol. Note that there's
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * nothing that prevents these from being in mod_auth.c, except that other
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * modules which wanted to provide their own variants on finding users and
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * passwords for Basic auth (a fairly common request) would then require
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * mod_auth to be loaded or they wouldn't work.
3d96ee83babeec32482c9082c9426340cee8c44dwrowe * get_basic_auth_pw returns 0 (OK) if it set the 'pw' argument (and assured
7bdef86e15d47d16dcbe7a5611683191774bd5fbgstein * a correct value in r->connection->user); otherwise it returns an error
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * code, either HTTP_INTERNAL_SERVER_ERROR if things are really confused,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * HTTP_UNAUTHORIZED if no authentication at all seemed to be in use, or
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * DECLINED if there was authentication but it wasn't Basic (in which case,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * the caller should presumably decline as well).
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * note_basic_auth_failure arranges for the right stuff to be scribbled on
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * the HTTP return so that the client knows how to authenticate itself the
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * next time. As does note_digest_auth_failure for Digest auth.
2d2eda71267231c2526be701fe655db125852c1ffielding * note_auth_failure does the same thing, but will call the correct one
2d2eda71267231c2526be701fe655db125852c1ffielding * based on the authentication type in use.
2d2eda71267231c2526be701fe655db125852c1ffieldingAPI_EXPORT(void) ap_note_auth_failure(request_rec *r);
2d2eda71267231c2526be701fe655db125852c1ffieldingAPI_EXPORT(void) ap_note_basic_auth_failure(request_rec *r);
2d2eda71267231c2526be701fe655db125852c1ffieldingAPI_EXPORT(void) ap_note_digest_auth_failure(request_rec *r);
2d2eda71267231c2526be701fe655db125852c1ffieldingAPI_EXPORT(int) ap_get_basic_auth_pw(request_rec *r, const char **pw);
2d2eda71267231c2526be701fe655db125852c1ffielding * Setting up the protocol fields for subsidiary requests...
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * Also, a wrapup function to keep the internal accounting straight.
61fd0cab072a05b855cbef9c585702401ac5ae29rbbvoid ap_set_sub_req_protocol(request_rec *rnew, const request_rec *r);
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/* This is also useful for putting sub_reqs and internal_redirects together */
61fd0cab072a05b855cbef9c585702401ac5ae29rbbCORE_EXPORT(void) ap_parse_uri(request_rec *r, const char *uri);
3d96ee83babeec32482c9082c9426340cee8c44dwrowe/* Get the method number associated with the given string, assumed to
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm * contain an HTTP method. Returns M_INVALID if not recognized.
61fd0cab072a05b855cbef9c585702401ac5ae29rbb /* Hooks */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * post_read_request --- run right after read_request or internal_redirect,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * and not run during any subrequests.
3d96ee83babeec32482c9082c9426340cee8c44dwroweAP_DECLARE_HOOK(const char *,http_method,(const request_rec *))
2d2eda71267231c2526be701fe655db125852c1ffieldingAP_DECLARE_HOOK(unsigned short,default_port,(const request_rec *))
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar#endif /* !APACHE_HTTP_PROTOCOL_H */