| 74 | } |
| 75 | |
| 76 | static void ap_die_r(int type, request_rec *r, int recursive_error) |
| 77 | { |
| 78 | char *custom_response; |
| 79 | request_rec *r_1st_err = r; |
| 80 | |
| 81 | if (type == OK || type == DONE) { |
| 82 | ap_finalize_request_protocol(r); |
| 83 | return; |
| 84 | } |
| 85 | |
| 86 | if (!ap_is_HTTP_VALID_RESPONSE(type)) { |
| 87 | ap_filter_t *next; |
| 88 | |
| 89 | /* |
| 90 | * Check if we still have the ap_http_header_filter in place. If |
| 91 | * this is the case we should not ignore the error here because |
| 92 | * it means that we have not sent any response at all and never |
| 93 | * will. This is bad. Sent an internal server error instead. |
| 94 | */ |
| 95 | next = r->output_filters; |
| 96 | while (next && (next->frec != ap_http_header_filter_handle)) { |
| 97 | next = next->next; |
| 98 | } |
| 99 | |
| 100 | /* |
| 101 | * If next != NULL then we left the while above because of |
| 102 | * next->frec == ap_http_header_filter |
| 103 | */ |
| 104 | if (next) { |
| 105 | if (type != AP_FILTER_ERROR) { |
| 106 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01579) |
| 107 | "Invalid response status %i", type); |
| 108 | } |
| 109 | else { |
| 110 | ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02831) |
| 111 | "Response from AP_FILTER_ERROR"); |
| 112 | } |
| 113 | type = HTTP_INTERNAL_SERVER_ERROR; |
| 114 | } |
| 115 | else { |
| 116 | return; |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | /* |
| 121 | * The following takes care of Apache redirects to custom response URLs |
| 122 | * Note that if we are already dealing with the response to some other |
| 123 | * error condition, we just report on the original error, and give up on |
| 124 | * any attempt to handle the other thing "intelligently"... |
| 125 | */ |
| 126 | if (recursive_error != HTTP_OK) { |
| 127 | while (r_1st_err->prev && (r_1st_err->prev->status != HTTP_OK)) |
| 128 | r_1st_err = r_1st_err->prev; /* Get back to original error */ |
| 129 | |
| 130 | if (r_1st_err != r) { |
| 131 | /* The recursive error was caused by an ErrorDocument specifying |
| 132 | * an internal redirect to a bad URI. ap_internal_redirect has |
| 133 | * changed the filter chains to point to the ErrorDocument's |
no test coverage detected