Branch: Tag:

2000-02-14

2000-02-14 10:19:09 by Per Hedbor <ph@opera.com>

Changed 'requests_are_utf8_encoded' to 'charset=utf-8'. Looks better, and is somewhat more generic :-)

Rev: server/etc/supports:1.73
Rev: server/protocols/http.pike:1.203

2:   // Modified by Francesco Chemolli to add throttling capabilities.   // Copyright © 1996 - 2000, Idonex AB.    - constant cvs_version = "$Id: http.pike,v 1.202 2000/02/14 09:22:40 per Exp $"; + constant cvs_version = "$Id: http.pike,v 1.203 2000/02/14 10:19:09 per Exp $";      #define MAGIC_ERROR   
99:   string rawauth, realauth;   string since;   array(string) output_charset = ({}); + string input_charset;    - void set_output_charset( string|function to ) + void set_output_charset( string|function to, int|void no_override )   { -  +  if(sizeof( output_charset ) && output_charset[0] == to ) +  return; +  if( !no_override )    output_charset = ({ to }) + output_charset; -  +  else if(!sizeof(output_charset) || output_charset[0] == "iso-8859-1" ) +  output_charset = ({ to }) + output_charset;   }    - array(string) output_encode( string what ) + static array(string) output_encode( string what )   {    string charset;    if( sizeof( output_charset ) )
179:    }   }    - void decode_charset_encoding( function(string:string) decoder ) + void decode_charset_encoding( string|function(string:string) decoder )   { -  +  if(stringp(decoder)) +  decoder = _charset_decoder( Locale.Charset.decoder(decoder) )->decode; +     if( misc->request_charset_decoded )    return; -  misc->request_charset_decoded = 1; +     if( !decoder )    return;    -  +  misc->request_charset_decoded = 1; +     string safe_decoder(string s) {    catch { return decoder(s); };    return s;
887: Inside #if undefined(DISABLE_SUPPORTS)
   supports = find_supports(client_var->fullname, supports);    }    -  // MSIE 5.0 sends all requests UTF8-encoded. -  if (supports->requests_are_utf8_encoded) { -  catch +  if ( client_var->charset && client_var->charset != "iso-8859-1" )    { -  set_output_charset( string_to_utf8 ); -  if( !variables->magic_roxen_automatic_charset_variable ) -  variables->magic_roxen_automatic_charset_variable = "åäö"; - // f = utf8_to_string(f); -  }; +  set_output_charset( client_var->charset ); +  input_charset = client_var->charset;    }   #else    supports = (< "images", "gifinline", "forms", "mailto">);
1779:       mixed q;    if( q = variables->magic_roxen_automatic_charset_variable ) -  decode_charset_encoding( get_client_charset_decoder( q,this_object() ) ); +  decode_charset_encoding( get_client_charset_decoder( q,this_object() ) ); +  if( input_charset ) +  decode_charset_encoding( input_charset );    -  if (misc->host) { +  if (misc->host) +  {    // FIXME: port_obj->name & port_obj->default_port are constant    // consider caching them?    conf =
1791:    (":"+port_obj->default_port):"") +    not_query,    this_object()); -  } else { +  } +  else +  {    // No host header.    // Fallback to using the first configuration bound to this port.    conf = port_obj->urls[port_obj->sorted_urls[0]]->conf;
1836:    processed=1;    roxen.handle(this_object()->handle_request);    -  }) { +  }) +  {    report_error("Internal server error: " + describe_backtrace(err));    my_fd->close();    destruct (my_fd);