]> granicus.if.org Git - apache/blob - include/http_protocol.h
Add macro to check for an error bucket. (Can't call it APR_BUCKET_IS_ERROR
[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 /**
95  * Read the mime-encoded headers.
96  * @param r The current request
97  */
98 void ap_get_mime_headers(request_rec *r);
99
100 /* Finish up stuff after a request */
101
102 /**
103  * Called at completion of sending the response.  It sends the terminating
104  * protocol information.
105  * @param r The current request
106  * @deffunc void ap_finalize_request_protocol(request_rec *r)
107  */
108 AP_DECLARE(void) ap_finalize_request_protocol(request_rec *r);
109
110 /**
111  * Send error back to client.
112  * @param r The current request
113  * @param recursive_error last arg indicates error status in case we get 
114  *      an error in the process of trying to deal with an ErrorDocument 
115  *      to handle some other error.  In that case, we print the default 
116  *      report for the first thing that went wrong, and more briefly report 
117  *      on the problem with the ErrorDocument.
118  * @deffunc void ap_send_error_response(request_rec *r, int recursive_error)
119  */
120 AP_DECLARE(void) ap_send_error_response(request_rec *r, int recursive_error);
121
122 /* Set last modified header line from the lastmod date of the associated file.
123  * Also, set content length.
124  *
125  * May return an error status, typically HTTP_NOT_MODIFIED (that when the
126  * permit_cache argument is set to one).
127  */
128
129 /**
130  * Set the content length for this request
131  * @param r The current request
132  * @param length The new content length
133  * @deffunc void ap_set_content_length(request_rec *r, apr_off_t length)
134  */
135 AP_DECLARE(void) ap_set_content_length(request_rec *r, apr_off_t length);
136
137 /**
138  * Set the keepalive status for this request
139  * @param r The current request
140  * @return 1 if keepalive can be set, 0 otherwise
141  * @deffunc int ap_set_keepalive(request_rec *r)
142  */
143 AP_DECLARE(int) ap_set_keepalive(request_rec *r);
144
145 /**
146  * Return the latest rational time from a request/mtime pair.  Mtime is 
147  * returned unless it's in the future, in which case we return the current time.
148  * @param r The current request
149  * @param mtime The last modified time
150  * @return the latest rational time.
151  * @deffunc apr_time_t ap_rationalize_mtime(request_rec *r, apr_time_t mtime)
152  */
153 AP_DECLARE(apr_time_t) ap_rationalize_mtime(request_rec *r, apr_time_t mtime);
154
155 /**
156  * Build the content-type that should be sent to the client from the
157  * content-type specified.  The following rules are followed:
158  *    - if type is NULL, type is set to ap_default_type(r)
159  *    - if charset adding is disabled, stop processing and return type.
160  *    - then, if there are no parameters on type, add the default charset
161  *    - return type
162  * @param r The current request
163  * @return The content-type
164  * @deffunc const char *ap_make_content_type(request_rec *r, const char *type);
165  */ 
166 AP_DECLARE(const char *) ap_make_content_type(request_rec *r,
167                                               const char *type);
168
169 #ifdef CORE_PRIVATE
170 /**
171  * Precompile metadata structures used by ap_make_content_type()
172  * @param r The pool to use for allocations
173  * @deffunc void ap_setup_make_content_type(apr_pool_t *pool)
174  */
175 AP_DECLARE(void) ap_setup_make_content_type(apr_pool_t *pool);
176 #endif /* CORE_PRIVATE */
177
178 /**
179  * Construct an entity tag from the resource information.  If it's a real
180  * file, build in some of the file characteristics.
181  * @param r The current request
182  * @param force_weak Force the entity tag to be weak - it could be modified
183  *                   again in as short an interval.
184  * @return The entity tag
185  * @deffunc char *ap_make_etag(request_rec *r, int force_weak)
186  */ 
187 AP_DECLARE(char *) ap_make_etag(request_rec *r, int force_weak);
188
189 /**
190  * Set the E-tag outgoing header
191  * @param The current request
192  * @deffunc void ap_set_etag(request_rec *r)
193  */
194 AP_DECLARE(void) ap_set_etag(request_rec *r);
195
196 /**
197  * Set the last modified time for the file being sent
198  * @param r The current request
199  * @deffunc void ap_set_last_modified(request_rec *r)
200  */
201 AP_DECLARE(void) ap_set_last_modified(request_rec *r);
202
203 /**
204  * Implements condition GET rules for HTTP/1.1 specification.  This function
205  * inspects the client headers and determines if the response fulfills 
206  * the requirements specified.
207  * @param r The current request
208  * @return 1 if the response fulfills the condition GET rules, 0 otherwise
209  * @deffunc int ap_meets_conditions(request_rec *r)
210  */
211 AP_DECLARE(int) ap_meets_conditions(request_rec *r);
212
213 /* Other ways to send stuff at the client.  All of these keep track
214  * of bytes_sent automatically.  This indirection is intended to make
215  * it a little more painless to slide things like HTTP-NG packetization
216  * underneath the main body of the code later.  In the meantime, it lets
217  * us centralize a bit of accounting (bytes_sent).
218  *
219  * These also return the number of bytes written by the call.
220  * They should only be called with a timeout registered, for obvious reaasons.
221  * (Ditto the send_header stuff).
222  */
223
224 /**
225  * Send an entire file to the client, using sendfile if supported by the 
226  * current platform
227  * @param fd The file to send.
228  * @param r The current request
229  * @param offset Offset into the file to start sending.
230  * @param length Amount of data to send
231  * @param nbytes Amount of data actually sent
232  * @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);
233  */
234 AP_DECLARE(apr_status_t) ap_send_fd(apr_file_t *fd, request_rec *r, apr_off_t offset, 
235                                    apr_size_t length, apr_size_t *nbytes);
236
237 #if APR_HAS_MMAP
238 /**
239  * Send an MMAP'ed file to the client
240  * @param mm The MMAP'ed file to send
241  * @param r The current request
242  * @param offset The offset into the MMAP to start sending
243  * @param length The amount of data to send
244  * @return The number of bytes sent
245  * @deffunc size_t ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset, size_t length)
246  */
247 AP_DECLARE(size_t) ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset,
248                              size_t length);
249 #endif
250
251
252 /**
253  * Register a new request method, and return the offset that will be
254  * associated with that method.
255  *
256  * @param p        The pool to create registered method numbers from.
257  * @param methname The name of the new method to register.
258  * @return         Ab int value representing an offset into a bitmask.
259  */
260 AP_DECLARE(int) ap_method_register(apr_pool_t *p, const char *methname);
261
262 /**
263  * Initialize the method_registry and allocate memory for it.
264  *
265  * @param p Pool to allocate memory for the registry from.
266  */
267 AP_DECLARE(void) ap_method_registry_init(apr_pool_t *p);
268
269 /*
270  * This is a convenience macro to ease with checking a mask
271  * against a method name.
272  */
273 #define AP_METHOD_CHECK_ALLOWED(mask, methname) \
274     ((mask) & (AP_METHOD_BIT << ap_method_number_of((methname))))
275
276 /**
277  * Create a new method list with the specified number of preallocated
278  * slots for extension methods.
279  *
280  * @param   p       Pointer to a pool in which the structure should be
281  *                  allocated.
282  * @param   nelts   Number of preallocated extension slots
283  * @return  Pointer to the newly created structure.
284  * @deffunc ap_method_list_t ap_make_method_list(apr_pool_t *p, int nelts)
285  */
286 AP_DECLARE(ap_method_list_t *) ap_make_method_list(apr_pool_t *p, int nelts);
287 AP_DECLARE(void) ap_copy_method_list(ap_method_list_t *dest,
288                                      ap_method_list_t *src);
289 AP_DECLARE_NONSTD(void) ap_method_list_do(int (*comp) (void *urec, const char *mname,
290                                                        int mnum),
291                                           void *rec,
292                                           const ap_method_list_t *ml, ...);
293 AP_DECLARE(void) ap_method_list_vdo(int (*comp) (void *urec, const char *mname,
294                                                  int mnum),
295                                     void *rec, const ap_method_list_t *ml,
296                                     va_list vp);
297 /**
298  * Search for an HTTP method name in an ap_method_list_t structure, and
299  * return true if found.
300  *
301  * @param   method  String containing the name of the method to check.
302  * @param   l       Pointer to a method list, such as cmd->methods_limited.
303  * @return  1 if method is in the list, otherwise 0
304  * @deffunc int ap_method_in_list(const char *method, ap_method_list_t *l)
305  */
306 AP_DECLARE(int) ap_method_in_list(ap_method_list_t *l, const char *method);
307
308 /**
309  * Add an HTTP method name to an ap_method_list_t structure if it isn't
310  * already listed.
311  *
312  * @param   method  String containing the name of the method to check.
313  * @param   l       Pointer to a method list, such as cmd->methods_limited.
314  * @return  None.
315  * @deffunc void ap_method_in_list(ap_method_list_t *l, const char *method)
316  */
317 AP_DECLARE(void) ap_method_list_add(ap_method_list_t *l, const char *method);
318     
319 /**
320  * Remove an HTTP method name from an ap_method_list_t structure.
321  *
322  * @param   l       Pointer to a method list, such as cmd->methods_limited.
323  * @param   method  String containing the name of the method to remove.
324  * @return  None.
325  * @deffunc void ap_method_list_remove(ap_method_list_t *l, const char *method)
326  */
327 AP_DECLARE(void) ap_method_list_remove(ap_method_list_t *l,
328                                        const char *method);
329
330 /**
331  * Reset a method list to be completely empty.
332  *
333  * @param   l       Pointer to a method list, such as cmd->methods_limited.
334  * @return  None.
335  * @deffunc void ap_clear_method_list(ap_method_list_t *l)
336  */
337 AP_DECLARE(void) ap_clear_method_list(ap_method_list_t *l);
338     
339 /**
340  * Set the content type for this request (r->content_type). 
341  * Note:
342  * This function must be called to set r->content_type in order 
343  * for the AddOutputFilterByType directive to work correctly.
344  * @param r The current request
345  * @param length The new content type
346  * @deffunc void ap_set_content_type(request_rec *r, const char* ct)
347  */
348 AP_DECLARE(void) ap_set_content_type(request_rec *r, const char *ct);
349
350 /* Hmmm... could macrofy these for now, and maybe forever, though the
351  * definitions of the macros would get a whole lot hairier.
352  */
353
354 /**
355  * Output one character for this request
356  * @param c the character to output
357  * @param r the current request
358  * @return The number of bytes sent
359  * @deffunc int ap_rputc(int c, request_rec *r)
360  */
361 AP_DECLARE(int) ap_rputc(int c, request_rec *r);
362
363 /**
364  * Output a string for the current request
365  * @param str The string to output
366  * @param r The current request
367  * @return The number of bytes sent
368  * @deffunc int ap_rputs(const char *str, request_rec *r)
369  */
370 AP_DECLARE(int) ap_rputs(const char *str, request_rec *r);
371
372 /**
373  * Write a buffer for the current request
374  * @param buf The buffer to write
375  * @param nbyte The number of bytes to send from the buffer
376  * @param r The current request
377  * @return The number of bytes sent
378  * @deffunc int ap_rwrite(const void *buf, int nbyte, request_rec *r)
379  */
380 AP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r);
381
382 /**
383  * Write an unspecified number of strings to the request
384  * @param r The current request
385  * @param ... The strings to write
386  * @return The number of bytes sent
387  * @deffunc int ap_rvputs(request_rec *r, ...)
388  */
389 AP_DECLARE_NONSTD(int) ap_rvputs(request_rec *r,...);
390
391 /**
392  * Output data to the client in a printf format
393  * @param r The current request
394  * @param fmt The format string
395  * @param vlist The arguments to use to fill out the format string
396  * @return The number of bytes sent
397  * @deffunc int ap_vrprintf(request_rec *r, const char *fmt, va_list vlist)
398  */
399 AP_DECLARE(int) ap_vrprintf(request_rec *r, const char *fmt, va_list vlist);
400
401 /**
402  * Output data to the client in a printf format
403  * @param r The current request
404  * @param fmt The format string
405  * @param ... The arguments to use to fill out the format string
406  * @return The number of bytes sent
407  * @deffunc int ap_rprintf(request_rec *r, const char *fmt, ...)
408  */
409 AP_DECLARE_NONSTD(int) ap_rprintf(request_rec *r, const char *fmt,...)
410                                 __attribute__((format(printf,2,3)));
411 /**
412  * Flush all of the data for the current request to the client
413  * @param r The current request
414  * @return The number of bytes sent
415  * @deffunc int ap_rflush(request_rec *r)
416  */
417 AP_DECLARE(int) ap_rflush(request_rec *r);
418
419 /**
420  * Index used in custom_responses array for a specific error code
421  * (only use outside protocol.c is in getting them configured).
422  * @param status HTTP status code
423  * @return The index of the response
424  * @deffunc int ap_index_of_response(int status)
425  */
426 AP_DECLARE(int) ap_index_of_response(int status);
427
428 /** 
429  * Return the Status-Line for a given status code (excluding the
430  * HTTP-Version field). If an invalid or unknown status code is
431  * passed, "500 Internal Server Error" will be returned. 
432  * @param status The HTTP status code
433  * @return The Status-Line
434  * @deffunc const char *ap_get_status_line(int status)
435  */
436 AP_DECLARE(const char *) ap_get_status_line(int status);
437
438 /* Reading a block of data from the client connection (e.g., POST arg) */
439
440 /**
441  * Setup the client to allow Apache to read the request body.
442  * @param r The current request
443  * @param read_policy How the server should interpret a chunked 
444  *                    transfer-encoding.  One of: <pre>
445  *    REQUEST_NO_BODY          Send 413 error if message has any body
446  *    REQUEST_CHUNKED_ERROR    Send 411 error if body without Content-Length
447  *    REQUEST_CHUNKED_DECHUNK  If chunked, remove the chunks for me.
448  * </pre>
449  * @return either OK or an error code
450  * @deffunc int ap_setup_client_block(request_rec *r, int read_policy)
451  */
452 AP_DECLARE(int) ap_setup_client_block(request_rec *r, int read_policy);
453
454 /**
455  * Determine if the client has sent any data.  This also sends a 
456  * 100 Continue response to HTTP/1.1 clients, so modules should not be called
457  * until the module is ready to read content.
458  * @warning Never call this function more than once.
459  * @param r The current request
460  * @return 0 if there is no message to read, 1 otherwise
461  * @deffunc int ap_should_client_block(request_rec *r)
462  */
463 AP_DECLARE(int) ap_should_client_block(request_rec *r);
464
465 /**
466  * Call this in a loop.  It will put data into a buffer and return the length
467  * of the input block
468  * @param r The current request
469  * @param buffer The buffer in which to store the data
470  * @param bufsiz The size of the buffer
471  * @return Number of bytes inserted into the buffer.  When done reading, 0
472  *         if EOF, or -1 if there was an error
473  * @deffunc long ap_get_client_block(request_rec *r, char *buffer, apr_size_t bufsiz)
474  */
475 AP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer, apr_size_t bufsiz);
476
477 /**
478  * In HTTP/1.1, any method can have a body.  However, most GET handlers
479  * wouldn't know what to do with a request body if they received one.
480  * This helper routine tests for and reads any message body in the request,
481  * simply discarding whatever it receives.  We need to do this because
482  * failing to read the request body would cause it to be interpreted
483  * as the next request on a persistent connection.
484  * @param r The current request
485  * @return error status if request is malformed, OK otherwise 
486  * @deffunc int ap_discard_request_body(request_rec *r)
487  */
488 AP_DECLARE(int) ap_discard_request_body(request_rec *r);
489
490
491 /**
492  * Setup the output headers so that the client knows how to authenticate
493  * itself the next time, if an authentication request failed.  This function
494  * works for both basic and digest authentication
495  * @param r The current request
496  * @deffunc void ap_note_auth_failure(request_rec *r)
497  */ 
498 AP_DECLARE(void) ap_note_auth_failure(request_rec *r);
499
500 /**
501  * Setup the output headers so that the client knows how to authenticate
502  * itself the next time, if an authentication request failed.  This function
503  * works only for basic authentication
504  * @param r The current request
505  * @deffunc void ap_note_basic_auth_failure(request_rec *r)
506  */ 
507 AP_DECLARE(void) ap_note_basic_auth_failure(request_rec *r);
508
509 /**
510  * Setup the output headers so that the client knows how to authenticate
511  * itself the next time, if an authentication request failed.  This function
512  * works only for digest authentication
513  * @param r The current request
514  * @deffunc void ap_note_digest_auth_failure(request_rec *r)
515  */ 
516 AP_DECLARE(void) ap_note_digest_auth_failure(request_rec *r);
517
518 /**
519  * Get the password from the request headers
520  * @param r The current request
521  * @param pw The password as set in the headers
522  * @return 0 (OK) if it set the 'pw' argument (and assured
523  *         a correct value in r->connection->user); otherwise it returns 
524  *         an error code, either HTTP_INTERNAL_SERVER_ERROR if things are 
525  *         really confused, HTTP_UNAUTHORIZED if no authentication at all 
526  *         seemed to be in use, or DECLINED if there was authentication but 
527  *         it wasn't Basic (in which case, the caller should presumably 
528  *         decline as well).
529  * @deffunc int ap_get_basic_auth_pw(request_rec *r, const char **pw)
530  */
531 AP_DECLARE(int) ap_get_basic_auth_pw(request_rec *r, const char **pw);
532
533 /**
534  * parse_uri: break apart the uri
535  * @warning Side Effects: <pre>
536  *    - sets r->args to rest after '?' (or NULL if no '?')
537  *    - sets r->uri to request uri (without r->args part)
538  *    - sets r->hostname (if not set already) from request (scheme://host:port)
539  * </pre>
540  * @param r The current request
541  * @param uri The uri to break apart
542  * @deffunc void ap_parse_uri(request_rec *r, const char *uri)
543  */
544 AP_CORE_DECLARE(void) ap_parse_uri(request_rec *r, const char *uri);
545
546 /**
547  * Get the next line of input for the request
548  * @param s The buffer into which to read the line
549  * @param n The size of the buffer
550  * @param r The request
551  * @param fold Whether to merge continuation lines
552  * @return The length of the line, if successful
553  *         n, if the line is too big to fit in the buffer
554  *         -1 for miscellaneous errors
555  * @deffunc int ap_method_number_of(const char *method)
556  */
557 AP_DECLARE(int) ap_getline(char *s, int n, request_rec *r, int fold);
558
559 /**
560  * Get the next line of input for the request
561  *
562  * Note: on ASCII boxes, ap_rgetline is a macro which simply calls 
563  *       ap_rgetline_core to get the line of input.
564  * 
565  *       on EBCDIC boxes, ap_rgetline is a wrapper function which
566  *       translates ASCII protocol lines to the local EBCDIC code page
567  *       after getting the line of input.
568  *       
569  * @param s Pointer to the pointer to the buffer into which the line
570  *          should be read; if *s==NULL, a buffer of the necessary size
571  *          to hold the data will be allocated from the request pool
572  * @param n The size of the buffer
573  * @param read The length of the line.
574  * @param r The request
575  * @param fold Whether to merge continuation lines
576  * @return APR_SUCCESS, if successful
577  *         APR_ENOSPC, if the line is too big to fit in the buffer
578  *         Other errors where appropriate
579  */
580 #if APR_CHARSET_EBCDIC
581 AP_DECLARE(apr_status_t) ap_rgetline(char **s, apr_size_t n, 
582                                      apr_size_t *read,
583                                      request_rec *r, int fold);
584 #else /* ASCII box */
585 #define ap_rgetline(s, n, read, r, fold) \
586         ap_rgetline_core((s), (n), (read), (r), (fold))
587 #endif
588 AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n, 
589                                           apr_size_t *read,
590                                           request_rec *r, int fold);
591
592 /**
593  * Get the method number associated with the given string, assumed to
594  * contain an HTTP method.  Returns M_INVALID if not recognized.
595  * @param method A string containing a valid HTTP method
596  * @return The method number
597  */
598 AP_DECLARE(int) ap_method_number_of(const char *method);
599
600 /**
601  * Get the method name associated with the given internal method
602  * number.  Returns NULL if not recognized.
603  * @param p A pool to use for temporary allocations.
604  * @param methnum An integer value corresponding to an internal method number
605  * @return The name corresponding to the method number
606  */
607 AP_DECLARE(const char *) ap_method_name_of(apr_pool_t *p, int methnum);
608
609
610   /* Hooks */
611   /*
612    * post_read_request --- run right after read_request or internal_redirect,
613    *                  and not run during any subrequests.
614    */
615 /**
616  * This hook allows modules to affect the request immediately after the request
617  * has been read, and before any other phases have been processes.  This allows
618  * modules to make decisions based upon the input header fields
619  * @param r The current request
620  * @return OK or DECLINED
621  * @deffunc ap_run_post_read_request(request_rec *r)
622  */
623 AP_DECLARE_HOOK(int,post_read_request,(request_rec *r))
624
625 /**
626  * This hook allows modules to perform any module-specific logging activities
627  * over and above the normal server things.
628  * @param r The current request
629  * @return OK, DECLINED, or HTTP_...
630  * @deffunc int ap_run_log_transaction(request_rec *r)
631  */
632 AP_DECLARE_HOOK(int,log_transaction,(request_rec *r))
633
634 /**
635  * This hook allows modules to retrieve the http method from a request.  This
636  * allows Apache modules to easily extend the methods that Apache understands
637  * @param r The current request
638  * @return The http method from the request
639  * @deffunc const char *ap_run_http_method(const request_rec *r)
640  */
641 AP_DECLARE_HOOK(const char *,http_method,(const request_rec *r))
642
643 /**
644  * Return the default port from the current request
645  * @param r The current request
646  * @return The current port
647  * @deffunc apr_port_t ap_run_default_port(const request_rec *r)
648  */
649 AP_DECLARE_HOOK(apr_port_t,default_port,(const request_rec *r))
650
651 typedef struct ap_bucket_error ap_bucket_error;
652
653 /**
654  * A bucket referring to an HTTP error
655  * This bucket can be passed down the filter stack to indicate that an
656  * HTTP error occurred while running a filter.  In order for this bucket
657  * to be used successfully, it MUST be sent as the first bucket in the
658  * first brigade to be sent from a given filter.
659  */
660 struct ap_bucket_error {
661     /** The error code */
662     int status;
663     /** The error string */
664     const char    *data;
665 };
666
667 AP_DECLARE_DATA extern const apr_bucket_type_t ap_bucket_type_error;
668
669 /**
670  * Determine if a bucket is an error bucket
671  * @param e The bucket to inspect
672  * @return true or false
673  */
674 #define AP_BUCKET_IS_ERROR(e)         (e->type == &ap_bucket_type_error)
675
676 /**
677  * Make the bucket passed in an error bucket
678  * @param b The bucket to make into an error bucket
679  * @param error The HTTP error code to put in the bucket. 
680  * @param buf An optional error string to put in the bucket.
681  * @param p A pool to allocate out of.
682  * @return The new bucket, or NULL if allocation failed
683  * @deffunc apr_bucket *ap_bucket_error_make(apr_bucket *b, int error, const char *buf, apr_pool_t *p)
684  */
685 AP_DECLARE(apr_bucket *) ap_bucket_error_make(apr_bucket *b, int error,
686                 const char *buf, apr_pool_t *p);
687
688 /**
689  * Create a bucket referring to an HTTP error.
690  * @param error The HTTP error code to put in the bucket. 
691  * @param buf An optional error string to put in the bucket.
692  * @param p A pool to allocate the error string out of.
693  * @param list The bucket allocator from which to allocate the bucket
694  * @return The new bucket, or NULL if allocation failed
695  * @deffunc apr_bucket *ap_bucket_error_create(int error, const char *buf, apr_pool_t *p, apr_bucket_alloc_t *list)
696  */
697 AP_DECLARE(apr_bucket *) ap_bucket_error_create(int error, const char *buf,
698                                                 apr_pool_t *p,
699                                                 apr_bucket_alloc_t *list);
700
701 AP_DECLARE_NONSTD(apr_status_t) ap_byterange_filter(ap_filter_t *f, apr_bucket_brigade *b);
702 AP_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, apr_bucket_brigade *b);
703 AP_DECLARE_NONSTD(apr_status_t) ap_content_length_filter(ap_filter_t *,
704                                                               apr_bucket_brigade *);
705 AP_DECLARE_NONSTD(apr_status_t) ap_old_write_filter(ap_filter_t *f, apr_bucket_brigade *b);
706
707 /*
708  * Setting up the protocol fields for subsidiary requests...
709  * Also, a wrapup function to keep the internal accounting straight.
710  */
711 void ap_set_sub_req_protocol(request_rec *rnew, const request_rec *r);
712 void ap_finalize_sub_req_protocol(request_rec *sub_r);
713                                                                                 
714 #ifdef __cplusplus
715 }
716 #endif
717
718 #endif  /* !APACHE_HTTP_PROTOCOL_H */