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

Function do_negotiation

modules/mappers/mod_negotiation.c:2808–2952  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2806 */
2807
2808static int do_negotiation(request_rec *r, negotiation_state *neg,
2809 var_rec **bestp, int prefer_scripts)
2810{
2811 var_rec *avail_recs = (var_rec *) neg->avail_vars->elts;
2812 int alg_result; /* result of variant selection algorithm */
2813 int res;
2814 int j;
2815
2816 /* Decide if resource is transparently negotiable */
2817
2818 /* GET or HEAD? (HEAD has same method number as GET) */
2819 if (r->method_number == M_GET) {
2820
2821 /* maybe this should be configurable, see also the comment
2822 * about recursive type maps in setup_choice_response()
2823 */
2824 neg->is_transparent = 1;
2825
2826 /* We can't be transparent if we are a map file in the middle
2827 * of the request URI.
2828 */
2829 if (r->path_info && *r->path_info)
2830 neg->is_transparent = 0;
2831
2832 for (j = 0; j < neg->avail_vars->nelts; ++j) {
2833 var_rec *variant = &avail_recs[j];
2834
2835 /* We can't be transparent, because of internal
2836 * assumptions in best_match(), if there is a
2837 * non-neighboring variant. We can have a non-neighboring
2838 * variant when processing a type map.
2839 */
2840 if (ap_strchr_c(variant->file_name, '/'))
2841 neg->is_transparent = 0;
2842
2843 /* We can't be transparent, because of the behavior
2844 * of variant typemap bodies.
2845 */
2846 if (variant->body) {
2847 neg->is_transparent = 0;
2848 }
2849 }
2850 }
2851
2852 if (neg->is_transparent) {
2853 parse_negotiate_header(r, neg);
2854 }
2855 else { /* configure negotiation on non-transparent resource */
2856 neg->may_choose = 1;
2857 }
2858
2859 maybe_add_default_accepts(neg, prefer_scripts);
2860
2861 alg_result = best_match(neg, bestp);
2862
2863 /* alg_result is one of
2864 * alg_choice: a best variant is chosen
2865 * alg_list: no best variant is chosen

Callers 2

handle_map_fileFunction · 0.85
handle_multiFunction · 0.85

Calls 8

ap_strchr_cFunction · 0.85
parse_negotiate_headerFunction · 0.85
best_matchFunction · 0.85
set_neg_headersFunction · 0.85
store_variant_listFunction · 0.85
setup_choice_responseFunction · 0.85
do_cache_negotiated_docsFunction · 0.85

Tested by

no test coverage detected