apr_array_header_t *avail_vars; /* available variants */
int
count_multiviews_variants;
/* number of variants found on disk */
int
is_transparent;
/* 1 if this resource is trans. negotiable */
int
dont_fiddle_headers;
/* 1 if we may not fiddle with accept hdrs */
int
ua_supports_trans;
/* 1 if ua supports trans negotiation */
int
send_alternates;
/* 1 if we want to send an Alternates header */
int
may_choose;
/* 1 if we may choose a variant for the client */
int
use_rvsa;
/* 1 if we must use RVSA/1.0 negotiation algo */
} negotiation_state;
typedef struct { apr_pool_t *pool; request_rec *r; neg_dir_config *conf; char *dir_name; int accept_q; /* 1 if an Accept item has a q= param */ float default_lang_quality; /* fiddle lang q for variants with no lang */ /* the array pointers below are NULL if the corresponding accept * headers are not present */ apr_array_header_t *accepts; /* accept_recs */ apr_array_header_t *accept_encodings; /* accept_recs */ apr_array_header_t *accept_charsets; /* accept_recs */ apr_array_header_t *accept_langs; /* accept_recs */ apr_array_header_t *avail_vars; /* available variants */ int count_multiviews_variants; /* number of variants found on disk */ int is_transparent; /* 1 if this resource is trans. negotiable */ int dont_fiddle_headers; /* 1 if we may not fiddle with accept hdrs */ int ua_supports_trans; /* 1 if ua supports trans negotiation */ int send_alternates; /* 1 if we want to send an Alternates header */ int may_choose; /* 1 if we may choose a variant for the client */ int use_rvsa; /* 1 if we must use RVSA/1.0 negotiation algo */ } negotiation_state;
对于协商的表达方式都是一样的,如:
Accept: */*
Accept-Language: zh-cn,zh;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: GB2312,utf-8;q=0.7,*;q=0.7
其中“,”和“;”的分隔或许不太好明白其含义,其实,其格式是这样的:
name;q=N;charset=TEXT
如果要表达多组,则用“,”分隔;如:
name;q=N;charset=TEXT,name;q=N;charset=TEXT
其中,q、charset都是可以省略的,如:
Accept: */*
只有一组说明,而且是省略了q和charset
相关源码参考:
modules/mappers/mod_negotiation.c
typedef
struct
accept_rec {
char
*name;
/* MUST be lowercase */
float
quality;
float
level;
char
*charset;
/* for content-type only */
} accept_rec;
typedef struct accept_rec { char *name; /* MUST be lowercase */ float quality; float level; char *charset; /* for content-type only */ } accept_rec;