MCPcopy Create free account
hub / github.com/apache/httpd / emit_tail

Function emit_tail

modules/generators/mod_autoindex.c:1132–1191  ·  view source on GitHub ↗

* 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

Source from the content-addressed store, hash-verified

1130 * oh well.
1131 */
1132static 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);

Callers 1

index_directoryFunction · 0.85

Calls 8

ap_sub_req_lookup_uriFunction · 0.85
response_is_htmlFunction · 0.85
ap_run_sub_reqFunction · 0.85
ap_cstr_casecmpnFunction · 0.85
do_emit_plainFunction · 0.85
ap_rputsFunction · 0.85
ap_psignatureFunction · 0.85
ap_destroy_sub_reqFunction · 0.85

Tested by

no test coverage detected