00001 /* Copyright 1999-2005 The Apache Software Foundation or its licensors, as 00002 * applicable. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef APACHE_HTTP_PROTOCOL_H 00018 #define APACHE_HTTP_PROTOCOL_H 00019 00020 #include "httpd.h" 00021 #include "apr_hooks.h" 00022 #include "apr_portable.h" 00023 #include "apr_mmap.h" 00024 #include "apr_buckets.h" 00025 #include "util_filter.h" 00026 00027 #ifdef __cplusplus 00028 extern "C" { 00029 #endif 00030 00031 /** 00032 * @package HTTP protocol handling 00033 */ 00034 00035 /** 00036 * This hook allows modules to insert filters for the current error response 00037 * @param r the current request 00038 * @ingroup hooks 00039 */ 00040 AP_DECLARE_HOOK(void,insert_error_filter,(request_rec *r)) 00041 00042 /* This is an optimization. We keep a record of the filter_rec that 00043 * stores the old_write filter, so that we can avoid strcmp's later. 00044 */ 00045 AP_DECLARE_DATA extern ap_filter_rec_t *ap_old_write_func; 00046 00047 /* 00048 * Prototypes for routines which either talk directly back to the user, 00049 * or control the ones that eventually do. 00050 */ 00051 00052 /** 00053 * Read a request and fill in the fields. 00054 * @param c The current connection 00055 * @return The new request_rec 00056 */ 00057 request_rec *ap_read_request(conn_rec *c); 00058 00059 /** 00060 * Read the mime-encoded headers. 00061 * @param r The current request 00062 */ 00063 AP_DECLARE(void) ap_get_mime_headers(request_rec *r); 00064 00065 /** 00066 * Optimized version of ap_get_mime_headers() that requires a 00067 * temporary brigade to work with 00068 * @param r The current request 00069 * @param bb temp brigade 00070 */ 00071 AP_DECLARE(void) ap_get_mime_headers_core(request_rec *r, 00072 apr_bucket_brigade *bb); 00073 00074 /* Finish up stuff after a request */ 00075 00076 /** 00077 * Called at completion of sending the response. It sends the terminating 00078 * protocol information. 00079 * @param r The current request 00080 * @deffunc void ap_finalize_request_protocol(request_rec *r) 00081 */ 00082 AP_DECLARE(void) ap_finalize_request_protocol(request_rec *r); 00083 00084 /** 00085 * Send error back to client. 00086 * @param r The current request 00087 * @param recursive_error last arg indicates error status in case we get 00088 * an error in the process of trying to deal with an ErrorDocument 00089 * to handle some other error. In that case, we print the default 00090 * report for the first thing that went wrong, and more briefly report 00091 * on the problem with the ErrorDocument. 00092 * @deffunc void ap_send_error_response(request_rec *r, int recursive_error) 00093 */ 00094 AP_DECLARE(void) ap_send_error_response(request_rec *r, int recursive_error); 00095 00096 /* Set last modified header line from the lastmod date of the associated file. 00097 * Also, set content length. 00098 * 00099 * May return an error status, typically HTTP_NOT_MODIFIED (that when the 00100 * permit_cache argument is set to one). 00101 */ 00102 00103 /** 00104 * Set the content length for this request 00105 * @param r The current request 00106 * @param length The new content length 00107 * @deffunc void ap_set_content_length(request_rec *r, apr_off_t length) 00108 */ 00109 AP_DECLARE(void) ap_set_content_length(request_rec *r, apr_off_t length); 00110 00111 /** 00112 * Set the keepalive status for this request 00113 * @param r The current request 00114 * @return 1 if keepalive can be set, 0 otherwise 00115 * @deffunc int ap_set_keepalive(request_rec *r) 00116 */ 00117 AP_DECLARE(int) ap_set_keepalive(request_rec *r); 00118 00119 /** 00120 * Return the latest rational time from a request/mtime pair. Mtime is 00121 * returned unless it's in the future, in which case we return the current time. 00122 * @param r The current request 00123 * @param mtime The last modified time 00124 * @return the latest rational time. 00125 * @deffunc apr_time_t ap_rationalize_mtime(request_rec *r, apr_time_t mtime) 00126 */ 00127 AP_DECLARE(apr_time_t) ap_rationalize_mtime(request_rec *r, apr_time_t mtime); 00128 00129 /** 00130 * Build the content-type that should be sent to the client from the 00131 * content-type specified. The following rules are followed: 00132 * - if type is NULL, type is set to ap_default_type(r) 00133 * - if charset adding is disabled, stop processing and return type. 00134 * - then, if there are no parameters on type, add the default charset 00135 * - return type 00136 * @param r The current request 00137 * @return The content-type 00138 * @deffunc const char *ap_make_content_type(request_rec *r, const char *type); 00139 */ 00140 AP_DECLARE(const char *) ap_make_content_type(request_rec *r, 00141 const char *type); 00142 00143 #ifdef CORE_PRIVATE 00144 /** 00145 * Precompile metadata structures used by ap_make_content_type() 00146 * @param r The pool to use for allocations 00147 * @deffunc void ap_setup_make_content_type(apr_pool_t *pool) 00148 */ 00149 AP_DECLARE(void) ap_setup_make_content_type(apr_pool_t *pool); 00150 #endif /* CORE_PRIVATE */ 00151 00152 /** 00153 * Construct an entity tag from the resource information. If it's a real 00154 * file, build in some of the file characteristics. 00155 * @param r The current request 00156 * @param force_weak Force the entity tag to be weak - it could be modified 00157 * again in as short an interval. 00158 * @return The entity tag 00159 * @deffunc char *ap_make_etag(request_rec *r, int force_weak) 00160 */ 00161 AP_DECLARE(char *) ap_make_etag(request_rec *r, int force_weak); 00162 00163 /** 00164 * Set the E-tag outgoing header 00165 * @param The current request 00166 * @deffunc void ap_set_etag(request_rec *r) 00167 */ 00168 AP_DECLARE(void) ap_set_etag(request_rec *r); 00169 00170 /** 00171 * Set the last modified time for the file being sent 00172 * @param r The current request 00173 * @deffunc void ap_set_last_modified(request_rec *r) 00174 */ 00175 AP_DECLARE(void) ap_set_last_modified(request_rec *r); 00176 00177 /** 00178 * Implements condition GET rules for HTTP/1.1 specification. This function 00179 * inspects the client headers and determines if the response fulfills 00180 * the requirements specified. 00181 * @param r The current request 00182 * @return OK if the response fulfills the condition GET rules, some 00183 * other status code otherwise 00184 * @deffunc int ap_meets_conditions(request_rec *r) 00185 */ 00186 AP_DECLARE(int) ap_meets_conditions(request_rec *r); 00187 00188 /* Other ways to send stuff at the client. All of these keep track 00189 * of bytes_sent automatically. This indirection is intended to make 00190 * it a little more painless to slide things like HTTP-NG packetization 00191 * underneath the main body of the code later. In the meantime, it lets 00192 * us centralize a bit of accounting (bytes_sent). 00193 * 00194 * These also return the number of bytes written by the call. 00195 * They should only be called with a timeout registered, for obvious reaasons. 00196 * (Ditto the send_header stuff). 00197 */ 00198 00199 /** 00200 * Send an entire file to the client, using sendfile if supported by the 00201 * current platform 00202 * @param fd The file to send. 00203 * @param r The current request 00204 * @param offset Offset into the file to start sending. 00205 * @param length Amount of data to send 00206 * @param nbytes Amount of data actually sent 00207 * @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); 00208 */ 00209 AP_DECLARE(apr_status_t) ap_send_fd(apr_file_t *fd, request_rec *r, apr_off_t offset, 00210 apr_size_t length, apr_size_t *nbytes); 00211 00212 #if APR_HAS_MMAP 00213 /** 00214 * Send an MMAP'ed file to the client 00215 * @param mm The MMAP'ed file to send 00216 * @param r The current request 00217 * @param offset The offset into the MMAP to start sending 00218 * @param length The amount of data to send 00219 * @return The number of bytes sent 00220 * @deffunc size_t ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset, size_t length) 00221 */ 00222 AP_DECLARE(size_t) ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset, 00223 size_t length); 00224 #endif 00225 00226 00227 /** 00228 * Register a new request method, and return the offset that will be 00229 * associated with that method. 00230 * 00231 * @param p The pool to create registered method numbers from. 00232 * @param methname The name of the new method to register. 00233 * @return Ab int value representing an offset into a bitmask. 00234 */ 00235 AP_DECLARE(int) ap_method_register(apr_pool_t *p, const char *methname); 00236 00237 /** 00238 * Initialize the method_registry and allocate memory for it. 00239 * 00240 * @param p Pool to allocate memory for the registry from. 00241 */ 00242 AP_DECLARE(void) ap_method_registry_init(apr_pool_t *p); 00243 00244 /* 00245 * This is a convenience macro to ease with checking a mask 00246 * against a method name. 00247 */ 00248 #define AP_METHOD_CHECK_ALLOWED(mask, methname) \ 00249 ((mask) & (AP_METHOD_BIT << ap_method_number_of((methname)))) 00250 00251 /** 00252 * Create a new method list with the specified number of preallocated 00253 * slots for extension methods. 00254 * 00255 * @param p Pointer to a pool in which the structure should be 00256 * allocated. 00257 * @param nelts Number of preallocated extension slots 00258 * @return Pointer to the newly created structure. 00259 * @deffunc ap_method_list_t ap_make_method_list(apr_pool_t *p, int nelts) 00260 */ 00261 AP_DECLARE(ap_method_list_t *) ap_make_method_list(apr_pool_t *p, int nelts); 00262 AP_DECLARE(void) ap_copy_method_list(ap_method_list_t *dest, 00263 ap_method_list_t *src); 00264 AP_DECLARE_NONSTD(void) ap_method_list_do(int (*comp) (void *urec, const char *mname, 00265 int mnum), 00266 void *rec, 00267 const ap_method_list_t *ml, ...); 00268 AP_DECLARE(void) ap_method_list_vdo(int (*comp) (void *urec, const char *mname, 00269 int mnum), 00270 void *rec, const ap_method_list_t *ml, 00271 va_list vp); 00272 /** 00273 * Search for an HTTP method name in an ap_method_list_t structure, and 00274 * return true if found. 00275 * 00276 * @param method String containing the name of the method to check. 00277 * @param l Pointer to a method list, such as cmd->methods_limited. 00278 * @return 1 if method is in the list, otherwise 0 00279 * @deffunc int ap_method_in_list(const char *method, ap_method_list_t *l) 00280 */ 00281 AP_DECLARE(int) ap_method_in_list(ap_method_list_t *l, const char *method); 00282 00283 /** 00284 * Add an HTTP method name to an ap_method_list_t structure if it isn't 00285 * already listed. 00286 * 00287 * @param method String containing the name of the method to check. 00288 * @param l Pointer to a method list, such as cmd->methods_limited. 00289 * @return None. 00290 * @deffunc void ap_method_in_list(ap_method_list_t *l, const char *method) 00291 */ 00292 AP_DECLARE(void) ap_method_list_add(ap_method_list_t *l, const char *method); 00293 00294 /** 00295 * Remove an HTTP method name from an ap_method_list_t structure. 00296 * 00297 * @param l Pointer to a method list, such as cmd->methods_limited. 00298 * @param method String containing the name of the method to remove. 00299 * @return None. 00300 * @deffunc void ap_method_list_remove(ap_method_list_t *l, const char *method) 00301 */ 00302 AP_DECLARE(void) ap_method_list_remove(ap_method_list_t *l, 00303 const char *method); 00304 00305 /** 00306 * Reset a method list to be completely empty. 00307 * 00308 * @param l Pointer to a method list, such as cmd->methods_limited. 00309 * @return None. 00310 * @deffunc void ap_clear_method_list(ap_method_list_t *l) 00311 */ 00312 AP_DECLARE(void) ap_clear_method_list(ap_method_list_t *l); 00313 00314 /** 00315 * Set the content type for this request (r->content_type). 00316 * @param r The current request 00317 * @param ct The new content type 00318 * @deffunc void ap_set_content_type(request_rec *r, const char* ct) 00319 * @warning This function must be called to set r->content_type in order 00320 * for the AddOutputFilterByType directive to work correctly. 00321 */ 00322 AP_DECLARE(void) ap_set_content_type(request_rec *r, const char *ct); 00323 00324 /* Hmmm... could macrofy these for now, and maybe forever, though the 00325 * definitions of the macros would get a whole lot hairier. 00326 */ 00327 00328 /** 00329 * Output one character for this request 00330 * @param c the character to output 00331 * @param r the current request 00332 * @return The number of bytes sent 00333 * @deffunc int ap_rputc(int c, request_rec *r) 00334 */ 00335 AP_DECLARE(int) ap_rputc(int c, request_rec *r); 00336 00337 /** 00338 * Output a string for the current request 00339 * @param str The string to output 00340 * @param r The current request 00341 * @return The number of bytes sent 00342 * @deffunc int ap_rputs(const char *str, request_rec *r) 00343 */ 00344 AP_DECLARE(int) ap_rputs(const char *str, request_rec *r); 00345 00346 /** 00347 * Write a buffer for the current request 00348 * @param buf The buffer to write 00349 * @param nbyte The number of bytes to send from the buffer 00350 * @param r The current request 00351 * @return The number of bytes sent 00352 * @deffunc int ap_rwrite(const void *buf, int nbyte, request_rec *r) 00353 */ 00354 AP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r); 00355 00356 /** 00357 * Write an unspecified number of strings to the request 00358 * @param r The current request 00359 * @param ... The strings to write 00360 * @return The number of bytes sent 00361 * @deffunc int ap_rvputs(request_rec *r, ...) 00362 */ 00363 AP_DECLARE_NONSTD(int) ap_rvputs(request_rec *r,...); 00364 00365 /** 00366 * Output data to the client in a printf format 00367 * @param r The current request 00368 * @param fmt The format string 00369 * @param vlist The arguments to use to fill out the format string 00370 * @return The number of bytes sent 00371 * @deffunc int ap_vrprintf(request_rec *r, const char *fmt, va_list vlist) 00372 */ 00373 AP_DECLARE(int) ap_vrprintf(request_rec *r, const char *fmt, va_list vlist); 00374 00375 /** 00376 * Output data to the client in a printf format 00377 * @param r The current request 00378 * @param fmt The format string 00379 * @param ... The arguments to use to fill out the format string 00380 * @return The number of bytes sent 00381 * @deffunc int ap_rprintf(request_rec *r, const char *fmt, ...) 00382 */ 00383 AP_DECLARE_NONSTD(int) ap_rprintf(request_rec *r, const char *fmt,...) 00384 __attribute__((format(printf,2,3))); 00385 /** 00386 * Flush all of the data for the current request to the client 00387 * @param r The current request 00388 * @return The number of bytes sent 00389 * @deffunc int ap_rflush(request_rec *r) 00390 */ 00391 AP_DECLARE(int) ap_rflush(request_rec *r); 00392 00393 /** 00394 * Index used in custom_responses array for a specific error code 00395 * (only use outside protocol.c is in getting them configured). 00396 * @param status HTTP status code 00397 * @return The index of the response 00398 * @deffunc int ap_index_of_response(int status) 00399 */ 00400 AP_DECLARE(int) ap_index_of_response(int status); 00401 00402 /** 00403 * Return the Status-Line for a given status code (excluding the 00404 * HTTP-Version field). If an invalid or unknown status code is 00405 * passed, "500 Internal Server Error" will be returned. 00406 * @param status The HTTP status code 00407 * @return The Status-Line 00408 * @deffunc const char *ap_get_status_line(int status) 00409 */ 00410 AP_DECLARE(const char *) ap_get_status_line(int status); 00411 00412 /* Reading a block of data from the client connection (e.g., POST arg) */ 00413 00414 /** 00415 * Setup the client to allow Apache to read the request body. 00416 * @param r The current request 00417 * @param read_policy How the server should interpret a chunked 00418 * transfer-encoding. One of: <pre> 00419 * REQUEST_NO_BODY Send 413 error if message has any body 00420 * REQUEST_CHUNKED_ERROR Send 411 error if body without Content-Length 00421 * REQUEST_CHUNKED_DECHUNK If chunked, remove the chunks for me. 00422 * </pre> 00423 * @return either OK or an error code 00424 * @deffunc int ap_setup_client_block(request_rec *r, int read_policy) 00425 */ 00426 AP_DECLARE(int) ap_setup_client_block(request_rec *r, int read_policy); 00427 00428 /** 00429 * Determine if the client has sent any data. This also sends a 00430 * 100 Continue response to HTTP/1.1 clients, so modules should not be called 00431 * until the module is ready to read content. 00432 * @warning Never call this function more than once. 00433 * @param r The current request 00434 * @return 0 if there is no message to read, 1 otherwise 00435 * @deffunc int ap_should_client_block(request_rec *r) 00436 */ 00437 AP_DECLARE(int) ap_should_client_block(request_rec *r); 00438 00439 /** 00440 * Call this in a loop. It will put data into a buffer and return the length 00441 * of the input block 00442 * @param r The current request 00443 * @param buffer The buffer in which to store the data 00444 * @param bufsiz The size of the buffer 00445 * @return Number of bytes inserted into the buffer. When done reading, 0 00446 * if EOF, or -1 if there was an error 00447 * @deffunc long ap_get_client_block(request_rec *r, char *buffer, apr_size_t bufsiz) 00448 */ 00449 AP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer, apr_size_t bufsiz); 00450 00451 /** 00452 * In HTTP/1.1, any method can have a body. However, most GET handlers 00453 * wouldn't know what to do with a request body if they received one. 00454 * This helper routine tests for and reads any message body in the request, 00455 * simply discarding whatever it receives. We need to do this because 00456 * failing to read the request body would cause it to be interpreted 00457 * as the next request on a persistent connection. 00458 * @param r The current request 00459 * @return error status if request is malformed, OK otherwise 00460 * @deffunc int ap_discard_request_body(request_rec *r) 00461 */ 00462 AP_DECLARE(int) ap_discard_request_body(request_rec *r); 00463 00464 00465 /** 00466 * Setup the output headers so that the client knows how to authenticate 00467 * itself the next time, if an authentication request failed. This function 00468 * works for both basic and digest authentication 00469 * @param r The current request 00470 * @deffunc void ap_note_auth_failure(request_rec *r) 00471 */ 00472 AP_DECLARE(void) ap_note_auth_failure(request_rec *r); 00473 00474 /** 00475 * Setup the output headers so that the client knows how to authenticate 00476 * itself the next time, if an authentication request failed. This function 00477 * works only for basic authentication 00478 * @param r The current request 00479 * @deffunc void ap_note_basic_auth_failure(request_rec *r) 00480 */ 00481 AP_DECLARE(void) ap_note_basic_auth_failure(request_rec *r); 00482 00483 /** 00484 * Setup the output headers so that the client knows how to authenticate 00485 * itself the next time, if an authentication request failed. This function 00486 * works only for digest authentication 00487 * @param r The current request 00488 * @deffunc void ap_note_digest_auth_failure(request_rec *r) 00489 */ 00490 AP_DECLARE(void) ap_note_digest_auth_failure(request_rec *r); 00491 00492 /** 00493 * Get the password from the request headers 00494 * @param r The current request 00495 * @param pw The password as set in the headers 00496 * @return 0 (OK) if it set the 'pw' argument (and assured 00497 * a correct value in r->user); otherwise it returns 00498 * an error code, either HTTP_INTERNAL_SERVER_ERROR if things are 00499 * really confused, HTTP_UNAUTHORIZED if no authentication at all 00500 * seemed to be in use, or DECLINED if there was authentication but 00501 * it wasn't Basic (in which case, the caller should presumably 00502 * decline as well). 00503 * @deffunc int ap_get_basic_auth_pw(request_rec *r, const char **pw) 00504 */ 00505 AP_DECLARE(int) ap_get_basic_auth_pw(request_rec *r, const char **pw); 00506 00507 /** 00508 * parse_uri: break apart the uri 00509 * @warning Side Effects: <pre> 00510 * - sets r->args to rest after '?' (or NULL if no '?') 00511 * - sets r->uri to request uri (without r->args part) 00512 * - sets r->hostname (if not set already) from request (scheme://host:port) 00513 * </pre> 00514 * @param r The current request 00515 * @param uri The uri to break apart 00516 * @deffunc void ap_parse_uri(request_rec *r, const char *uri) 00517 */ 00518 AP_CORE_DECLARE(void) ap_parse_uri(request_rec *r, const char *uri); 00519 00520 /** 00521 * Get the next line of input for the request 00522 * @param s The buffer into which to read the line 00523 * @param n The size of the buffer 00524 * @param r The request 00525 * @param fold Whether to merge continuation lines 00526 * @return The length of the line, if successful 00527 * n, if the line is too big to fit in the buffer 00528 * -1 for miscellaneous errors 00529 * @deffunc int ap_method_number_of(const char *method) 00530 */ 00531 AP_DECLARE(int) ap_getline(char *s, int n, request_rec *r, int fold); 00532 00533 /** 00534 * Get the next line of input for the request 00535 * 00536 * Note: on ASCII boxes, ap_rgetline is a macro which simply calls 00537 * ap_rgetline_core to get the line of input. 00538 * 00539 * on EBCDIC boxes, ap_rgetline is a wrapper function which 00540 * translates ASCII protocol lines to the local EBCDIC code page 00541 * after getting the line of input. 00542 * 00543 * @param s Pointer to the pointer to the buffer into which the line 00544 * should be read; if *s==NULL, a buffer of the necessary size 00545 * to hold the data will be allocated from the request pool 00546 * @param n The size of the buffer 00547 * @param read The length of the line. 00548 * @param r The request 00549 * @param fold Whether to merge continuation lines 00550 * @param bb Working brigade to use when reading buckets 00551 * @return APR_SUCCESS, if successful 00552 * APR_ENOSPC, if the line is too big to fit in the buffer 00553 * Other errors where appropriate 00554 */ 00555 #if APR_CHARSET_EBCDIC 00556 AP_DECLARE(apr_status_t) ap_rgetline(char **s, apr_size_t n, 00557 apr_size_t *read, 00558 request_rec *r, int fold, 00559 apr_bucket_brigade *bb); 00560 #else /* ASCII box */ 00561 #define ap_rgetline(s, n, read, r, fold, bb) \ 00562 ap_rgetline_core((s), (n), (read), (r), (fold), (bb)) 00563 #endif 00564 AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n, 00565 apr_size_t *read, 00566 request_rec *r, int fold, 00567 apr_bucket_brigade *bb); 00568 00569 /** 00570 * Get the method number associated with the given string, assumed to 00571 * contain an HTTP method. Returns M_INVALID if not recognized. 00572 * @param method A string containing a valid HTTP method 00573 * @return The method number 00574 */ 00575 AP_DECLARE(int) ap_method_number_of(const char *method); 00576 00577 /** 00578 * Get the method name associated with the given internal method 00579 * number. Returns NULL if not recognized. 00580 * @param p A pool to use for temporary allocations. 00581 * @param methnum An integer value corresponding to an internal method number 00582 * @return The name corresponding to the method number 00583 */ 00584 AP_DECLARE(const char *) ap_method_name_of(apr_pool_t *p, int methnum); 00585 00586 00587 /* Hooks */ 00588 /* 00589 * post_read_request --- run right after read_request or internal_redirect, 00590 * and not run during any subrequests. 00591 */ 00592 /** 00593 * This hook allows modules to affect the request immediately after the request 00594 * has been read, and before any other phases have been processes. This allows 00595 * modules to make decisions based upon the input header fields 00596 * @param r The current request 00597 * @return OK or DECLINED 00598 * @deffunc ap_run_post_read_request(request_rec *r) 00599 */ 00600 AP_DECLARE_HOOK(int,post_read_request,(request_rec *r)) 00601 00602 /** 00603 * This hook allows modules to perform any module-specific logging activities 00604 * over and above the normal server things. 00605 * @param r The current request 00606 * @return OK, DECLINED, or HTTP_... 00607 * @deffunc int ap_run_log_transaction(request_rec *r) 00608 */ 00609 AP_DECLARE_HOOK(int,log_transaction,(request_rec *r)) 00610 00611 /** 00612 * This hook allows modules to retrieve the http method from a request. This 00613 * allows Apache modules to easily extend the methods that Apache understands 00614 * @param r The current request 00615 * @return The http method from the request 00616 * @deffunc const char *ap_run_http_method(const request_rec *r) 00617 */ 00618 AP_DECLARE_HOOK(const char *,http_method,(const request_rec *r)) 00619 00620 /** 00621 * Return the default port from the current request 00622 * @param r The current request 00623 * @return The current port 00624 * @deffunc apr_port_t ap_run_default_port(const request_rec *r) 00625 */ 00626 AP_DECLARE_HOOK(apr_port_t,default_port,(const request_rec *r)) 00627 00628 typedef struct ap_bucket_error ap_bucket_error; 00629 00630 /** 00631 * A bucket referring to an HTTP error 00632 * This bucket can be passed down the filter stack to indicate that an 00633 * HTTP error occurred while running a filter. In order for this bucket 00634 * to be used successfully, it MUST be sent as the first bucket in the 00635 * first brigade to be sent from a given filter. 00636 */ 00637 struct ap_bucket_error { 00638 /** Number of buckets using this memory */ 00639 apr_bucket_refcount refcount; 00640 /** The error code */ 00641 int status; 00642 /** The error string */ 00643 const char *data; 00644 }; 00645 00646 AP_DECLARE_DATA extern const apr_bucket_type_t ap_bucket_type_error; 00647 00648 /** 00649 * Determine if a bucket is an error bucket 00650 * @param e The bucket to inspect 00651 * @return true or false 00652 */ 00653 #define AP_BUCKET_IS_ERROR(e) (e->type == &ap_bucket_type_error) 00654 00655 /** 00656 * Make the bucket passed in an error bucket 00657 * @param b The bucket to make into an error bucket 00658 * @param error The HTTP error code to put in the bucket. 00659 * @param buf An optional error string to put in the bucket. 00660 * @param p A pool to allocate out of. 00661 * @return The new bucket, or NULL if allocation failed 00662 * @deffunc apr_bucket *ap_bucket_error_make(apr_bucket *b, int error, const char *buf, apr_pool_t *p) 00663 */ 00664 AP_DECLARE(apr_bucket *) ap_bucket_error_make(apr_bucket *b, int error, 00665 const char *buf, apr_pool_t *p); 00666 00667 /** 00668 * Create a bucket referring to an HTTP error. 00669 * @param error The HTTP error code to put in the bucket. 00670 * @param buf An optional error string to put in the bucket. 00671 * @param p A pool to allocate the error string out of. 00672 * @param list The bucket allocator from which to allocate the bucket 00673 * @return The new bucket, or NULL if allocation failed 00674 * @deffunc apr_bucket *ap_bucket_error_create(int error, const char *buf, apr_pool_t *p, apr_bucket_alloc_t *list) 00675 */ 00676 AP_DECLARE(apr_bucket *) ap_bucket_error_create(int error, const char *buf, 00677 apr_pool_t *p, 00678 apr_bucket_alloc_t *list); 00679 00680 AP_DECLARE_NONSTD(apr_status_t) ap_byterange_filter(ap_filter_t *f, apr_bucket_brigade *b); 00681 AP_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, apr_bucket_brigade *b); 00682 AP_DECLARE_NONSTD(apr_status_t) ap_content_length_filter(ap_filter_t *, 00683 apr_bucket_brigade *); 00684 AP_DECLARE_NONSTD(apr_status_t) ap_old_write_filter(ap_filter_t *f, apr_bucket_brigade *b); 00685 00686 /* 00687 * Setting up the protocol fields for subsidiary requests... 00688 * Also, a wrapup function to keep the internal accounting straight. 00689 */ 00690 AP_DECLARE(void) ap_set_sub_req_protocol(request_rec *rnew, const request_rec *r); 00691 AP_DECLARE(void) ap_finalize_sub_req_protocol(request_rec *sub_r); 00692 00693 #ifdef __cplusplus 00694 } 00695 #endif 00696 00697 #endif /* !APACHE_HTTP_PROTOCOL_H */