You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.


TOC PREV NEXT INDEX

Embedding Gecko API


nsIIOService


This interface provides a set of network utility functions. It duplicates many of the nsIProtocolHandler methods in a protocol handler independent way (e.g., NewURI inspects the scheme in order to delegate creation of the new URI to the appropriate protocol handler). nsIIOService also 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. It is scriptable.

Methods
getProtocolHandler

Returns a protocol handler for a given URI scheme.

Syntax:

nsIProtocolHandler nsIIOService::getProtocolHandler(
	in string aScheme) 

Parameters:

aScheme: The URI scheme.

Returns:

A reference to the corresponding nsIProtocolHandler.
getProtocolFlags

Returns the protocol flags for a given scheme.

Syntax:

unsigned long nsIIOService::getProtocolFlags(
	in string aScheme) 

Parameters:

aScheme: The URI scheme.

Returns:

The value of the corresponding nsIProtocolHandler::protocolFlags.
newURI

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.

See also: nsIProtocolHandler::newURI.

Syntax:

nsIURI nsIIOService::newURI(in AUTF8String aSpec,
	in string aOriginCharset, in nsIURI aBaseURI) 

Parameters:

aSpec: The URI spec.
aOriginCharset: The charset of the URI.
aBaseURI: The beginning URI.

Returns:

A reference to the new nsIURI object.
newFileURI

Constructs a new URI from an nsIFile.

Syntax:

nsIURI nsIIOService::newFileURI(in nsIFile aFile) 

Parameters:

aFile: The file path.

Returns:

A reference to the new nsIURI object.
newChannelFromURI

Creates a channel for a given URI.

Syntax:

nsIChannel nsIIOService::newChannelFromURI(
	in nsIURI aURI) 

Parameters:

aURI: The nsIURI from which to make the channel.

Returns:

A reference to the new nsIChannel object.
newChannel

Equivalent to newChannelFromURI(newURI(...)).

Syntax:

nsIChannel nsIIOService::newChannel(in AUTF8String aSpec,
	in string aOriginCharset, in nsIURI aBaseURI) 

Parameters:

aSpec: The URI spec.
aOriginCharset: The charset of the URI.
aBaseURI: The beginning URI.

Returns:

A reference to the new nsIChannel object.
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.

See also: nsIProtocolHandler::allowPort.

Syntax:

boolean nsIIOService::allowPort(in long aPort, 
	in string aScheme) 

Parameters:

aPort: The port number.
aScheme: The scheme corresponding to the appropriate protocol handler.

Returns:

TRUE if the port is allowed, FALSE otherwise.
extractScheme

A utility to extract the scheme from a URL string, consistently and according to spec (see RFC 2396).

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.

Syntax:

ACString nsIIOService::extractScheme(
	in AUTF8String urlString) 

Parameters:

urlString: The URL string to parse.

Returns:

The URL scheme.

Note: Throws NS_ERROR_MALFORMED_URI if URL string is not of the right form.

Attributes
attribute boolean nsIIOService::offline

TRUE if networking is in "offline" mode, FALSE otherwise. When in offline mode, attempts to access the network will fail (although this is not necessarily corrolated with whether there is actually a network available -- that's hard to detect without causing the dialer to come up).


Written by:Ellen Evans | Comments, questions, complaints? Bug 143387
TOC PREV NEXT INDEX