cvs commit: apache/src mod_negotiation.c

1997-11-05 Thread dgaudet
dgaudet 97/11/05 03:48:31

  Modified:src  Tag: APACHE_1_2_X mod_negotiation.c
  Log:
  Fix undefined C behaviour.
  
  Submitted by: Ben Laurie
  Reviewed by:  Dean Gaudet, Ralf Engelschall
  
  Revision  ChangesPath
  No   revision
  
  
  No   revision
  
  
  1.40.2.3  +3 -2  apache/src/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===
  RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
  retrieving revision 1.40.2.2
  retrieving revision 1.40.2.3
  diff -u -r1.40.2.2 -r1.40.2.3
  --- mod_negotiation.c 1997/07/19 08:17:16 1.40.2.2
  +++ mod_negotiation.c 1997/11/05 11:48:30 1.40.2.3
  @@ -623,8 +623,9 @@
   {
   char *cp = header;
   
  -while (*cp && *cp != ':')
  -*cp++ = tolower(*cp);
  +for ( ; *cp && *cp != ':' ; ++cp) {
  +*cp = tolower(*cp);
  +}
   
   if (!*cp) {
log_reason ("Syntax error in type map --- no ':'", r->filename, r);
  
  
  


cvs commit: apache/src mod_negotiation.c

1997-07-19 Thread Dean Gaudet
dgaudet 97/07/19 01:17:18

  Modified:src   Tag: APACHE_1_2_X  mod_negotiation.c
  Log:
  Minor tweak to fix a problem with the fix to PR#94.
  
  Reviewed by:  Alexei Kosut, Randy Terbush
  Submitted by: Paul Sutton
  
  Revision  ChangesPath
  No   revision
  
  
  No   revision
  
  
  1.40.2.2  +2 -0  apache/src/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===
  RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
  retrieving revision 1.40.2.1
  retrieving revision 1.40.2.2
  diff -C3 -r1.40.2.1 -r1.40.2.2
  *** mod_negotiation.c 1997/06/27 02:20:19 1.40.2.1
  --- mod_negotiation.c 1997/07/19 08:17:16 1.40.2.2
  ***
  *** 1443,1448 
  --- 1443,1449 
   the same charset quality, then we prefer this variant */
if (variant->charset_quality == best->charset_quality &&
(variant->content_charset != NULL &&
  +  *variant->content_charset != '\0' &&
 strcmp(variant->content_charset, "iso-8859-1") != 0) &&
(best->content_charset == NULL ||
 *best->content_charset == '\0' ||
  ***
  *** 1545,1550 
  --- 1546,1552 
   the same charset quality, then we prefer this variant */
if (variant->charset_quality > best->charset_quality ||
((variant->content_charset != NULL &&
  +   *variant->content_charset != '\0' &&
  strcmp(variant->content_charset, "iso-8859-1") != 0) &&
 (best->content_charset == NULL ||
  *best->content_charset == '\0' ||
  
  
  


cvs commit: apache/src mod_negotiation.c

1997-07-19 Thread Dean Gaudet
dgaudet 97/07/19 01:16:15

  Modified:src   mod_negotiation.c
  Log:
  PR#94: Content negot fails unless each varient has a charset
  This was applied to 1.2.1 but missed in 1.3.  We also include here a
  later update from Paul.
  
  Reviewed by:  Dean Gaudet, Alexei Kosut, Randy Terbush
  Submitted by: Paul Sutton
  
  Revision  ChangesPath
  1.50  +12 -5 apache/src/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===
  RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -C3 -r1.49 -r1.50
  *** mod_negotiation.c 1997/07/17 22:27:40 1.49
  --- mod_negotiation.c 1997/07/19 08:16:14 1.50
  ***
  *** 1443,1450 
/* If the best variant's charset is ISO-8859-1 and this variant has
   the same charset quality, then we prefer this variant */
if (variant->charset_quality == best->charset_quality &&
  ! (best->content_charset == NULL || *best->content_charset == 0 ||
  ! strcmp(best->content_charset, "iso-8859-1") == 0)) {
*p_bestq = q;
return 1;
}
  --- 1443,1454 
/* If the best variant's charset is ISO-8859-1 and this variant has
   the same charset quality, then we prefer this variant */
if (variant->charset_quality == best->charset_quality &&
  ! (variant->content_charset != NULL &&
  !  *variant->content_charset != '\0' &&
  !  strcmp(variant->content_charset, "iso-8859-1") != 0) &&
  ! (best->content_charset == NULL ||
  !  *best->content_charset == '\0' ||
  !  strcmp(best->content_charset, "iso-8859-1") == 0)) {
*p_bestq = q;
return 1;
}
  ***
  *** 1542,1550 
/* If the best variant's charset is ISO-8859-1 and this variant has
   the same charset quality, then we prefer this variant */
if (variant->charset_quality > best->charset_quality ||
  ! (variant->charset_quality == best->charset_quality &&
  ! (best->content_charset == NULL || *best->content_charset == 0 ||
  ! strcmp(best->content_charset, "iso-8859-1") == 0))) {
*p_bestq = q;
return 1;
}
  --- 1546,1557 
/* If the best variant's charset is ISO-8859-1 and this variant has
   the same charset quality, then we prefer this variant */
if (variant->charset_quality > best->charset_quality ||
  ! ((variant->content_charset != NULL &&
  !   *variant->content_charset != '\0' &&
  !   strcmp(variant->content_charset, "iso-8859-1") != 0) &&
  !  (best->content_charset == NULL ||
  !   *best->content_charset == '\0' ||
  !   strcmp(best->content_charset, "iso-8859-1") == 0))) {
*p_bestq = q;
return 1;
}
  
  
  


cvs commit: apache/src mod_negotiation.c

1997-02-06 Thread Marc Slemko
marc97/02/06 23:13:16

  Modified:src   mod_negotiation.c
  Log:
  handle_multi() was not setting content_language.
  
  Submitted by: Petr Lampa <[EMAIL PROTECTED]>
  Reviewed by: Paul Sutton, Marc Slemko, Dean Gaudet
  
  Revision  ChangesPath
  1.32  +1 -0  apache/src/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===
  RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -C3 -r1.31 -r1.32
  *** mod_negotiation.c 1997/02/07 06:36:07 1.31
  --- mod_negotiation.c 1997/02/07 07:13:15 1.32
  ***
  *** 1940,1945 
  --- 1940,1946 
r->content_type = sub_req->content_type;
r->content_encoding = sub_req->content_encoding;
r->content_languages = sub_req->content_languages;
  + r->content_language = sub_req->content_language;
r->finfo = sub_req->finfo;

return OK;
  
  
  


cvs commit: apache/src mod_negotiation.c

1996-12-21 Thread Brian Behlendorf
brian   96/12/21 19:47:16

  Modified:src   mod_negotiation.c
  Log:
  Reviewed by:  Randy Terbush, Brian Behlendorf
  Submitted by: Paul Sutton
  
  Change name of #define to make it clear this complies with draft 02 of Koen's
  conneg proposal.
  
  Revision  ChangesPath
  1.28  +3 -3  apache/src/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===
  RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -C3 -r1.27 -r1.28
  *** mod_negotiation.c 1996/12/09 04:37:03 1.27
  --- mod_negotiation.c 1996/12/22 03:47:14 1.28
  ***
  *** 63,76 
#include "http_core.h"
#include "http_log.h"

  ! /* define HOLTMAN to allow for Holtman I-D transparent negotiation.
 * This file currently implements the draft-02, except for
 * anything to do with features and cache-control (max-age etc)
 *
 * Since the draft is just that, and we don't yet implement
 * everything, regard the transparent negotiation stuff as experimental.
 */
  ! /*#define HOLTMAN*/

/* Commands --- configuring document caching on a per (virtual?)
 * server basis...
  --- 63,76 
#include "http_core.h"
#include "http_log.h"

  ! /* define TCN_02 to allow for Holtman I-D transparent negotiation.
 * This file currently implements the draft-02, except for
 * anything to do with features and cache-control (max-age etc)
 *
 * Since the draft is just that, and we don't yet implement
 * everything, regard the transparent negotiation stuff as experimental.
 */
  ! /*#define TCN_02*/

/* Commands --- configuring document caching on a per (virtual?)
 * server basis...
  ***
  *** 455,461 
  do_header_line (r->pool, table_get (hdrs, "Accept-charset"));
new->avail_vars = make_array (r->pool, 40, sizeof (var_rec));

  ! #ifdef HOLTMAN
if (table_get(r->headers_in, "Negotiate")) {
/* Negotiate: header tells us UA does transparent negotiation
 * We have to decide whether we want to ... for now, yes,
  --- 455,461 
  do_header_line (r->pool, table_get (hdrs, "Accept-charset"));
new->avail_vars = make_array (r->pool, 40, sizeof (var_rec));

  ! #ifdef TCN_02
if (table_get(r->headers_in, "Negotiate")) {
/* Negotiate: header tells us UA does transparent negotiation
 * We have to decide whether we want to ... for now, yes,
  
  
  


cvs commit: apache/src mod_negotiation.c

1996-12-08 Thread Alexei Kosut
akosut  96/12/08 20:37:05

  Modified:src   mod_negotiation.c
  Log:
  Fix infinite loop when processing Content-language lines in type-map files.
  
  Reviewed by: Randy Terbush, Chuck Murcko
  
  Revision  ChangesPath
  1.27  +1 -1  apache/src/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===
  RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -C3 -r1.26 -r1.27
  *** mod_negotiation.c 1996/12/09 03:56:24 1.26
  --- mod_negotiation.c 1996/12/09 04:37:03 1.27
  ***
  *** 417,423 
char **new = (char **)push_array (lang_recs);
*new = get_token (p, lang_line, 0);
str_tolower (*new);
  ! if (**lang_line == ',')
++(*lang_line);
}

  --- 417,423 
char **new = (char **)push_array (lang_recs);
*new = get_token (p, lang_line, 0);
str_tolower (*new);
  ! if (**lang_line == ',' || **lang_line == ';')
++(*lang_line);
}

  
  
  


cvs commit: apache/src mod_negotiation.c

1996-12-08 Thread Brian Behlendorf
brian   96/12/08 19:56:26

  Modified:src   mod_negotiation.c
  Log:
  Typo.
  
  Revision  ChangesPath
  1.26  +1 -1  apache/src/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===
  RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -C3 -r1.25 -r1.26
  *** mod_negotiation.c 1996/12/01 20:29:17 1.25
  --- mod_negotiation.c 1996/12/09 03:56:24 1.26
  ***
  *** 1062,1068 

}
else if (naccept) {
  ! /* Variant has one (or more) langauges, and we have one (or more)
 * language ranges on the Accept-Language header. Look for
 * the best match. We do this by going through each language
 * on the variant description looking for a match on the
  --- 1062,1068 

}
else if (naccept) {
  ! /* Variant has one (or more) languages, and we have one (or more)
 * language ranges on the Accept-Language header. Look for
 * the best match. We do this by going through each language
 * on the variant description looking for a match on the
  
  
  


cvs commit: apache/src mod_negotiation.c

1996-10-29 Thread Paul Sutton
pcs 96/10/29 07:23:05

  Modified:src   mod_negotiation.c
  Log:
  Reviewed By: Brian Behlendorf, Jim Jagielski
  
  Update mod_negotation.c to support variants with multiple language
  types. Languages can either be obtained from file extensions
  (eg foo.fr.en.html) or on the Content-Language line in a type-map
  file (eg Content-Language: fr, en).
  
  This patch:
  
  * Allows multiple comma separated languages on the Content-Language:
header in a type-map file
  
  * Updates the function which sets the language quality factor for
each variant to select the best (highest q) match from the tags
of the variant, using the algorithm in HTTP/1.1 14.4
  
  * If the new (HTTP/1.1) language negotiation results in a tie between
variants, falls back onto the Apache 1.1 language negotiation
algorythm, using _just_ the first language of the variant
  
  * Updates the 406 text and Alternates header to list multiple languages
if necessary
  
  Revision  ChangesPath
  1.23  +174 -89   apache/src/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===
  RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -C3 -r1.22 -r1.23
  *** mod_negotiation.c 1996/10/28 16:28:17 1.22
  --- mod_negotiation.c 1996/10/29 15:23:03 1.23
  ***
  *** 82,87 
  --- 82,98 

module negotiation_module;

  + char *merge_string_array (pool *p, array_header *arr, char *sep)
  + {
  + int i;
  + char *t = "";
  + 
  + for (i = 0; i < arr->nelts; i++) {
  + t = pstrcat(p, t, i ? sep : "", ((char**)arr->elts)[i], NULL);
  + }
  + return t;
  + }
  + 
void *create_neg_dir_config (pool *p, char *dummy)
{
neg_dir_config *new =
  ***
  *** 162,168 
char *type_name;
char *file_name;
char *content_encoding;
  ! char *content_language;
char *content_charset;
char *description;

  --- 173,179 
char *type_name;
char *file_name;
char *content_encoding;
  ! array_header *content_languages; /* list of languages for this variant 
*/
char *content_charset;
char *description;

  ***
  *** 230,236 
mime_info->type_name = "";
mime_info->file_name = "";
mime_info->content_encoding = "";
  ! mime_info->content_language = "";
mime_info->content_charset = "";
mime_info->description = "";

  --- 241,247 
mime_info->type_name = "";
mime_info->file_name = "";
mime_info->content_encoding = "";
  ! mime_info->content_languages = NULL;
mime_info->content_charset = "";
mime_info->description = "";

  ***
  *** 392,397 
  --- 403,429 
return accept_recs;
}

  + /* Given the text of the Content-Languages: line from the var map file,
  +  * return an array containing the languages of this variant
  +  */
  + 
  + array_header *do_languages_line (pool *p, char **lang_line)
  + {
  + array_header *lang_recs = make_array (p, 2, sizeof (char *));
  +   
  + if (!lang_line) return lang_recs;
  + 
  + while (**lang_line) {
  + char **new = (char **)push_array (lang_recs);
  + *new = get_token (p, lang_line, 0);
  + str_tolower (*new);
  + if (**lang_line == ',')
  + ++(*lang_line);
  + }
  + 
  + return lang_recs;
  + }
  + 
/*
 *
 * Handling header lines from clients...
  ***
  *** 648,655 
mime_info.bytes = atoi(body);
}
else if (!strncmp (buffer, "content-language:", 17)) {
  ! mime_info.content_language = get_token (neg->pool, &body, 0);
  ! str_tolower (mime_info.content_language);
}
else if (!strncmp (buffer, "content-encoding:", 17)) {
mime_info.content_encoding = get_token (neg->pool, &body, 0);
  --- 680,687 
mime_info.bytes = atoi(body);
}
else if (!strncmp (buffer, "content-language:", 17)) {
  ! mime_info.content_languages = 
  ! do_languages_line(neg->pool, &body);
}
else if (!strncmp (buffer, "content-encoding:", 17)) {
mime_info.content_encoding = get_token (neg->pool, &body, 0);
  ***
  *** 756,764 
mime_info.content_encoding = sub_req->content_encoding;
str_tolower(mime_info.content_encoding);
}
  ! if (sub_req->content_language) {
  ! mime_info.content_language = sub_req->content_language;
  ! str_tolower(mime_info.content_language);
}

get_entry (neg->pool, &accept_info, sub_req->content_type);
  --- 788,800 

cvs commit: apache/src mod_negotiation.c

1996-10-28 Thread Paul Sutton
pcs 96/10/28 08:28:18

  Modified:src   mod_negotiation.c
  Log:
  Bug fixes for Holtman transparent negotiation implementation. Not active
  unless compiled with #define HOLTMAN (see comments in the code). Protocol
  bugs noticed and patched by Koen Holtman.
  
  Bugs fixed are:
   * implement speculative vs. definite q values [Koen]
   * do not fiddle q values for language or media types [Koen]
   * return choice via an internal_redirect instead of run_sub_req, to
 prevent wrong handler getting onto the response
   * use neg->use_transparent_neg to determine if we are running tcn
  
  Revision  ChangesPath
  1.22  +42 -26apache/src/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===
  RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -C3 -r1.21 -r1.22
  *** mod_negotiation.c 1996/10/25 14:58:42 1.21
  --- mod_negotiation.c 1996/10/28 16:28:17 1.22
  ***
  *** 188,198 
int is_pseudo_html; /* text/html, *or* the INCLUDES_MAGIC_TYPEs 
*/

/* Above are all written-once properties of the variant.  The
  !  * two fields below are changed during negotiation:
 */

float level_matched;
int mime_stars;
} var_rec;

/* Something to carry around the state of negotiation (and to keep
  --- 188,199 
int is_pseudo_html; /* text/html, *or* the INCLUDES_MAGIC_TYPEs 
*/

/* Above are all written-once properties of the variant.  The
  !  * three fields below are changed during negotiation:
 */

float level_matched;
int mime_stars;
  + int definite;
} var_rec;

/* Something to carry around the state of negotiation (and to keep
  ***
  *** 239,244 
  --- 240,246 
mime_info->bytes = 0;
mime_info->lang_index = -1;
mime_info->mime_stars = 0;
  + mime_info->definite = 1;

mime_info->charset_quality = 1.0;
mime_info->type_quality = 0.0;
  ***
  *** 454,459 
  --- 456,462 
for (i = 0; i < new->accepts->nelts; ++i)
if (elts[i].quality < 1.0) new->accept_q = 1;
}
  + else new->accept_q = 1;

return new;
}
  ***
  *** 942,947 
  --- 945,953 
 * acceptable, but only if no variants with an explicit language
 * are acceptable. The default q value set here is assigned to variants
 * with no language type in set_language_quality().
  +  *
  +  * Note that if using the transparent negotiation network algorythm,
  +  * we don't use this fiddle.
 */

void set_default_lang_quality(negotiation_state *neg)
  ***
  *** 949,961 
var_rec *avail_recs = (var_rec *)neg->avail_vars->elts;
int j;

  ! for (j = 0; j < neg->avail_vars->nelts; ++j) {
  ! var_rec *variant = &avail_recs[j];
  ! if (variant->content_language && *variant->content_language) {
  ! neg->default_lang_quality = 0.001;
  ! return;
}
  - }
  
neg->default_lang_quality = 1.0;
}
  --- 955,968 
var_rec *avail_recs = (var_rec *)neg->avail_vars->elts;
int j;

  ! if (!neg->use_transparent_neg)
  ! for (j = 0; j < neg->avail_vars->nelts; ++j) {
  ! var_rec *variant = &avail_recs[j];
  ! if (variant->content_language && *variant->content_language) {
  ! neg->default_lang_quality = 0.001;
  ! return;
  ! }
}
  
neg->default_lang_quality = 1.0;
}
  ***
  *** 1066,1071 
  --- 1073,1079 

variant->lang_quality = best ? best->quality : 
 (star ? star->quality : fiddle_q);
  + variant->definite = variant->definite && best;
}

/* Now set the old lang_index field */
  ***
  *** 1114,1119 
  --- 1122,1128 
int i;
accept_rec *accept_recs = (accept_rec *)neg->accepts->elts;
float q = 0.0;
  + int q_definite = 1;

/* if no Accept: header, leave quality alone (will
 * remain at the default value of 1) */
  ***
  *** 1162,1169 
  --- 1171,1181 
if (!neg->accept_q && variant->mime_stars == 1) q = 0.01;
else if (!neg->accept_q && variant->mime_stars == 2) q = 0.02;
else q = type->quality;
  + 
  + q_definite = (variant->mime_stars == 3);
}
variant->accept_type_quality = q;
  + variant->definite=variant->definite && q_definite;

