mozilla
Your Search Results

    nsIIOService

    This interface provides a set of URL parsing utility functions. These are provided as a convenience to the programmer and in some cases to improve performance by eliminating intermediate data structures and interfaces.
    Inherits from: nsISupports Last changed in Gecko 1.2

    This interface duplicates many of the nsIProtocolHandler methods in a protocol handler independent way (For example newURI() inspects the scheme in order to delegate creation of the new URI to the appropriate protocol handler).

    Note: nsIIOService may only be used from the main thread.

    Implemented by @mozilla.org/network/io-service;1 as a service:

    var iOService = Components.classes["@mozilla.org/network/io-service;1"]
                    .getService(Components.interfaces.nsIIOService);
    

    Method overview

    boolean allowPort(in long aPort, in string aScheme);
    ACString extractScheme(in AUTF8String urlString);
    unsigned long getProtocolFlags(in string aScheme);
    nsIProtocolHandler getProtocolHandler(in string aScheme);
    nsIChannel newChannel(in AUTF8String aSpec, in string aOriginCharset, in nsIURI aBaseURI);
    nsIChannel newChannelFromURI(in nsIURI aURI);
    nsIURI newFileURI(in nsIFile aFile);
    nsIURI newURI(in AUTF8String aSpec, in string aOriginCharset, in nsIURI aBaseURI);

    Attributes

    Attribute Type Description
    offline boolean Returns true if networking is in "offline" mode. When in offline mode, attempts to access the network will fail (although this does not necessarily correlate with whether there is actually a network available -- that's hard to detect without causing the dialer to come up). Observers will be notified of changes to this attribute.

    Methods

    allowPort()

    Checks if a port number is banned. This involves consulting a list of unsafe ports, corresponding to network services that may be easily exploitable. If the given port is considered unsafe, then the protocol handler (corresponding to aScheme) will be asked whether it wishes to override the IO service's decision to block the port. This gives the protocol handler ultimate control over its own security policy while ensuring reasonable, default protection.

    Is similar to nsIProtocolHandler.allowPort().

    boolean allowPort(
      in long aPort,
      in string aScheme
    );
    
    Parameters
    aPort
    The port to check
    aScheme
    The scheme for the protocol handler that could override the IOService's decision.
    Return value

    true if the port is allowed, false otherwise.

    extractScheme()

    Utility to extract the scheme from a URL string, consistently and according to spec (see RFC 3986).

    Note:  Most URL parsing is done via nsIURI, and in fact the scheme can also be extracted from a URL string via nsIURI. This method is provided purely as an optimization.

    ACString extractScheme(
      in AUTF8String urlString
    );
    
    Parameters
    urlString
    The string for the URL to extract the scheme from.
    Return value

    A string corresponding to the scheme.

    Exceptions thrown
    NS_ERROR_MALFORMED_URI
    If URL string is not of the right form.

    getProtocolFlags()

    Returns the protocol flags for a given scheme.

    unsigned long getProtocolFlags(
      in string aScheme
    );
    
    Parameters
    aScheme
    The scheme for which to get the protocol flags.
    Return value

    The value of the protocolFlags attribute for the corresponding nsIProtocolHandler.

    getProtocolHandler()

    Returns a protocol handler for a given URI scheme.

    nsIProtocolHandler getProtocolHandler(
      in string aScheme
    );
    
    Parameters
    aScheme
    The URI scheme for which to get a protocol handler.
    Return value

    An nsIProtocolHandler for the scheme.

    newChannel()

    A shortcut method to avoid repeated calls of newURI() and newChannelFromURI().

    nsIChannel newChannel(
      in AUTF8String aSpec,
      in string aOriginCharset,
      in nsIURI aBaseURI
    );
    
    Parameters
    aSpec
    The spec for the desired uri.
    aOriginCharset
    The charset for the uri. May be null.
    aBaseURI
    The base URI for the spec. May be null. If aSpec is an absolute URL, this parameter is ignored.
    Return value

    Returns an nsIChannel based on aSpec and aBaseURI.

    newChannelFromURI()

    Creates a channel for a given URI.

    nsIChannel newChannelFromURI(
      in nsIURI aURI
    );
    
    Parameters
    aURI
    An nsIURI from which to make a channel.
    Return value

    An nsIChannel for the uri.

    newFileURI()

    This method constructs a new URI from a nsIFile.

    nsIURI newFileURI(
      in nsIFile aFile
    );
    
    Parameters
    aFile
    The nsIFile whose URI is desired.
    Return value

    An nsIURI corresponding to the file.

    newURI()

    This method constructs a new URI by determining the scheme of the URI spec, and then delegating the construction of the URI to the protocol handler for that scheme. QueryInterface can be used on the resulting URI object to obtain a more specific type of URI.

    nsIURI newURI(
      in AUTF8String aSpec,
      in string aOriginCharset,
      in nsIURI aBaseURI
    );
    
    Parameters
    aSpec
    The spec for the desired uri.
    aOriginCharset
    The charset for the uri. May be null.
    aBaseURI
    The base URI for the spec. May be null. If aSpec is an absolute URL, this parameter is ignored.
    Return value

    An nsIURI object corresponding to aSpec and aBaseURI.

    Remarks

    Note:  The proper way to create a new nsIURI is with newURI() method defined above. Do NOT create a new nsIURI with createInstance().

    This was a frozen interface see bug 157131 for details. From Gecko 2.0 interfaces are no longer frozen.

    See also

    Document Tags and Contributors

    Last updated by: Sheppy,