Mozilla.com

  1. MDC
  2. Portada
  3. nsIURI

nsIURI

Imagen:traduccion-pendiente.png Esta página está traduciéndose a partir del artículo nsIURI, razón por la cual puede haber algunos errores sintácticos o partes sin traducir. Puedes colaborar continuando con la traducción


nsIURI es un interfase para un identificador uniforme de recursos con facultad de internacionalización.


nsIURI is defined in netwerk/base/public/nsIURI.idl . It is scriptable and has been frozen since Mozilla 1.0.0 .

Código de interfaz

[scriptable, uuid(07a22cc0-0ce5-11d3-9331-00104ba0fd40)]
interface nsIURI : nsISupports
{
  attribute AUTF8String spec;
  readonly attribute AUTF8String prePath;
  attribute ACString scheme;
  attribute AUTF8String userPass;
  attribute AUTF8String username;
  attribute AUTF8String password;
  attribute AUTF8String hostPort;
  attribute AUTF8String host;
  attribute long port;
  attribute AUTF8String path;

  boolean equals(in nsIURI other);
  boolean schemeIs(in string scheme);
  nsIURI clone();
  AUTF8String resolve(in AUTF8String relativePath);

  readonly attribute ACString asciiSpec;
  readonly attribute ACString asciiHost;
  readonly attribute ACString originCharset;
};

Esencialmente URI son nombres estructurados para... cualquier cosa. Este interfaz ofrece métodos para crear y cuestionar los componentes básicos de un URI. Las sub clases, incluida ofrecen mayor estructura a los URI. Esta interfaz sigue las especificaciones Berners-Lee en RFC 2396, donde se definen las URI básicas como:

ftp://user:password@example.org:12345/path/leaf 
Componente Valore en el ejemplo
scheme ftp
userPass user:password
host example.org
port 12345
path /path/leaf
prePath ftp://user:password@example.org:12345

Métodos

equals()

boolean equals (in nsIURI other);

Test de equivalencia de URI (no es estrictamente una comparación de cadenas) p.e. http://example.com:80/ == http://example.com/

schemeIs()

boolean schemeIs(in string scheme);

An optimization to do scheme checks without requiring the users of nsIURI to GetScheme, thereby saving extra allocating and freeing. Returns true if the schemes match (case ignored).

clone()

nsIURI clone();

Clones the current URI. For some protocols, this is more than just an optimization. For example, under MacOS, the spec of a file URL does not necessarily uniquely identify a file since two volumes could share the same name.

resolve()

AUTF8String resolve(in AUTF8String relativePath);

This method resolves a relative string into an absolute URI string, using this URI as the base. NOTE: some implementations may have no concept of a relative URI.

Attributes

Attribute Type Description
spec nsACString (UTF-8) Returns a string representation of the URI. Setting the spec causes the new spec to be parsed, initializing the URI.
prePath readonly nsACString (UTF-8) The prePath (eg. scheme://user:password@host:port) returns the string before the path. This is useful for authentication or managing sessions.

Some characters may be escaped.

scheme nsACString (US-ASCII) The Scheme is the protocol to which this URI refers. The scheme is restricted to the US-ASCII charset per RFC2396.
userPass nsACString (UTF-8) The username:password (or username only if value doesn't contain a ':')

Some characters may be escaped.

username nsACString (UTF-8) The optional username, assuming the preHost consists of username:password.

Some characters may be escaped.

password nsACString (UTF-8) The optional password, assuming the preHost consists of username:password.

Some characters may be escaped.

hostPort nsACString (UTF-8) The host:port (or simply the host, if port == -1).

Characters are NOT escaped.

host nsACString (UTF-8) The host is the internet domain name to which this URI refers. It could be an IPv4 (or IPv6) address literal. If supported, it could be a non-ASCII internationalized domain name.

Characters are NOT escaped.

port PRInt32 A port value of -1 corresponds to the protocol's default port (eg. -1 implies port 80 for http URIs).
path nsACString (UTF-8) The path, typically including at least a leading '/' (but may also be empty, depending on the protocol).

Some characters may be escaped.

asciiSpec readonly nsACString (US-ASCII) The URI spec with an ASCII compatible encoding. Host portion follows the IDNA draft spec. Other parts are URL-escaped per the rules of RFC2396. The result is strictly ASCII.
asciiHost readonly nsACString (US-ASCII) The URI host with an ASCII compatible encoding. Follows the IDNA draft spec for converting internationalized domain names (UTF-8) to ASCII for compatibility with existing internet infrasture.
originCharset readonly nsACString The charset of the document from which this URI originated. An empty value implies UTF-8.

If this value is something other than UTF-8 then the URI components (e.g., spec, prePath, username, etc.) will all be fully URL-escaped. Otherwise, the URI components may contain unescaped multibyte UTF-8 characters.


Languages

Page last modified 13:33, 4 Ene 2008 by Serxio?

Archivos (0)