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.16 2003/03/08 22:22:53 nilsson Exp $ + // $Id: URI.pike,v 1.17 2004/01/11 00:41:39 nilsson 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:25:   string fragment;      //! Certain classes of URI (e.g. URL) may have these defined   string host, user, password;      //! If no port number is present in URI, but the scheme used has a   //! default port number, this number is put here.   int port;      //! The base URI object, if present - object(this_program) base_uri; + this_program base_uri;      // URI hacker docs:   // This string is the raw uri the object was instantiated from in the   // first place. We save it here for the sole purpose of being able to   // replace the base URI, hence also needing to reresolve all of our   // properties with respect to that change.   string raw_uri;      #ifdef STANDARDS_URI_DEBUG   #define DEBUG(X, Y ...) werror("Standards.URI: "+X+"\n", Y)
pike.git/lib/modules/Standards.pmod/URI.pike:55:    sscanf(auth, "%[^:]:%s", user, password); // auth info present    DEBUG("parse_authority(): user=%O, password=%O", user, password);    }    if(scheme)    port = Protocols.Ports.tcp[scheme]; // Set a good default á la RFC 1700    sscanf(authority, "%[^:]%*[:]%d", host, port);    DEBUG("parse_authority(): host=%O, port=%O", host, port);   }      // Inherit all properties except raw_uri and base_uri from the URI uri. :-) - static void inherit_properties(object(this_program) uri) + static void inherit_properties(this_program uri)   {    authority = uri->authority;    scheme = uri->scheme;    user = uri->user; password = uri->password;    host = uri->host; query = uri->query;    port = uri->port;    path = uri->path; fragment = uri->fragment;   }      //! Compare this URI to something, in a canonical way.
pike.git/lib/modules/Standards.pmod/URI.pike:156:      //! @decl void reparse_uri()   //! @decl void reparse_uri(URI base_uri)   //! @decl void reparse_uri(string base_uri)   //! Reparse the URI with respect to a new base URI. If   //! no base_uri was supplied, the old base_uri is thrown away.   //! The resolving is performed according to the guidelines   //! 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) + void reparse_uri(this_program|string|void base_uri)   {    string uri = raw_uri;       if(stringp(base_uri))    {    DEBUG("cloning base URI %O", base_uri); -  this_program::base_uri = object_program(this_object())(base_uri); // create a new URI object +  this_program::base_uri = this_program(base_uri); // create a new URI object    }    else    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
pike.git/lib/modules/Standards.pmod/URI.pike:290:   //! @decl void create(string uri, URI base_uri)   //! @decl void create(string uri, string base_uri)   //! @param base_uri   //! When supplied, will root the URI a the given location. This is   //! needed to correctly verify relative URIs, but may be left out otherwise.   //! If left out, and uri is a relative URI, an error is thrown.   //! @param uri   //! When uri is another URI object, the created   //! URI will inherit all properties of the supplied uri   //! except, of course, for its base_uri. - void create(object(this_program)|string uri, -  object(this_program)|string|void base_uri) + void create(this_program|string uri, +  this_program|string|void base_uri)   {    DEBUG("create(%O, %O) called!", uri, base_uri);    if(stringp(uri))    raw_uri = [string]uri; // Keep for future runs of reparse_uri after a base_uri change    else // if(objectp(uri)) (implied)    {    raw_uri = uri->raw_uri;    inherit_properties([object(this_program)]uri);    }   
pike.git/lib/modules/Standards.pmod/URI.pike:356:   string|mapping cast(string to)   {    switch(to)    {    case "string":    return _sprintf('s');    case "mapping":    array(string) i = ({ "scheme", "authority", "user", "password", "host", "port",    "path", "query", "fragment",    "raw_uri", "base_uri", }); -  return mkmapping(i, rows(this_object(), i)); +  return mkmapping(i, rows(this, i));    }   }      //! Returns path and query part of the URI if present.   string get_path_query()   {    return (path||"") + (query ? "?" + query : "");   }      string _sprintf(int how, mapping|void args)