pike.git / lib / modules / Standards.pmod / URI.pike

version» Context lines:

pike.git/lib/modules/Standards.pmod/URI.pike:1:   #pike __REAL_VERSION__      //! This class implements URI parsing and resolving of relative references to   //! absolute form, as defined in RFC 2396      // Implemented by Johan Sundström and Johan Schön. - // $Id: URI.pike,v 1.12 2002/03/20 16:40:03 nilsson Exp $ + // $Id: URI.pike,v 1.13 2002/09/21 15:08:30 mast Exp $      #pragma strict_types      //! Scheme component of URI   string scheme;      //! Authority component of URI (formerly called net_loc, from RFC 2396   //! known as authority)   string authority;   
pike.git/lib/modules/Standards.pmod/URI.pike:163:   //! outlined by RFC 2396, Uniform Resource Identifiers (URI): Generic Syntax.   //! @param base_uri   //! Set the new base URI to this.   void reparse_uri(object(this_program)|string|void base_uri)   {    string uri = raw_uri;       if(stringp(base_uri))    {    DEBUG("cloning base URI %O", base_uri); -  local::base_uri = object_program(this_object())(base_uri); // create a new URI object +  this_program::base_uri = object_program(this_object())(base_uri); // create a new URI object    }    else -  local::base_uri = [object(this_program)]base_uri; +  this_program::base_uri = [object(this_program)]base_uri;       // RFC 2396, §5.2:    // 1) The URI reference is parsed into the potential four components and    // fragment identifier, as described in Section 4.3.       // 2) If the path component is empty and the scheme, authority, and    // query components are undefined, then it is a reference to the    // current document and we are done. Otherwise, the reference URI's    // query and fragment components are defined as found (or not found)    // within the URI reference and not inherited from the base URI.    // (Doing this at once saves us some useless parsing efforts.)    if(!uri || uri == "")    {    DEBUG("Path is empty -- Inherit entire base URI "    "as per RFC 2396, §5.2 step 2. Done!"); -  inherit_properties(local::base_uri); +  inherit_properties(this_program::base_uri);    return;    }       if(uri[0] == '#')    {    DEBUG("Fragment only. Using entire base URI, except fragment."); -  inherit_properties(local::base_uri); +  inherit_properties(this_program::base_uri);    fragment = uri[1..];    return;    }       // Parse fragment identifier    sscanf(uri, "%s#%s", uri, fragment);    DEBUG("Found fragment %O", fragment);       // Parse scheme    if(sscanf(uri, "%[A-Za-z0-9+.-]:%s", scheme, uri) < 2)    {    scheme = 0; -  if(!local::base_uri) +  if(!this_program::base_uri)    error("Standards.URI: got a relative URI (no scheme) lacking a base_uri!\n");    }    DEBUG("Found scheme %O", scheme);       // Parse authority/login    if(sscanf(uri, "//%[^/]%s", authority, uri))    {    DEBUG("Found authority %O", authority);    }   
pike.git/lib/modules/Standards.pmod/URI.pike:234:    // scheme is inherited from the base URI's scheme component.    if(scheme)    {    if(authority)    parse_authority();       DEBUG("Scheme found! RFC 2396, §5.2, step 3 "    "says we're absolute. Done!");    return;    } -  scheme = local::base_uri->scheme; +  scheme = this_program::base_uri->scheme;    DEBUG("Inherited scheme %O from base URI", scheme);       if(authority)    parse_authority();          // 4) If the authority component is defined, then the reference is a    // network-path and we skip to step 7. Otherwise, the reference    // URI's authority is inherited from the base URI's authority    // component, which will also be undefined if the URI scheme does not    // use an authority component.    if(!authority || !sizeof(authority))    { -  authority = local::base_uri->authority; +  authority = this_program::base_uri->authority;    DEBUG("Inherited authority %O from base URI", authority);    parse_authority();       // 5) If the path component begins with a slash character ("/"), then    // the reference is an absolute-path and we skip to step 7.    if(!sscanf(path, "/%*s"))    {       // 6) If this step is reached, then we are resolving a relative-path    // reference. The relative path needs to be merged with the base    // URI's path. Although there are many ways to do this, we will    // describe a simple method using a separate string buffer.       DEBUG("Combining base path %O with path %O => %O", -  local::base_uri->path, path, -  combine_uri_path(local::base_uri->path, path)); -  path = combine_uri_path(local::base_uri->path, path); +  this_program::base_uri->path, path, +  combine_uri_path(this_program::base_uri->path, path)); +  path = combine_uri_path(this_program::base_uri->path, path);       }    }       // 7) The resulting URI components, including any inherited from the    // base URI, are recombined to give the absolute form of the URI reference.    // (Reassembly is done at cast-to-string/sprintf() time)   }