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