Branch: Tag:

2008-01-10

2008-01-10 10:19:56 by Martin Stjernholm <mast@lysator.liu.se>

Moved init of id->misc->pref_languages into a separate function for use from
vary callbacks.

Rev: server/base_server/prototypes.pike:1.199
Rev: server/protocols/ftp.pike:2.118
Rev: server/protocols/http.pike:1.539

6:   #include <module.h>   #include <variables.h>   #include <module_constants.h> - constant cvs_version="$Id: prototypes.pike,v 1.198 2008/01/10 10:06:21 mast Exp $"; + constant cvs_version="$Id: prototypes.pike,v 1.199 2008/01/10 10:19:56 mast Exp $";      #ifdef DAV_DEBUG   #define DAV_WERROR(X...) werror(X)
1210:    //! Call to initialize the cookies.    //!    //! Typically called from callbacks installed with -  //! @[register_vary_callback()] if @[cookies] hasn't been initialized. +  //! @[register_vary_callback()] to ensure @[cookies] is initialized.    void init_cookies(int|void no_cookie_jar)    {    if (!cookies) {
1222:    }    }    +  void init_pref_languages() +  //! Call to initialize @code{@[misc]->pref_languages@}. +  //! +  //! Typically called from callbacks installed with +  //! @[register_vary_callback()] to ensure +  //! @code{@[misc]->pref_languages@} is initialized. +  { +  if (!misc->pref_languages) { +  misc->pref_languages=PrefLanguages(); +  if (string|array(string) contents = request_headers[ "accept-language" ]) +  { +  if( !arrayp( contents ) ) +  contents = (contents-" ")/","; +  else +  contents = +  Array.flatten( map( map( contents, `-, " " ), `/, "," ))-({""}); +  misc->pref_languages->languages=contents; +  misc["accept-language"] = contents; +  } +  } +  } +     mapping (string:array(string)|string) request_headers;    //! Indices and values map to the names and values of all HTTP headers sent    //! with the request; all data has been transport decoded, and the header