WARNING: Most of this content (with the exception of the Mozilla 1.9 XPCOM reference) is very old, and can be expected to be out of date and possibly obsolete. For better XUL documentation, please visit the XUL hub at the Mozilla Developer Center.

nsINetUtil

IID:57322c6f-f4ec-4e46-8253-b74be220de16
Inherits From:nsISupports

nsINetUtil provides various network-related utility methods.

This interface is implemented by the following components:


Constants

PRUint32 ESCAPE_ALL = 0
PRUint32 ESCAPE_XALPHAS = 1
Leave alphanumeric characters intact, convert spaces to '+',
PRUint32 ESCAPE_XPALPHAS = 2
Leave alphanumeric characters and forward slashes intact,
PRUint32 ESCAPE_URL_PATH = 4
PRUint32 ESCAPE_URL_SCHEME = 1
PRUint32 ESCAPE_URL_USERNAME = 2
PRUint32 ESCAPE_URL_PASSWORD = 4
PRUint32 ESCAPE_URL_HOST = 8
PRUint32 ESCAPE_URL_DIRECTORY = 16
PRUint32 ESCAPE_URL_FILE_BASENAME = 32
PRUint32 ESCAPE_URL_FILE_EXTENSION = 64
PRUint32 ESCAPE_URL_PARAM = 128
PRUint32 ESCAPE_URL_QUERY = 256
PRUint32 ESCAPE_URL_REF = 512
PRUint32 ESCAPE_URL_FILEPATH = 112
PRUint32 ESCAPE_URL_MINIMAL = 1023
PRUint32 ESCAPE_URL_FORCED = 1024
PRUint32 ESCAPE_URL_ONLY_ASCII = 2048
Skip graphic octets (0x20-0x7E) when escaping Skips all ASCII octets (0x00-0x7F) when unescaping
PRUint32 ESCAPE_URL_ONLY_NONASCII = 4096
PRUint32 ESCAPE_URL_COLON = 16384
PRUint32 ESCAPE_URL_SKIP_CONTROL = 32768

Methods

ACString escapeString ( ACString string , PRUint32 escapeType ) ACString escapeURL ( ACString str , PRUint32 flags ) PRBool extractCharsetFromContentType ( AUTF8String typeHeader , out AUTF8String charset , out PRInt32 charsetStart , out PRInt32 charsetEnd ) AUTF8String parseContentType ( AUTF8String typeHeader , out AUTF8String charset , out PRBool hadCharset ) PRBool protocolHasFlags ( nsIURI URI , PRUint32 flag ) nsIURI toImmutableURI ( nsIURI URI ) ACString unescapeString ( ACString str , PRUint32 flags ) PRBool URIChainHasFlags ( nsIURI URI , PRUint32 flags )

ACString escapeString ( ACString string , PRUint32 escapeType )

Escape a string with %00-style escaping

Arguments:
string
escapeType

ACString escapeURL ( ACString str , PRUint32 flags )

%XX-Escape invalid chars in a URL segment.

Arguments:
str: the URL to be escaped
flags: the URL segment type flags
Returns:
the escaped string (the string itself if escaping did not happen)

PRBool extractCharsetFromContentType ( AUTF8String typeHeader , out AUTF8String charset , out PRInt32 charsetStart , out PRInt32 charsetEnd )

Extract the charset parameter location and value from a content-type header.

Arguments:
typeHeader: the header string to parse
charset
charsetStart
charsetEnd
Returns:
whether a charset parameter was found. This can be false even in cases when parseContentType would claim to have a charset, if the type that won out does not have a charset parameter specified, because in this case setting the charset does in fact correspond to appending to the string.

AUTF8String parseContentType ( AUTF8String typeHeader , out AUTF8String charset , out PRBool hadCharset )

Parse a content-type header and return the content type and charset (if any).

Arguments:
typeHeader: the header string to parse
charset
hadCharset
Returns:
the MIME type specified in the header, in lower-case.

PRBool protocolHasFlags ( nsIURI URI , PRUint32 flag )

Test whether the given URI's handler has the given protocol flags.

Arguments:
URI: the URI in question
flag
Returns:
whether the protocol handler for aURI has all the flags in aFlags.

nsIURI toImmutableURI ( nsIURI URI )

Take uRI and produce an immutable version of it for the caller. If uRI is immutable this will be uRI itself; otherwise this will be a clone, marked immutable if possible. Passing null to this method is allowed; in that case it will return null.

Arguments:
URI

ACString unescapeString ( ACString str , PRUint32 flags )

Expands URL escape sequences

Arguments:
str: the URL to be unescaped
flags: only ESCAPE_URL_ONLY_NONASCII and ESCAPE_URL_SKIP_CONTROL are recognized. If |flags| is 0 all escape sequences are unescaped
Returns:
unescaped string

PRBool URIChainHasFlags ( nsIURI URI , PRUint32 flags )

Test whether the protocol handler for this URI or that for any of its inner URIs has the given protocol flags. This will QI uRI to nsINestedURI and walk the nested URI chain.

Arguments:
URI: the URI in question
flags: the flags we're testing for.
Returns:
whether any of the protocol handlers involved have all the flags in aFlags.

Reference documentation is generated from Mozilla's source.

Copyright © 1999-2006 XULPlanet.com