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