Roxen.git / server / base_server / roxen.pike

version» Context lines:

Roxen.git/server/base_server/roxen.pike:1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2004, Roxen IS.   //   // The Roxen WebServer main program.   //   // Per Hedbor, Henrik Grubbström, Pontus Hagland, David Hedbor and others.   // ABS and suicide systems contributed freely by Francesco Chemolli    - constant cvs_version="$Id: roxen.pike,v 1.1018 2009/01/11 18:13:42 jonasw Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.1019 2009/01/16 14:38:32 mast Exp $";      //! @appears roxen   //!   //! The Roxen WebServer main program.      // The argument cache. Used by the image cache.   ArgCache argcache;      // Some headerfiles   #define IN_ROXEN
Roxen.git/server/base_server/roxen.pike:1469:    return host_is_local_cache[hostname] = res;   }      array(Protocol|mapping(string:mixed)) find_port_for_url (    Standards.URI url, void|Configuration only_this_conf)   // Returns ({port_obj, url_data}) for a url that matches the given   // one. url_data is the mapping for the url in port_obj->urls. If   // only_this_conf is given then only ports for that configuration are   // searched.   { -  // Force string coersion to incorporate any separate base URI -  Standards.URI url2 = Standards.URI((string) url); -  url2->fragment = 0; -  url2->query = 0; -  string url_with_port = (string) url2; +  // Cannot use the uri formatter in Standards.URI here since we +  // always want the port number to be present. +  string host = url->host; +  if (has_value (host, ":")) host = "[" + host + "]"; +  string url_with_port = sprintf ("%s://%s:%d%s", url->scheme, host, url->port, +  sizeof (url->path) ? url->path : "/");       URL2CONF_MSG("URL with port: %s\n", url_with_port);       foreach (urls; string u; mapping(string:mixed) q)    {    URL2CONF_MSG("Trying %O:%O\n", u, q);    if( glob( u+"*", url_with_port ) )    {    URL2CONF_MSG("glob match\n");    if (Protocol p = q->port)
Roxen.git/server/base_server/roxen.pike:2645:    }    ui->fragment = 0;       if( (int)opts->nobind )    {    report_warning(    LOC_M(61,"Not binding the port %O, disabled in configuration")+"\n",    (string) ui );    return 0;    } -  if (ui->host == "any" || ui->host == "ANY" || ui->host == "::") -  ui->host = "*"; +  if (lower_case (ui->host) == "any" || ui->host == "::") +  host = "*";    else    // FIXME: Maybe Standards.URI should do this internally? -  ui->host = lower_case (Standards.IDNA.zone_to_ascii (ui->host)); +  host = lower_case (Standards.IDNA.zone_to_ascii (ui->host));       protocol = ui->scheme; -  host = ui->host; -  if (!sizeof(host || "") || !protocols[protocol]) { +  if (host == "" || !protocols[protocol]) {    report_error(LOC_M(19,"Bad URL '%s' for server `%s'")+"\n",    (string) ui, conf->query_name());    } -  if (!ui->port) -  ui->port = protocols[protocol]->default_port; -  port = ui->port; +     -  url = (string) ui; +  port = ui->port || protocols[protocol]->default_port;    -  if (path = ui->path) -  if (sizeof(path)) { +  if (path = ui->path) {    if (has_suffix(path, "/")) -  path = path[..sizeof(path) - 2]; -  } else { -  path = 0; +  path = path[..<1]; +  if (path == "") path = 0;    }    -  +  { +  string h = has_value (host, ":") ? "[" + host + "]" : host; +  url = sprintf ("%s://%s:%d%s/", protocol, h, port, +  // If the path is set it's assumed to begin with a +  // "/", but not end with one. +  path || ""); +  } +     if( urls[ url ] )    {    if( !urls[ url ]->port )    m_delete( urls, url );    else if( urls[ url ]->conf )    {    if( urls[ url ]->conf != conf )    {    report_error(LOC_M(20,    "Cannot register URL %s, "
Roxen.git/server/base_server/roxen.pike:5646: Inside #if defined(SNMP_AGENT)
   }    break;   #endif // SNMP_AGENT       }   }      int is_ip(string s)   {    return s && -  ((sscanf(s,"%*d.%*d.%*d.%*d")==4 && s[-1]>='0' && s[-1]<='9') || // IPv4 -  (sizeof(s/":") > 1)); // IPv6 +  (sscanf(s,"%*d.%*d.%*d.%*d%*c")==4 || // IPv4 +  has_value (s, ":")); // IPv6   }      protected string _sprintf( )   {    return "roxen";   }         // Logging