pike.git / lib / modules / Protocols.pmod / HTTP.pmod / module.pmod

version» Context lines:

pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:298:   //! Example:   //! @pre{   //! > Protocols.HTTP.http_encode_query( (["anna":"eva","lilith":"blue"]) );   //! Result: "lilith=blue&anna=eva"   //! > Protocols.HTTP.http_encode_query( (["&":"&","'=\"":"\0\0\0"]) );   //! Result: "%26amp%3b=%26&%27%3d%22=%00%00%00"   //! @}   string http_encode_query(mapping(string:int|string) variables)   {    return Array.map((array)variables, -  lambda(array(string|int) v) +  lambda(array(string|int|array(string)) v)    {    if (intp(v[1]))    return http_encode_string(v[0]); -  +  if (arrayp(v[1])) +  return map(v[1], lambda (string val) { +  return +  http_encode_string(v[0])+"="+ +  http_encode_string(val); +  })*"&";    return http_encode_string(v[0])+"="+    http_encode_string(v[1]);    })*"&";   }      //! This protects all odd - see @[http_encode_query()] -   //! characters for transfer in HTTP.   //!   //! Do not use this function to protect URLs, since   //! it will protect URL characters like @tt{'/'@} and @tt{'?'@}.