* Handle the preamble through the H1 tag line, 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 HEADER.gif) might get multiviewed as the result * instead of a text document, meaning nothing will be
| 998 | * oh well. |
| 999 | */ |
| 1000 | static void emit_head(request_rec *r, char *header_fname, int suppress_amble, |
| 1001 | int emit_xhtml, char *title) |
| 1002 | { |
| 1003 | autoindex_config_rec *d; |
| 1004 | apr_table_t *hdrs = r->headers_in; |
| 1005 | apr_file_t *f = NULL; |
| 1006 | request_rec *rr = NULL; |
| 1007 | int emit_amble = 1; |
| 1008 | int emit_H1 = 1; |
| 1009 | const char *r_accept; |
| 1010 | const char *r_accept_enc; |
| 1011 | |
| 1012 | /* |
| 1013 | * If there's a header file, send a subrequest to look for it. If it's |
| 1014 | * found and html do the subrequest, otherwise handle it |
| 1015 | */ |
| 1016 | r_accept = apr_table_get(hdrs, "Accept"); |
| 1017 | r_accept_enc = apr_table_get(hdrs, "Accept-Encoding"); |
| 1018 | apr_table_setn(hdrs, "Accept", "text/html, text/plain"); |
| 1019 | apr_table_unset(hdrs, "Accept-Encoding"); |
| 1020 | |
| 1021 | |
| 1022 | if ((header_fname != NULL) && r->args) { |
| 1023 | header_fname = apr_pstrcat(r->pool, header_fname, "?", r->args, NULL); |
| 1024 | } |
| 1025 | |
| 1026 | if ((header_fname != NULL) |
| 1027 | && (rr = ap_sub_req_lookup_uri(header_fname, r, r->output_filters)) |
| 1028 | && (rr->status == HTTP_OK) |
| 1029 | && (rr->filename != NULL) |
| 1030 | && (rr->finfo.filetype == APR_REG)) { |
| 1031 | /* |
| 1032 | * Check for the two specific cases we allow: text/html and |
| 1033 | * text/anything-else. The former is allowed to be processed for |
| 1034 | * SSIs. |
| 1035 | */ |
| 1036 | if (rr->content_type != NULL) { |
| 1037 | if (response_is_html(rr)) { |
| 1038 | ap_filter_t *f; |
| 1039 | /* Hope everything will work... */ |
| 1040 | emit_amble = 0; |
| 1041 | emit_H1 = 0; |
| 1042 | |
| 1043 | if (! suppress_amble) { |
| 1044 | emit_preamble(r, emit_xhtml, title); |
| 1045 | } |
| 1046 | /* This is a hack, but I can't find any better way to do this. |
| 1047 | * The problem is that we have already created the sub-request, |
| 1048 | * but we just inserted the OLD_WRITE filter, and the |
| 1049 | * sub-request needs to pass its data through the OLD_WRITE |
| 1050 | * filter, or things go horribly wrong (missing data, data in |
| 1051 | * the wrong order, etc). To fix it, if you create a |
| 1052 | * sub-request and then insert the OLD_WRITE filter before you |
| 1053 | * run the request, you need to make sure that the sub-request |
| 1054 | * data goes through the OLD_WRITE filter. Just steal this |
| 1055 | * code. The long-term solution is to remove the ap_r* |
| 1056 | * functions. |
| 1057 | */ |
no test coverage detected