/* if the _best_ quality we got for this variant was 0.0,
 * eliminate it now */
  ***
  *** 1311,1324 
variant->lang_quality;

#ifdef NEG_DEB

cvs commit: apache/src mod_negotiation.c

1996-10-25 Thread Paul Sutton
pcs 96/10/25 07:58:43

  Modified:src   mod_negotiation.c
  Log:
  Fixed bug in type-map processing which meant it was no longer ignoring
  any initial line giving the URI of the negotiable resource. Also
  stopping a Content-Type line on its own from being treated as a
  variant with no name.
  
  Revision  ChangesPath
  1.21  +2 -5  apache/src/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===
  RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -C3 -r1.20 -r1.21
  *** mod_negotiation.c 1996/10/20 18:03:36 1.20
  --- mod_negotiation.c 1996/10/25 14:58:42 1.21
  ***
  *** 241,247 
mime_info->mime_stars = 0;

mime_info->charset_quality = 1.0;
  ! mime_info->type_quality = 1.0;
mime_info->encoding_quality = 1;
mime_info->lang_quality = 1.0;
mime_info->accept_type_quality = 1.0;
  --- 241,247 
mime_info->mime_stars = 0;

mime_info->charset_quality = 1.0;
  ! mime_info->type_quality = 0.0;
