* Handle the Readme file through the postamble, inclusive. Locate * the file with a subrequests. Process text/html documents by actually * running the subrequest; text/xxx documents get copied verbatim, * and any other content type is ignored. This means that a non-text * document (such as FOOTER.gif) might get multiviewed as the result * instead of a text document, meaning nothing will be
| 1130 | * oh well. |
| 1131 | */ |
| 1132 | static void emit_tail(request_rec *r, char *readme_fname, int suppress_amble) |
| 1133 | { |
| 1134 | apr_file_t *f = NULL; |
| 1135 | request_rec *rr = NULL; |
| 1136 | int suppress_post = 0; |
| 1137 | int suppress_sig = 0; |
| 1138 | |
| 1139 | /* |
| 1140 | * If there's a readme file, send a subrequest to look for it. If it's |
| 1141 | * found and a text file, handle it -- otherwise fall through and |
| 1142 | * pretend there's nothing there. |
| 1143 | */ |
| 1144 | if ((readme_fname != NULL) |
| 1145 | && (rr = ap_sub_req_lookup_uri(readme_fname, r, r->output_filters)) |
| 1146 | && (rr->status == HTTP_OK) |
| 1147 | && (rr->filename != NULL) |
| 1148 | && rr->finfo.filetype == APR_REG) { |
| 1149 | /* |
| 1150 | * Check for the two specific cases we allow: text/html and |
| 1151 | * text/anything-else. The former is allowed to be processed for |
| 1152 | * SSIs. |
| 1153 | */ |
| 1154 | if (rr->content_type != NULL) { |
| 1155 | if (response_is_html(rr)) { |
| 1156 | ap_filter_t *f; |
| 1157 | for (f=rr->output_filters; |
| 1158 | f->frec != ap_subreq_core_filter_handle; f = f->next); |
| 1159 | f->next = r->output_filters; |
| 1160 | |
| 1161 | |
| 1162 | if (ap_run_sub_req(rr) == OK) { |
| 1163 | /* worked... */ |
| 1164 | suppress_sig = 1; |
| 1165 | suppress_post = suppress_amble; |
| 1166 | } |
| 1167 | } |
| 1168 | else if (!ap_cstr_casecmpn("text/", rr->content_type, 5)) { |
| 1169 | /* |
| 1170 | * If we can open the file, suppress the signature. |
| 1171 | */ |
| 1172 | if (apr_file_open(&f, rr->filename, APR_READ, |
| 1173 | APR_OS_DEFAULT, r->pool) == APR_SUCCESS) { |
| 1174 | do_emit_plain(r, f); |
| 1175 | apr_file_close(f); |
| 1176 | suppress_sig = 1; |
| 1177 | } |
| 1178 | } |
| 1179 | } |
| 1180 | } |
| 1181 | |
| 1182 | if (!suppress_sig) { |
| 1183 | ap_rputs(ap_psignature("", r), r); |
| 1184 | } |
| 1185 | if (!suppress_post) { |
| 1186 | ap_rputs("</body></html>\n", r); |
| 1187 | } |
| 1188 | if (rr != NULL) { |
| 1189 | ap_destroy_sub_req(rr); |
no test coverage detected