* find_ct is the hook routine for determining content-type and other * MIME-related metadata. It assumes that r->filename has already been * set and stat has been called for r->finfo. It also assumes that the * non-path base file name is not the empty string unless it is a dir. */
| 751 | * non-path base file name is not the empty string unless it is a dir. |
| 752 | */ |
| 753 | static int find_ct(request_rec *r) |
| 754 | { |
| 755 | mime_dir_config *conf; |
| 756 | apr_array_header_t *exception_list; |
| 757 | char *ext; |
| 758 | const char *fn, *fntmp, *type, *charset = NULL, *resource_name, *qm; |
| 759 | int found_metadata = 0; |
| 760 | |
| 761 | if (r->finfo.filetype == APR_DIR) { |
| 762 | ap_set_content_type_ex(r, DIR_MAGIC_TYPE, 1); |
| 763 | return OK; |
| 764 | } |
| 765 | |
| 766 | if (!r->filename) { |
| 767 | return DECLINED; |
| 768 | } |
| 769 | |
| 770 | conf = (mime_dir_config *)ap_get_module_config(r->per_dir_config, |
| 771 | &mime_module); |
| 772 | exception_list = apr_array_make(r->pool, 2, sizeof(char *)); |
| 773 | |
| 774 | /* If use_path_info is explicitly set to on (value & 1 == 1), append. */ |
| 775 | if (conf->use_path_info & 1) { |
| 776 | resource_name = apr_pstrcat(r->pool, r->filename, r->path_info, NULL); |
| 777 | } |
| 778 | /* |
| 779 | * In the reverse proxy case r->filename might contain a query string if |
| 780 | * the nocanon option was used with ProxyPass. |
| 781 | * If this is the case cut off the query string as the last parameter in |
| 782 | * this query string might end up on an extension we take care about, but |
| 783 | * we only want to match against path components not against query |
| 784 | * parameters. |
| 785 | */ |
| 786 | else if ((r->proxyreq == PROXYREQ_REVERSE) |
| 787 | && (apr_table_get(r->notes, "proxy-nocanon")) |
| 788 | && ((qm = ap_strchr_c(r->filename, '?')) != NULL)) { |
| 789 | resource_name = apr_pstrmemdup(r->pool, r->filename, qm - r->filename); |
| 790 | } |
| 791 | else { |
| 792 | resource_name = r->filename; |
| 793 | } |
| 794 | |
| 795 | /* Always drop the path leading up to the file name. |
| 796 | */ |
| 797 | if ((fn = ap_strrchr_c(resource_name, '/')) == NULL) { |
| 798 | fn = resource_name; |
| 799 | } |
| 800 | else { |
| 801 | ++fn; |
| 802 | } |
| 803 | |
| 804 | |
| 805 | /* The exception list keeps track of those filename components that |
| 806 | * are not associated with extensions indicating metadata. |
| 807 | * The base name is always the first exception (i.e., "txt.html" has |
| 808 | * a basename of "txt" even though it might look like an extension). |
| 809 | * Leading dots are considered to be part of the base name (a file named |
| 810 | * ".png" is likely not a png file but just a hidden file called png). |
nothing calls this directly
no test coverage detected