| 608 | |
| 609 | |
| 610 | static void parse_negotiate_header(request_rec *r, negotiation_state *neg) |
| 611 | { |
| 612 | const char *negotiate = apr_table_get(r->headers_in, "Negotiate"); |
| 613 | char *tok; |
| 614 | |
| 615 | /* First, default to no TCN, no Alternates, and the original Apache |
| 616 | * negotiation algorithm with fiddles for broken browser configs. |
| 617 | * |
| 618 | * To save network bandwidth, we do not configure to send an |
| 619 | * Alternates header to the user agent by default. User |
| 620 | * agents that want an Alternates header for agent-driven |
| 621 | * negotiation will have to request it by sending an |
| 622 | * appropriate Negotiate header. |
| 623 | */ |
| 624 | neg->ua_supports_trans = 0; |
| 625 | neg->send_alternates = 0; |
| 626 | neg->may_choose = 1; |
| 627 | neg->use_rvsa = 0; |
| 628 | neg->dont_fiddle_headers = 0; |
| 629 | |
| 630 | if (!negotiate) |
| 631 | return; |
| 632 | |
| 633 | if (strcmp(negotiate, "trans") == 0) { |
| 634 | /* Lynx 2.7 and 2.8 send 'negotiate: trans' even though they |
| 635 | * do not support transparent content negotiation, so for Lynx we |
| 636 | * ignore the negotiate header when its contents are exactly "trans". |
| 637 | * If future versions of Lynx ever need to say 'negotiate: trans', |
| 638 | * they can send the equivalent 'negotiate: trans, trans' instead |
| 639 | * to avoid triggering the workaround below. |
| 640 | */ |
| 641 | const char *ua = apr_table_get(r->headers_in, "User-Agent"); |
| 642 | |
| 643 | if (ua && (strncmp(ua, "Lynx", 4) == 0)) |
| 644 | return; |
| 645 | } |
| 646 | |
| 647 | neg->may_choose = 0; /* An empty Negotiate would require 300 response */ |
| 648 | |
| 649 | while ((tok = ap_get_list_item(neg->pool, &negotiate)) != NULL) { |
| 650 | |
| 651 | if (strcmp(tok, "trans") == 0 || |
| 652 | strcmp(tok, "vlist") == 0 || |
| 653 | strcmp(tok, "guess-small") == 0 || |
| 654 | apr_isdigit(tok[0]) || |
| 655 | strcmp(tok, "*") == 0) { |
| 656 | |
| 657 | /* The user agent supports transparent negotiation */ |
| 658 | neg->ua_supports_trans = 1; |
| 659 | |
| 660 | /* Send-alternates could be configurable, but note |
| 661 | * that it must be 1 if we have 'vlist' in the |
| 662 | * negotiate header. |
| 663 | */ |
| 664 | neg->send_alternates = 1; |
| 665 | |
| 666 | if (strcmp(tok, "1.0") == 0) { |
| 667 | /* we may use the RVSA/1.0 algorithm, configure for it */ |
no test coverage detected