mime_info->encoding_quality = 1;
mime_info->lang_quality = 1.0;
mime_info->accept_type_quality = 1.0;
  ***
  *** 656,665 
mime_info.description = get_token (neg->pool, &body, 0);
}
} else {
  ! #ifdef NOTDEF
  ! if (mime_info.quality > 0)
  ! #endif
  ! if (*mime_info.file_name)
{
void *new_var = push_array (neg->avail_vars);
memcpy (new_var, (void *)&mime_info, sizeof (var_rec));
  --- 656,662 
mime_info.description = get_token (neg->pool, &body, 0);
}
} else {
  ! if (mime_info.type_quality > 0 && *mime_info.file_name)
{
void *new_var = push_array (neg->avail_vars);
memcpy (new_var, (void *)&mime_info, sizeof (var_rec));
  
  
  


cvs commit: apache/src mod_negotiation.c

1996-09-27 Thread Brian Behlendorf
brian   96/09/27 19:30:58

  Modified:src   mod_negotiation.c
  Log:
  Clean up -Wall warnings, which seemed like they were good things to fix 
anyways.
  
  Revision  ChangesPath
  1.19  +4 -5  apache/src/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===
  RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -C3 -r1.18 -r1.19
  *** mod_negotiation.c 1996/09/24 12:44:59 1.18
  --- mod_negotiation.c 1996/09/28 02:30:56 1.19
  ***
  *** 50,56 
 *
 */

  ! /* $Id: mod_negotiation.c,v 1.18 1996/09/24 12:44:59 mjc Exp $ */

/*
 * mod_negotiation.c: keeps track of MIME types the client is willing to
  --- 50,56 
 *
 */

  ! /* $Id: mod_negotiation.c,v 1.19 1996/09/28 02:30:56 brian Exp $ */

/*
 * mod_negotiation.c: keeps track of MIME types the client is willing to
  ***
  *** 995,1005 
accept_rec *accs, *best = NULL, *star = NULL;
int i;
char *lang = variant->content_language;
  ! int prefixlen;
char *p;
int naccept = neg->accept_langs->nelts;
int index;
  ! neg_dir_config *conf;
int longest_lang_range_len = 0;
int len;

  --- 995,1005 
accept_rec *accs, *best = NULL, *star = NULL;
int i;
char *lang = variant->content_language;
  ! int prefixlen = 0;
char *p;
int naccept = neg->accept_langs->nelts;
int index;
  ! neg_dir_config *conf = NULL;
int longest_lang_range_len = 0;
int len;

  ***
  *** 1060,1066 
 * of any other language listed on the Accept-Language
 * header
 */
  ! if (p = strchr(accs[i].type_name, '-')) {
int plen = p - accs[i].type_name;
if (!strncmp(lang, accs[i].type_name, plen))
fiddle_q = 0.001;
  --- 1060,1066 
 * of any other language listed on the Accept-Language
 * header
 */
  ! if ((p = strchr(accs[i].type_name, '-'))) {
int plen = p - accs[i].type_name;
if (!strncmp(lang, accs[i].type_name, plen))
fiddle_q = 0.001;
  ***
  *** 1183,1189 
{
int i;
accept_rec *accept_recs = (accept_rec *)neg->accept_charsets->elts;
  - float q = 0.0;
char *charset = variant->content_charset;

if (!charset)
  --- 1183,1188 
  
  
  


cvs commit: apache/src mod_negotiation.c

1996-08-15 Thread Alexei Kosut
akosut  96/08/15 13:15:44

  Modified:src   mod_negotiation.c
  Log:
  In the absense of other considerations, cause Apache to send the smallest
  variant, even if the types are different (Accept-header order should not
  make a difference - the client would have sent us a q-value if it cared).
  
  Revision  ChangesPath
  1.16  +1 -3  apache/src/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===
  RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -C3 -r1.15 -r1.16
  *** mod_negotiation.c 1996/08/15 20:12:10 1.15
  --- mod_negotiation.c 1996/08/15 20:15:42 1.16
  ***
  *** 1026,1036 
|| (variant->lang_index == best->lang_index
&& ((levcmp = level_cmp (variant, best)) == 1
|| (levcmp == 0
  - && !strcmp (variant->type_name,
  - best->type_name)
&& (find_content_length(neg, variant)
<
  ! find_content_length(neg, best)
{
best = variant;
best_quality = q;
  --- 1026,1034 
|| (variant->lang_index == best->lang_index
&& ((levcmp = level_cmp (variant, best)) == 1
|| (levcmp == 0
&& (find_content_length(neg, variant)
<
  !  find_content_length(neg, best)
{
best = variant;
best_quality = q;
  
  
  


cvs commit: apache/src mod_negotiation.c

1996-08-15 Thread Alexei Kosut
akosut  96/08/15 13:12:12

  Modified:src   mod_negotiation.c
  Log:
  If the client doesn't send q-values in Accept: give wilcards arbitrarily
  low values, so that "Accept: image/gif, */*" on a request with variants
  image/gif; qs=0.3 and image/png; qs=0.7 doesn't end up with the PNG.
  
  Revision  ChangesPath
  1.15  +27 -3 apache/src/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===
  RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -C3 -r1.14 -r1.15
  *** mod_negotiation.c 1996/08/15 19:26:59 1.14
  --- mod_negotiation.c 1996/08/15 20:12:10 1.15
  ***
  *** 185,190 
  --- 185,191 
pool *pool;
request_rec *r;
char *dir_name;
  + int accept_q;   /* Do any of the Accept: headers have a q-value ? */

array_header *accepts;  /* accept_recs */
array_header *accept_encodings; /* accept_recs */
  ***
  *** 342,348 
  --- 343,352 
{
negotiation_state *new =
(negotiation_state *)pcalloc (r->pool, sizeof (negotiation_state));
  + accept_rec *elts;
table *hdrs = r->headers_in;
  + 
  + int i;

new->pool = r->pool;
new->r = r;
  ***
  *** 355,360 
  --- 359,374 
  do_header_line (r->pool, table_get (hdrs, "Accept-language"));
new->avail_vars = make_array (r->pool, 40, sizeof (var_rec));

  + /* Now we check for q-values. If they're all 1.0, we assume the
  +  * client is "broken", and we are allowed to fiddle with the
  +  * values later. Otherwise, we leave them alone.
  +  */
  + 
  + elts = (accept_rec *)new->accepts->elts;
  + 
  + for (i = 0; i < new->accepts->nelts; ++i)
  + if (elts[i].quality < 1.0) new->accept_q = 1;
  + 
return new;
}

  ***
  *** 944,960 
for (j = 0; j < neg->avail_vars->nelts; ++j) {

var_rec *variant = &avail_recs[j];
  ! float q = type->quality * variant->quality;
  ! 
/* If we've already rejected this variant, don't waste time */

  ! if (q == 0.0) continue; 

/* If media types don't match, forget it.
 * (This includes the level check).
 */

if (!mime_match(type, variant)) continue;

/* Check maxbytes */

  --- 958,984 
for (j = 0; j < neg->avail_vars->nelts; ++j) {

var_rec *variant = &avail_recs[j];
  ! float q, quality = type->quality;
  ! 
/* If we've already rejected this variant, don't waste time */

  ! if (variant->quality == 0.0) continue;  

/* If media types don't match, forget it.
 * (This includes the level check).
 */

if (!mime_match(type, variant)) continue;
  + 
  + /* If we are allowed to mess with the q-values,
  +  * make wildcards very low, so we have a low chance
  +  * of ending up with them if there's something better.
  +  */
  + 
  + if (!neg->accept_q && variant->mime_stars == 1) quality = 0.01;
  + if (!neg->accept_q && variant->mime_stars == 2) quality = 0.02;
  + 
  + q = quality * variant->quality;

/* Check maxbytes */

  
  
  


cvs commit: apache/src mod_negotiation.c

1996-08-15 Thread Alexei Kosut
akosut  96/08/15 12:27:00

  Modified:src   mod_negotiation.c
  Log:
  Make language subtag matching work in both directions correctly.
  
  Revision  ChangesPath
  1.14  +6 -2  apache/src/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===
  RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -C3 -r1.13 -r1.14
  *** mod_negotiation.c 1996/08/15 19:22:38 1.13
  --- mod_negotiation.c 1996/08/15 19:26:59 1.14
  ***
  *** 761,767 

/* Finding languages.  Note that we only match the substring specified
 * by the Accept: line --- this is to allow "en" to match all subvariants
  !  * of English.
 *
 * Again, strcmp() is legit because we've ditched case already.
 */
  --- 761,768 

/* Finding languages.  Note that we only match the substring specified
 * by the Accept: line --- this is to allow "en" to match all subvariants
  !  * of English. We then do it in the other direction, so that all
  !  * subvariants of English match "en".
 *
 * Again, strcmp() is legit because we've ditched case already.
 */
  ***
  *** 776,784 

accs = (accept_rec *)accept_langs->elts;

  ! for (i = 0; i < accept_langs->nelts; ++i)
if (!strncmp (lang, accs[i].type_name, strlen(accs[i].type_name)))
return i;

return -1;  
}
  --- 777,788 

accs = (accept_rec *)accept_langs->elts;

  ! for (i = 0; i < accept_langs->nelts; ++i) {
if (!strncmp (lang, accs[i].type_name, strlen(accs[i].type_name)))
return i;
  + if (!strncmp (lang, accs[i].type_name, strlen(lang)))
  + return i;
  + }

return -1;  
}
  
  
  


cvs commit: apache/src mod_negotiation.c

1996-08-15 Thread Alexei Kosut
akosut  96/08/15 11:36:46

  Modified:src   mod_negotiation.c
  Log:
  Fix Vary mechanism to be more correct in how it determines the contents
  of the Vary header.
  
  Revision  ChangesPath
  1.12  +37 -17apache/src/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===
  RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -C3 -r1.11 -r1.12
  *** mod_negotiation.c 1996/07/28 22:40:55 1.11
  --- mod_negotiation.c 1996/08/15 18:36:42 1.12
  ***
  *** 1022,1047 
char *set_vary (pool *p, negotiation_state *neg)
{
var_rec *var_recs = (var_rec*)neg->avail_vars->elts;
  ! int i, accept_encoding = 0;
  ! int accept_language = 0;
  ! char *enc, *lang;

  ! /* Go through each variant and check for an encoding
  !  * or language (we always set "Accept", so no need to check).
 */

for (i = 0; i < neg->avail_vars->nelts; ++i) {
  ! enc = var_recs[i].content_encoding;
  ! lang = var_recs[i].content_language;
  ! 
  ! if (!accept_encoding && !(!enc || !strcmp(enc, "")))
  ! accept_encoding = 1;
  ! if (!accept_language && !(!lang || !strcmp(lang, "")))
  ! accept_language = 1;
}

  ! return pstrcat(p, "Accept", accept_encoding ? ", Accept-Encoding" : "",
  !accept_language ? ", Accept-Language" : "", NULL);
}

/
  --- 1022,1064 
char *set_vary (pool *p, negotiation_state *neg)
{
var_rec *var_recs = (var_rec*)neg->avail_vars->elts;
  ! int i;
  ! int accept_type, accept_enc, accept_lang;
  ! char *type, *enc, *lang;
  ! char *last_type, *last_enc, *last_lang;

  ! accept_type = accept_enc = accept_lang = 0;
  ! last_type = last_enc = last_lang = NULL;
  ! 
  ! /* Go through each variant and check for a differing
  !  * type, encoding or type.
 */

for (i = 0; i < neg->avail_vars->nelts; ++i) {
  ! /* Ideally, we wouldn't have to do this, but strcmp(NULL, NULL)
  !  * isn't legal
  !  */
  ! type = var_recs[i].type_name ? var_recs[i].type_name : "";
  ! enc = var_recs[i].content_encoding ? var_recs[i].content_encoding : 
"";
  !lang = var_recs[i].content_language ? var_recs[i].content_language : 
"";
  ! 
  ! if (!accept_type && last_type && strcmp(last_type, type))
  ! accept_type = 1;
  ! else if (!accept_type && !last_type) last_type = type;
  ! 
  ! if (!accept_enc && last_enc && strcmp(last_enc, enc))
  ! accept_enc = 1;
  ! else if (!accept_enc && !last_enc) last_enc = enc;
  ! 
  ! if (!accept_lang && last_lang && strcmp(last_lang, lang))
  ! accept_lang = 1;
  ! else if (!accept_lang && !last_lang) last_lang = lang;
}

  ! if (!accept_type && !accept_enc && !accept_lang) return NULL;
  ! else return 2 + pstrcat(p, accept_type ? ", Accept" : "",
  ! accept_enc ? ", Accept-Encoding" : "",
  ! accept_lang ? ", Accept-Language" : "", NULL);
}

/
  ***
  *** 1055,1061 
var_rec *best;
int res;

  ! char *udir;

if ((res = read_type_map (neg, r->filename))) return res;

  --- 1072,1078 
var_rec *best;
int res;

  ! char *vary, *udir;

if ((res = read_type_map (neg, r->filename))) return res;

  ***
  *** 1073,1079 
 */
if (!do_cache_negotiated_docs(r->server) && (r->proto_num < 1001))
r->no_cache = 1;
  ! table_merge(r->err_headers_out, "Vary", set_vary(r->pool, neg));

udir = make_dirstr (r->pool, r->uri, count_dirs (r->uri));
udir = escape_uri(r->pool, udir);
  --- 1090,1097 
 */
if (!do_cache_negotiated_docs(r->server) && (r->proto_num < 1001))
r->no_cache = 1;
  ! if ((vary = set_vary(r->pool, neg)))
  ! table_merge(r->err_headers_out, "Vary", vary);

udir = make_dirstr (r->pool, r->uri, count_dirs (r->uri));
udir = escape_uri(r->pool, udir);
  ***
  *** 1086,1091 
  --- 1104,1110 
negotiation_state *neg;
var_rec *best;
request_rec *sub_req;
  + char *vary;
int res;

if (r->finfo.st_mode != 0 || !(allow_options (r) & OPT_MULTI))
  ***
  *** 1124,1130 

if (!do_cache_negotiated_docs(r->server) && (r->proto_num < 1001))
r->no_cache = 1;
  ! table_merge(r->err_headers_out, "Vary", set_vary(r->pool, neg));

r->filename = sub_req->filename;
r->handler = sub_req->h

cvs commit: apache/src mod_negotiation.c

1996-07-28 Thread Chuck Murcko
chuck   96/07/28 15:40:56

  Modified:src   mod_negotiation.c
  Log:
  Reviewed by:  Chuck Murcko
  Submitted by: Ralf S. Engelschall
  Prevent conflicts when ProxyRemote is in use
  
  Revision  ChangesPath
  1.11  +3 -0  apache/src/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===
  RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -C3 -r1.10 -r1.11
  *** mod_negotiation.c 1996/07/28 19:27:49 1.10
  --- mod_negotiation.c 1996/07/28 22:40:55 1.11
  ***
  *** 593,598 
  --- 593,601 

if (!(filp = strrchr (r->filename, '/'))) return DECLINED; /* Weird... 
*/

  + if (strncmp(r->filename, "proxy:", 6) == 0)
  + return DECLINED;
  + 
++filp;
prefix_len = strlen (filp);

  
  
  


cvs commit: apache/src mod_negotiation.c

1996-06-08 Thread Alexei Kosut
akosut  96/06/08 18:12:23

  Modified:src   mod_negotiation.c
  Log:
  Cause Accept values with wildcards to be treated with less priority
  than those without wildcards at the same quality value.
  
  Revision  ChangesPath
  1.8   +32 -14apache/src/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===
  RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -C3 -r1.7 -r1.8
  *** mod_negotiation.c 1996/05/27 19:48:39 1.7
  --- mod_negotiation.c 1996/06/09 01:12:21 1.8
  ***
  *** 175,185 
int is_pseudo_html; /* text/html, *or* the 
INCLUDES_MAGIC_TYPEs */

/* Above are all written-once properties of the variant.  The
  !  * two fields below are changed during negotiation:
 */

float quality;  
float level_matched;
} var_rec;

/* Something to carry around the state of negotiation (and to keep
  --- 175,186 
int is_pseudo_html; /* text/html, *or* the 
INCLUDES_MAGIC_TYPEs */

/* Above are all written-once properties of the variant.  The
  !  * three fields below are changed during negotiation:
 */

float quality;  
float level_matched;
  + int mime_stars;
} var_rec;

/* Something to carry around the state of negotiation (and to keep
  ***
  *** 216,221 
  --- 217,223 
mime_info->quality = 0.0;
mime_info->bytes = 0;
mime_info->lang_index = -1;
  + mime_info->mime_stars = 0;
}

/* Initializing the relevant fields of a variant record from the
  ***
  *** 674,679 
  --- 676,684 
 *
 * Note also that if we get an exact match on the media type, we update
 * level_matched for use in level_cmp below...
  +  * 
  +  * We also give a value for mime_stars, which is used later. It should
  +  * be 1 for star/star, 2 for type/star and 3 for type/subtype.
 */

int mime_match (accept_rec *accept, var_rec *avail)
  ***
  *** 682,697 
char *avail_type = avail->type_name;
int len = strlen(accept_type);
  
  ! if (accept_type[0] == '*')  /* Anything matches star/star */
return 1; 
  ! else if (accept_type[len - 1] == '*')
  ! return !strncmp (accept_type, avail_type, len - 2);
else if (!strcmp (accept_type, avail_type)
 || (!strcmp (accept_type, "text/html")
 && (!strcmp(avail_type, INCLUDES_MAGIC_TYPE)
 || !strcmp(avail_type, INCLUDES_MAGIC_TYPE3 {
if (accept->level >= avail->level) {
avail->level_matched = avail->level;
return 1;
}
}
  --- 687,710 
char *avail_type = avail->type_name;
int len = strlen(accept_type);
  
  ! if (accept_type[0] == '*')  { /* Anything matches star/star */
  ! if (avail->mime_stars < 1)
  !   avail->mime_stars = 1;
return 1; 
  ! }
  ! else if ((accept_type[len - 1] == '*') &&
  !  !strncmp (accept_type, avail_type, len - 2)) {
  ! if (avail->mime_stars < 2)
  !   avail->mime_stars = 2;
  ! return 1;
  ! }
else if (!strcmp (accept_type, avail_type)
 || (!strcmp (accept_type, "text/html")
 && (!strcmp(avail_type, INCLUDES_MAGIC_TYPE)
 || !strcmp(avail_type, INCLUDES_MAGIC_TYPE3 {
if (accept->level >= avail->level) {
avail->level_matched = avail->level;
  + avail->mime_stars = 3;
return 1;
}
}
  ***
  *** 870,876 
return;

/* Lose any variant with an unacceptable content encoding */
  ! 
for (i = 0; i < neg->avail_vars->nelts; ++i)
if (var_recs[i].quality > 0
&& !find_encoding (neg->accept_encodings,
  --- 883,889 
return;

/* Lose any variant with an unacceptable content encoding */
  ! 
for (i = 0; i < neg->avail_vars->nelts; ++i)
if (var_recs[i].quality > 0
&& !find_encoding (neg->accept_encodings,
  ***
  *** 960,965 
  --- 973,982 
 * tied variants by whatever means it likes.  This server
 * breaks ties as follows, in order:
 *
  +  * By perferring non-wildcard entries to those with
  +  * wildcards. The spec specifically says we should
  +  * do this, and it makes a lot of sense.
  +  *
 * By order of languages in Accept-language, to give the
 * client a way to specify a language preference.  I'd prefer
 * to give this precedence over media type, but the standard
  ***
  *** 979,993 

if (q > best_quality
   

cvs commit: apache/src mod_negotiation.c

1996-04-17 Thread Ben Laurie
ben 96/04/17 07:02:19

  Modified:src   mod_negotiation.c
  Log:
  Fix a few places where floats were used instead of ints.
  
  Revision  ChangesPath
  1.6   +2 -2  apache/src/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===
  RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -C3 -r1.5 -r1.6
  *** mod_negotiation.c 1996/04/09 22:49:54 1.5
  --- mod_negotiation.c 1996/04/17 14:02:17 1.6
  ***
  *** 209,215 
mime_info->content_encoding = "";
mime_info->content_language = "";

  ! mime_info->is_pseudo_html = 0.0;
mime_info->level = 0.0;
mime_info->level_matched = 0.0;
mime_info->qs = 0.0;
  --- 209,215 
mime_info->content_encoding = "";
mime_info->content_language = "";

  ! mime_info->is_pseudo_html = 0;
mime_info->level = 0.0;
mime_info->level_matched = 0.0;
mime_info->qs = 0.0;
  ***
  *** 896,902 
accept_rec *accs = (accept_rec *)accept_encodings->elts;
int i;

  ! if (is_identity_encoding(enc)) return 1.0;

for (i = 0; i < accept_encodings->nelts; ++i)
if (!strcmp (enc, accs[i].type_name))
  --- 896,902 
accept_rec *accs = (accept_rec *)accept_encodings->elts;
int i;

  ! if (is_identity_encoding(enc)) return 1;

for (i = 0; i < accept_encodings->nelts; ++i)
if (!strcmp (enc, accs[i].type_name))
  
  
  


cvs commit: apache/src mod_negotiation.c

1996-04-09 Thread Alexei Kosut
akosut  96/04/09 15:49:56

  Modified:src   mod_negotiation.c
  Log:
  Fix problem where files with handlers but no types were getting ignored
  with MultiViews.
  
  Revision  ChangesPath
  1.5   +8 -1  apache/src/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===
  RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -C3 -r1.4 -r1.5
  *** mod_negotiation.c 1996/04/02 10:48:49 1.4
  --- mod_negotiation.c 1996/04/09 22:49:54 1.5
  ***
  *** 662,668 
 */

sub_req = sub_req_lookup_file (dir_entry->d_name, r);
  ! 
if (sub_req->status != 200 || !sub_req->content_type) continue;

/* If it's a map file, we use that instead of the map
  --- 662,675 
 */

sub_req = sub_req_lookup_file (dir_entry->d_name, r);
  ! 
  ! /* If it has a handler, we'll pretend it's a CGI script,
  !  * since that's a good indication of the sort of thing it
  !  * might be doing.
  !  */
  ! if (sub_req->handler && !sub_req->content_type)
  !   sub_req->content_type = CGI_MAGIC_TYPE;
  ! 
if (sub_req->status != 200 || !sub_req->content_type) continue;

/* If it's a map file, we use that instead of the map
  
  
  


cvs commit: apache/src mod_negotiation.c

1996-04-02 Thread Mark Cox
mjc 96/04/02 02:48:50

  Modified:src   mod_negotiation.c
  Log:
  Watch out for either content_type or handler being NULL or we get SIGSEGVs
  
  Revision  ChangesPath
  1.4   +4 -2  apache/src/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===
  RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -C3 -r1.3 -r1.4
  *** mod_negotiation.c 1996/03/31 01:07:03 1.3
  --- mod_negotiation.c 1996/04/02 10:48:49 1.4
  ***
  *** 669,676 
 * we're building...
 */

  ! if (!strcmp (sub_req->content_type, MAP_FILE_MAGIC_TYPE) ||
  ! !strcmp (sub_req->handler, "type-map")) {
closedir(dirp);

neg->avail_vars->nelts = 0;
  --- 669,678 
 * we're building...
 */

  ! if (((sub_req->content_type) &&
  !  !strcmp (sub_req->content_type, MAP_FILE_MAGIC_TYPE)) || 
  ! ((sub_req->handler) && 
  ! !strcmp (sub_req->handler, "type-map"))) {
closedir(dirp);

neg->avail_vars->nelts = 0;