]> granicus.if.org Git - apache/blob - include/http_protocol.h
Update our copyright for this year.
[apache] / include / http_protocol.h
1 /* ====================================================================
2  * The Apache Software License, Version 1.1
3  *
4  * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
5  * reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in
16  *    the documentation and/or other materials provided with the
17  *    distribution.
18  *
19  * 3. The end-user documentation included with the redistribution,
20  *    if any, must include the following acknowledgment:
21  *       "This product includes software developed by the
22  *        Apache Software Foundation (http://www.apache.org/)."
23  *    Alternately, this acknowledgment may appear in the software itself,
24  *    if and wherever such third-party acknowledgments normally appear.
25  *
26  * 4. The names "Apache" and "Apache Software Foundation" must
27  *    not be used to endorse or promote products derived from this
28  *    software without prior written permission. For written
29  *    permission, please contact apache@apache.org.
30  *
31  * 5. Products derived from this software may not be called "Apache",
32  *    nor may "Apache" appear in their name, without prior written
33  *    permission of the Apache Software Foundation.
34  *
35  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46  * SUCH DAMAGE.
47  * ====================================================================
48  *
49  * This software consists of voluntary contributions made by many
50  * individuals on behalf of the Apache Software Foundation.  For more
51  * information on the Apache Software Foundation, please see
52  * <http://www.apache.org/>.
53  *
54  * Portions of this software are based upon public domain software
55  * originally written at the National Center for Supercomputing Applications,
56  * University of Illinois, Urbana-Champaign.
57  */
58
59 #ifndef APACHE_HTTP_PROTOCOL_H
60 #define APACHE_HTTP_PROTOCOL_H
61
62 #include "httpd.h"
63 #include "apr_hooks.h"
64 #include "apr_portable.h"
65 #include "apr_mmap.h"
66 #include "apr_buckets.h"
67 #include "util_filter.h"
68
69 #ifdef __cplusplus
70 extern "C" {
71 #endif
72
73 /**
74  * @package HTTP protocol handling
75  */
76
77 /* This is an optimization.  We keep a record of the filter_rec that
78  * stores the old_write filter, so that we can avoid strcmp's later.
79  */
80 AP_DECLARE_DATA extern ap_filter_rec_t *ap_old_write_func;
81
82 /*
83  * Prototypes for routines which either talk directly back to the user,
84  * or control the ones that eventually do.
85  */
86
87 /**
88  * Read a request and fill in the fields.
89  * @param c The current connection
90  * @return The new request_rec
91  */ 
92 request_rec *ap_read_request(conn_rec *c);
93
94 /* Finish up stuff after a request */
95
96 /**
97  * Called at completion of sending the response.  It sends the terminating
98  * protocol information.
99  * @param r The current request
100  * @deffunc void ap_finalize_request_protocol(request_rec *r)
101  */
102 AP_DECLARE(void) ap_finalize_request_protocol(request_rec *r);
103
104 /**
105  * Send error back to client.
106  * @param r The current request
107  * @param recursive_error last arg indicates error status in case we get 
108  *      an error in the process of trying to deal with an ErrorDocument 
109  *      to handle some other error.  In that case, we print the default 
110  *      report for the first thing that went wrong, and more briefly report 
111  *      on the problem with the ErrorDocument.
112  * @deffunc void ap_send_error_response(request_rec *r, int recursive_error)
113  */
114 AP_DECLARE(void) ap_send_error_response(request_rec *r, int recursive_error);
115
116 /* Set last modified header line from the lastmod date of the associated file.
117  * Also, set content length.
118  *
119  * May return an error status, typically HTTP_NOT_MODIFIED (that when the
120  * permit_cache argument is set to one).
121  */
122
123 /**
124  * Set the content length for this request
125  * @param r The current request
126  * @param length The new content length
127  * @deffunc void ap_set_content_length(request_rec *r, apr_off_t length)
128  */
129 AP_DECLARE(void) ap_set_content_length(request_rec *r, apr_off_t length);
130
131 /**
132  * Set the keepalive status for this request
133  * @param r The current request
134  * @return 1 if keepalive can be set, 0 otherwise
135  * @deffunc int ap_set_keepalive(request_rec *r)
136  */
137 AP_DECLARE(int) ap_set_keepalive(request_rec *r);
138
139 /**
140  * Return the latest rational time from a request/mtime pair.  Mtime is 
141  * returned unless it's in the future, in which case we return the current time.
142  * @param r The current request
143  * @param mtime The last modified time
144  * @return the latest rational time.
145  * @deffunc apr_time_t ap_rationalize_mtime(request_rec *r, apr_time_t mtime)
146  */
147 AP_DECLARE(apr_time_t) ap_rationalize_mtime(request_rec *r, apr_time_t mtime);
148
149 /**
150  * Build the content-type that should be sent to the client from the
151  * content-type specified.  The following rules are followed:
152  *    - if type is NULL, type is set to ap_default_type(r)
153  *    - if charset adding is disabled, stop processing and return type.
154  *    - then, if there are no parameters on type, add the default charset
155  *    - return type
156  * @param r The current request
157  * @return The content-type
158  * @deffunc const char *ap_make_content_type(request_rec *r, const char *type);
159  */ 
160 AP_DECLARE(const char *) ap_make_content_type(request_rec *r, const char *type);
161
162 /**
163  * Construct an entity tag from the resource information.  If it's a real
164  * file, build in some of the file characteristics.
165  * @param r The current request
166  * @param force_weak Force the entity tag to be weak - it could be modified
167  *                   again in as short an interval.
168  * @return The entity tag
169  * @deffunc char *ap_make_etag(request_rec *r, int force_weak)
170  */ 
171 AP_DECLARE(char *) ap_make_etag(request_rec *r, int force_weak);
172
173 /**
174  * Set the E-tag outgoing header
175  * @param The current request
176  * @deffunc void ap_set_etag(request_rec *r)
177  */
178 AP_DECLARE(void) ap_set_etag(request_rec *r);
179
180 /**
181  * Set the last modified time for the file being sent
182  * @param r The current request
183  * @deffunc void ap_set_last_modified(request_rec *r)
184  */
185 AP_DECLARE(void) ap_set_last_modified(request_rec *r);
186
187 /**
188  * Implements condition GET rules for HTTP/1.1 specification.  This function
189  * inspects the client headers and determines if the response fulfills 
190  * the requirements specified.
191  * @param r The current request
192  * @return 1 if the response fulfills the condition GET rules, 0 otherwise
193  * @deffunc int ap_meets_conditions(request_rec *r)
194  */
195 AP_DECLARE(int) ap_meets_conditions(request_rec *r);
196
197 /* Other ways to send stuff at the client.  All of these keep track
198  * of bytes_sent automatically.  This indirection is intended to make
199  * it a little more painless to slide things like HTTP-NG packetization
200  * underneath the main body of the code later.  In the meantime, it lets
201  * us centralize a bit of accounting (bytes_sent).
202  *
203  * These also return the number of bytes written by the call.
204  * They should only be called with a timeout registered, for obvious reaasons.
205  * (Ditto the send_header stuff).
206  */
207
208 /**
209  * Send an entire file to the client, using sendfile if supported by the 
210  * current platform
211  * @param fd The file to send.
212  * @param r The current request
213  * @param offset Offset into the file to start sending.
214  * @param length Amount of data to send
215  * @param nbytes Amount of data actually sent
216  * @deffunc apr_status_t ap_send_fd(apr_file_t *fd, request_rec *r, apr_off_t offset, apr_size_t length, apr_size_t *nbytes);
217  */
218 AP_DECLARE(apr_status_t) ap_send_fd(apr_file_t *fd, request_rec *r, apr_off_t offset, 
219                                    apr_size_t length, apr_size_t *nbytes);
220
221 #if APR_HAS_MMAP
222 /**
223  * Send an MMAP'ed file to the client
224  * @param mm The MMAP'ed file to send
225  * @param r The current request
226  * @param offset The offset into the MMAP to start sending
227  * @param length The amount of data to send
228  * @return The number of bytes sent
229  * @deffunc size_t ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset, size_t length)
230  */
231 AP_DECLARE(size_t) ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset,
232                              size_t length);
233 #endif
234
235 /* The index of the first bit field that is used to index into a limit
236  * bitmask. M_INVALID + 1 to METHOD_NUMBER_LAST.
237  */
238 #define METHOD_NUMBER_FIRST M_INVALID + 1
239
240 /* The max method number. Method numbers are used to shift bitmasks,
241  * so this cannot exceed 63, and all bits high is equal to -1, which is a
242  * special flag, so the last bit used has index 62.
243  */
244 #define METHOD_NUMBER_LAST  62
245
246 /**
247  * Register a new request method, and return the offset that will be
248  * associated with that method.
249  *
250  * @param p        The pool to create registered method numbers from.
251  * @param methname The name of the new method to register.
252  * @return         Ab int value representing an offset into a bitmask.
253  */
254 AP_DECLARE(int) ap_method_register(apr_pool_t *p, const char *methname);
255
256 /**
257  * Initialize the method_registry and allocate memory for it.
258  *
259  * @param p Pool to allocate memory for the registry from.
260  */
261 AP_DECLARE(void) ap_method_registry_init(apr_pool_t *p);
262
263 /*
264  * This is a convenience macro to ease with checking a mask
265  * against a method name.
266  */
267 #define AP_METHOD_CHECK_ALLOWED(mask, methname) \
268     ((mask) & (AP_METHOD_BIT << ap_method_number_of((methname))))
269
270 /**
271  * Create a new method list with the specified number of preallocated
272  * slots for extension methods.
273  *
274  * @param   p       Pointer to a pool in which the structure should be
275  *                  allocated.
276  * @param   nelts   Number of preallocated extension slots
277  * @return  Pointer to the newly created structure.
278  * @deffunc ap_method_list_t ap_make_method_list(apr_pool_t *p, int nelts)
279  */
280 AP_DECLARE(ap_method_list_t *) ap_make_method_list(apr_pool_t *p, int nelts);
281 AP_DECLARE(void) ap_copy_method_list(ap_method_list_t *dest,
282                                      ap_method_list_t *src);
283 AP_DECLARE_NONSTD(void) ap_method_list_do(int (*comp) (void *urec, const char *mname,
284                                                        int mnum),
285                                           void *rec,
286                                           const ap_method_list_t *ml, ...);
287 AP_DECLARE(void) ap_method_list_vdo(int (*comp) (void *urec, const char *mname,
288                                                  int mnum),
289                                     void *rec, const ap_method_list_t *ml,
290                                     va_list vp);
291 /**
292  * Search for an HTTP method name in an ap_method_list_t structure, and
293  * return true if found.
294  *
295  * @param   method  String containing the name of the method to check.
296  * @param   l       Pointer to a method list, such as cmd->methods_limited.
297  * @return  1 if method is in the list, otherwise 0
298  * @deffunc int ap_method_in_list(const char *method, ap_method_list_t *l)
299  */
300 AP_DECLARE(int) ap_method_in_list(ap_method_list_t *l, const char *method);
301
302 /**
303  * Add an HTTP method name to an ap_method_list_t structure if it isn't
304  * already listed.
305  *
306  * @param   method  String containing the name of the method to check.
307  * @param   l       Pointer to a method list, such as cmd->methods_limited.
308  * @return  None.
309  * @deffunc void ap_method_in_list(ap_method_list_t *l, const char *method)
310  */
311 AP_DECLARE(void) ap_method_list_add(ap_method_list_t *l, const char *method);
312     
313 /**
314  * Remove an HTTP method name from an ap_method_list_t structure.
315  *
316  * @param   l       Pointer to a method list, such as cmd->methods_limited.
317  * @param   method  String containing the name of the method to remove.
318  * @return  None.
319  * @deffunc void ap_method_list_remove(ap_method_list_t *l, const char *method)
320  */
321 AP_DECLARE(void) ap_method_list_remove(ap_method_list_t *l,
322                                        const char *method);
323
324 /**
325  * Reset a method list to be completely empty.
326  *
327  * @param   l       Pointer to a method list, such as cmd->methods_limited.
328  * @return  None.
329  * @deffunc void ap_clear_method_list(ap_method_list_t *l)
330  */
331 AP_DECLARE(void) ap_clear_method_list(ap_method_list_t *l);
332     
333 /* Hmmm... could macrofy these for now, and maybe forever, though the
334  * definitions of the macros would get a whole lot hairier.
335  */
336
337 /**
338  * Output one character for this request
339  * @param c the character to output
340  * @param r the current request
341  * @return The number of bytes sent
342  * @deffunc int ap_rputc(int c, request_rec *r)
343  */
344 AP_DECLARE(int) ap_rputc(int c, request_rec *r);
345
346 /**
347  * Output a string for the current request
348  * @param str The string to output
349  * @param r The current request
350  * @return The number of bytes sent
351  * @deffunc int ap_rputs(const char *str, request_rec *r)
352  */
353 AP_DECLARE(int) ap_rputs(const char *str, request_rec *r);
354
355 /**
356  * Write a buffer for the current request
357  * @param buf The buffer to write
358  * @param nbyte The number of bytes to send from the buffer
359  * @param r The current request
360  * @return The number of bytes sent
361  * @deffunc int ap_rwrite(const void *buf, int nbyte, request_rec *r)
362  */
363 AP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r);
364
365 /**
366  * Write an unspecified number of strings to the request
367  * @param r The current request
368  * @param ... The strings to write
369  * @return The number of bytes sent
370  * @deffunc int ap_rvputs(request_rec *r, ...)
371  */
372 AP_DECLARE_NONSTD(int) ap_rvputs(request_rec *r,...);
373
374 /**
375  * Output data to the client in a printf format
376  * @param r The current request
377  * @param fmt The format string
378  * @param vlist The arguments to use to fill out the format string
379  * @return The number of bytes sent
380  * @deffunc int ap_vrprintf(request_rec *r, const char *fmt, va_list vlist)
381  */
382 AP_DECLARE(int) ap_vrprintf(request_rec *r, const char *fmt, va_list vlist);
383
384 /**
385  * Output data to the client in a printf format
386  * @param r The current request
387  * @param fmt The format string
388  * @param ... The arguments to use to fill out the format string
389  * @return The number of bytes sent
390  * @deffunc int ap_rprintf(request_rec *r, const char *fmt, ...)
391  */
392 AP_DECLARE_NONSTD(int) ap_rprintf(request_rec *r, const char *fmt,...)
393                                 __attribute__((format(printf,2,3)));
394 /**
395  * Flush all of the data for the current request to the client
396  * @param r The current request
397  * @return The number of bytes sent
398  * @deffunc int ap_rflush(request_rec *r)
399  */
400 AP_DECLARE(int) ap_rflush(request_rec *r);
401
402 /**
403  * Index used in custom_responses array for a specific error code
404  * (only use outside protocol.c is in getting them configured).
405  * @param status HTTP status code
406  * @return The index of the response
407  * @deffunc int ap_index_of_response(int status)
408  */
409 AP_DECLARE(int) ap_index_of_response(int status);
410
411 /** 
412  * Return the Status-Line for a given status code (excluding the
413  * HTTP-Version field). If an invalid or unknown status code is
414  * passed, "500 Internal Server Error" will be returned. 
415  * @param status The HTTP status code
416  * @return The Status-Line
417  * @deffunc const char *ap_get_status_line(int status)
418  */
419 AP_DECLARE(const char *) ap_get_status_line(int status);
420
421 /* Reading a block of data from the client connection (e.g., POST arg) */
422
423 /**
424  * Setup the client to allow Apache to read the request body.
425  * @param r The current request
426  * @param read_policy How the server should interpret a chunked 
427  *                    transfer-encoding.  One of: <pre>
428  *    REQUEST_NO_BODY          Send 413 error if message has any body
429  *    REQUEST_CHUNKED_ERROR    Send 411 error if body without Content-Length
430  *    REQUEST_CHUNKED_DECHUNK  If chunked, remove the chunks for me.
431  * </pre>
432  * @return either OK or an error code
433  * @deffunc int ap_setup_cleint_block(request_rec *r, int read_policy)
434  */
435 AP_DECLARE(int) ap_setup_client_block(request_rec *r, int read_policy);
436
437 /**
438  * Determine if the client has sent any data.  This also sends a 
439  * 100 Continue resposne to HTTP/1.1 clients, so modules should not be called
440  * until the module is ready to read content.
441  * @warning Never call this function more than once.
442  * @param r The current request
443  * @return 0 if there is no message to read, 1 otherwise
444  * @deffunc int ap_should_client_block(request_rec *r)
445  */
446 AP_DECLARE(int) ap_should_client_block(request_rec *r);
447
448 /**
449  * Call this in a loop.  It will put data into a buffer and return the length
450  * of the input block
451  * @param r The current request
452  * @param buffer The buffer in which to store the data
453  * @param bufsiz The size of the buffer
454  * @return Number of bytes inserted into the buffer.  When done reading, 0
455  *         if EOF, or -1 if there was an error
456  * @deffunc long ap_get_client_block(request_rec *r, char *buffer, apr_size_t bufsiz)
457  */
458 AP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer, apr_size_t bufsiz);
459
460 /**
461  * In HTTP/1.1, any method can have a body.  However, most GET handlers
462  * wouldn't know what to do with a request body if they received one.
463  * This helper routine tests for and reads any message body in the request,
464  * simply discarding whatever it receives.  We need to do this because
465  * failing to read the request body would cause it to be interpreted
466  * as the next request on a persistent connection.
467  * @param r The current request
468  * @return error status if request is malformed, OK otherwise 
469  * @deffunc int ap_discard_request_body(request_rec *r)
470  */
471 AP_DECLARE(int) ap_discard_request_body(request_rec *r);
472
473
474 /**
475  * Setup the output headers so that the client knows how to authenticate
476  * itself the next time, if an authentication request failed.  This function
477  * works for both basic and digest authentication
478  * @param r The current request
479  * @deffunc void ap_note_auth_failure(request_rec *r)
480  */ 
481 AP_DECLARE(void) ap_note_auth_failure(request_rec *r);
482
483 /**
484  * Setup the output headers so that the client knows how to authenticate
485  * itself the next time, if an authentication request failed.  This function
486  * works only for basic authentication
487  * @param r The current request
488  * @deffunc void ap_note_basic_auth_failure(request_rec *r)
489  */ 
490 AP_DECLARE(void) ap_note_basic_auth_failure(request_rec *r);
491
492 /**
493  * Setup the output headers so that the client knows how to authenticate
494  * itself the next time, if an authentication request failed.  This function
495  * works only for digest authentication
496  * @param r The current request
497  * @deffunc void ap_note_digest_auth_failure(request_rec *r)
498  */ 
499 AP_DECLARE(void) ap_note_digest_auth_failure(request_rec *r);
500
501 /**
502  * Get the password from the request headers
503  * @param r The current request
504  * @param pw The password as set in the headers
505  * @return 0 (OK) if it set the 'pw' argument (and assured
506  *         a correct value in r->connection->user); otherwise it returns 
507  *         an error code, either HTTP_INTERNAL_SERVER_ERROR if things are 
508  *         really confused, HTTP_UNAUTHORIZED if no authentication at all 
509  *         seemed to be in use, or DECLINED if there was authentication but 
510  *         it wasn't Basic (in which case, the caller should presumably 
511  *         decline as well).
512  * @deffunc int ap_get_basic_auth_pw(request_rec *r, const char **pw)
513  */
514 AP_DECLARE(int) ap_get_basic_auth_pw(request_rec *r, const char **pw);
515
516 /**
517  * parse_uri: break apart the uri
518  * @warning Side Effects: <pre>
519  *    - sets r->args to rest after '?' (or NULL if no '?')
520  *    - sets r->uri to request uri (without r->args part)
521  *    - sets r->hostname (if not set already) from request (scheme://host:port)
522  * </pre>
523  * @param r The current request
524  * @param uri The uri to break apart
525  * @deffunc void ap_parse_uri(request_rec *r, const char *uri)
526  */
527 AP_CORE_DECLARE(void) ap_parse_uri(request_rec *r, const char *uri);
528
529 /**
530  * Get the next line of input for the request
531  * @param s The buffer into which to read the line
532  * @param n The size of the buffer
533  * @param r The request
534  * @param fold Whether to merge continuation lines
535  * @return The length of the line, if successful
536  *         n, if the line is too big to fit in the buffer
537  *         -1 for miscellaneous errors
538  * @deffunc int ap_method_number_of(const char *method)
539  */
540 AP_DECLARE(int) ap_getline(char *s, int n, request_rec *r, int fold);
541
542 /**
543  * Get the next line of input for the request
544  *
545  * Note: on ASCII boxes, ap_rgetline is a macro which simply calls 
546  *       ap_rgetline_core to get the line of input.
547  * 
548  *       on EBCDIC boxes, ap_rgetline is a wrapper function which
549  *       translates ASCII protocol lines to the local EBCDIC code page
550  *       after getting the line of input.
551  *       
552  * @param s Pointer to the pointer to the buffer into which the line
553  *          should be read; if *s==NULL, a buffer of the necessary size
554  *          to hold the data will be allocated from the request pool
555  * @param n The size of the buffer
556  * @param read The length of the line.
557  * @param r The request
558  * @param fold Whether to merge continuation lines
559  * @return APR_SUCCESS, if successful
560  *         APR_ENOSPC, if the line is too big to fit in the buffer
561  *         Other errors where appropriate
562  */
563 #if APR_CHARSET_EBCDIC
564 AP_DECLARE(apr_status_t) ap_rgetline(char **s, apr_size_t n, 
565                                      apr_size_t *read,
566                                      request_rec *r, int fold);
567 #else /* ASCII box */
568 #define ap_rgetline(s, n, read, r, fold) \
569         ap_rgetline_core((s), (n), (read), (r), (fold))
570 #endif
571 AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n, 
572                                           apr_size_t *read,
573                                           request_rec *r, int fold);
574 /**
575  * Get the method number associated with the given string, assumed to
576  * contain an HTTP method.  Returns M_INVALID if not recognized.
577  * @param method A string containing a valid HTTP method
578  * @return The method number
579  * @deffunc int ap_method_number_of(const char *method)
580  */
581 AP_DECLARE(int) ap_method_number_of(const char *method);
582
583 /**
584  * Get the method name associated with the given internal method
585  * number.  Returns NULL if not recognized.
586  * @param methnum An integer value corresponding to an internal method number
587  * @return The name corresponding to the method number
588  * @deffunc const char *ap_method_name_of(int methnum)
589  */
590 AP_DECLARE(const char *) ap_method_name_of(int methnum);
591
592
593   /* Hooks */
594   /*
595    * post_read_request --- run right after read_request or internal_redirect,
596    *                  and not run during any subrequests.
597    */
598 /**
599  * This hook allows modules to affect the request immediately after the request
600  * has been read, and before any other phases have been processes.  This allows
601  * modules to make decisions based upon the input header fields
602  * @param r The current request
603  * @return OK or DECLINED
604  * @deffunc ap_run_post_read_request(request_rec *r)
605  */
606 AP_DECLARE_HOOK(int,post_read_request,(request_rec *r))
607
608 /**
609  * This hook allows modules to perform any module-specific logging activities
610  * over and above the normal server things.
611  * @param r The current request
612  * @return OK, DECLINED, or HTTP_...
613  * @deffunc int ap_run_log_transaction(request_rec *r)
614  */
615 AP_DECLARE_HOOK(int,log_transaction,(request_rec *r))
616
617 /**
618  * This hook allows modules to retrieve the http method from a request.  This
619  * allows Apache modules to easily extend the methods that Apache understands
620  * @param r The current request
621  * @return The http method from the request
622  * @deffunc const char *ap_run_http_method(const request_rec *r)
623  */
624 AP_DECLARE_HOOK(const char *,http_method,(const request_rec *r))
625
626 /**
627  * Return the default port from the current request
628  * @param r The current request
629  * @return The current port
630  * @deffunc apr_port_t ap_run_default_port(const request_rec *r)
631  */
632 AP_DECLARE_HOOK(apr_port_t,default_port,(const request_rec *r))
633
634 typedef struct ap_bucket_error ap_bucket_error;
635
636 /**
637  * A bucket referring to an HTTP error
638  * This bucket can be passed down the filter stack to indicate that an
639  * HTTP error occurred while running a filter.  In order for this bucket
640  * to be used successfully, it MUST be sent as the first bucket in the
641  * first brigade to be sent from a given filter.
642  */
643 struct ap_bucket_error {
644     /** The error code */
645     int status;
646     /** The error string */
647     const char    *data;
648 };
649
650 AP_DECLARE_DATA extern const apr_bucket_type_t ap_bucket_type_error;
651
652 /**
653  * Make the bucket passed in an error bucket
654  * @param b The bucket to make into an error bucket
655  * @param error The HTTP error code to put in the bucket. 
656  * @param buf An optional error string to put in the bucket.
657  * @param p A pool to allocate out of.
658  * @return The new bucket, or NULL if allocation failed
659  * @deffunc apr_bucket *ap_bucket_error_make(apr_bucket *b, int error, const char *buf, apr_pool_t *p)
660  */
661 AP_DECLARE(apr_bucket *) ap_bucket_error_make(apr_bucket *b, int error,
662                 const char *buf, apr_pool_t *p);
663
664 /**
665  * Create a bucket referring to an HTTP error.
666  * @param error The HTTP error code to put in the bucket. 
667  * @param buf An optional error string to put in the bucket.
668  * @param p A pool to allocate out of.
669  * @return The new bucket, or NULL if allocation failed
670  * @deffunc apr_bucket *ap_bucket_error_create(int error, const char *buf, apr_pool_t *p)
671  */
672 AP_DECLARE(apr_bucket *) ap_bucket_error_create(int error,
673                 const char *buf, apr_pool_t *p);
674
675 AP_DECLARE_NONSTD(apr_status_t) ap_byterange_filter(ap_filter_t *f, apr_bucket_brigade *b);
676 AP_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, apr_bucket_brigade *b);
677 AP_DECLARE_NONSTD(apr_status_t) ap_content_length_filter(ap_filter_t *,
678                                                               apr_bucket_brigade *);
679 AP_DECLARE_NONSTD(apr_status_t) ap_old_write_filter(ap_filter_t *f, apr_bucket_brigade *b);
680
681 /*
682  * Setting up the protocol fields for subsidiary requests...
683  * Also, a wrapup function to keep the internal accounting straight.
684  */
685 void ap_set_sub_req_protocol(request_rec *rnew, const request_rec *r);
686 void ap_finalize_sub_req_protocol(request_rec *sub_r);
687                                                                                 
688 #ifdef __cplusplus
689 }
690 #endif
691
692 #endif  /* !APACHE_HTTP_PROTOCOL_H */