Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsNetUtil.h File Reference
#include "nsNetError.h"
#include "nsNetCID.h"
#include "nsReadableUtils.h"
#include "nsString.h"
#include "nsMemory.h"
#include "nsCOMPtr.h"
#include "prio.h"
#include "nsIURI.h"
#include "nsIInputStream.h"
#include "nsIOutputStream.h"
#include "nsISafeOutputStream.h"
#include "nsIStreamListener.h"
#include "nsIRequestObserverProxy.h"
#include "nsIStreamListenerProxy.h"
#include "nsISimpleStreamListener.h"
#include "nsILoadGroup.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIIOService.h"
#include "nsIServiceManager.h"
#include "nsIChannel.h"
#include "nsIInputStreamChannel.h"
#include "nsITransport.h"
#include "nsIStreamTransportService.h"
#include "nsIHttpChannel.h"
#include "nsIDownloader.h"
#include "nsIStreamLoader.h"
#include "nsIUnicharStreamLoader.h"
#include "nsIPipe.h"
#include "nsIProtocolHandler.h"
#include "nsIFileProtocolHandler.h"
#include "nsIStringStream.h"
#include "nsILocalFile.h"
#include "nsIFileStreams.h"
#include "nsIProtocolProxyService.h"
#include "nsIProxyInfo.h"
#include "nsIBufferedStreams.h"
#include "nsIInputStreamPump.h"
#include "nsIAsyncStreamCopier.h"
#include "nsIPersistentProperties2.h"
#include "nsISyncStreamListener.h"
#include "nsInterfaceRequestorAgg.h"
#include "nsInt64.h"
#include "nsINetUtil.h"

Go to the source code of this file.

Functions

const nsGetServiceByCIDWithError do_GetIOService (nsresult *error=0)
nsresult net_EnsureIOService (nsIIOService **ios, nsCOMPtr< nsIIOService > &grip)
nsresult NS_NewURI (nsIURI **result, const nsACString &spec, const char *charset=nsnull, nsIURI *baseURI=nsnull, nsIIOService *ioService=nsnull)
nsresult NS_NewURI (nsIURI **result, const nsAString &spec, const char *charset=nsnull, nsIURI *baseURI=nsnull, nsIIOService *ioService=nsnull)
nsresult NS_NewURI (nsIURI **result, const char *spec, nsIURI *baseURI=nsnull, nsIIOService *ioService=nsnull)
nsresult NS_NewFileURI (nsIURI **result, nsIFile *spec, nsIIOService *ioService=nsnull)
nsresult NS_NewChannel (nsIChannel **result, nsIURI *uri, nsIIOService *ioService=nsnull, nsILoadGroup *loadGroup=nsnull, nsIInterfaceRequestor *callbacks=nsnull, PRUint32 loadFlags=nsIRequest::LOAD_NORMAL)
nsresult NS_OpenURI (nsIInputStream **result, nsIURI *uri, nsIIOService *ioService=nsnull, nsILoadGroup *loadGroup=nsnull, nsIInterfaceRequestor *callbacks=nsnull, PRUint32 loadFlags=nsIRequest::LOAD_NORMAL, nsIChannel **channelOut=nsnull)
nsresult NS_OpenURI (nsIStreamListener *listener, nsISupports *context, nsIURI *uri, nsIIOService *ioService=nsnull, nsILoadGroup *loadGroup=nsnull, nsIInterfaceRequestor *callbacks=nsnull, PRUint32 loadFlags=nsIRequest::LOAD_NORMAL)
nsresult NS_MakeAbsoluteURI (nsACString &result, const nsACString &spec, nsIURI *baseURI, nsIIOService *unused=nsnull)
nsresult NS_MakeAbsoluteURI (char **result, const char *spec, nsIURI *baseURI, nsIIOService *unused=nsnull)
nsresult NS_MakeAbsoluteURI (nsAString &result, const nsAString &spec, nsIURI *baseURI, nsIIOService *unused=nsnull)
nsresult NS_NewInputStreamChannel (nsIChannel **result, nsIURI *uri, nsIInputStream *stream, const nsACString &contentType, const nsACString *contentCharset)
nsresult NS_NewInputStreamChannel (nsIChannel **result, nsIURI *uri, nsIInputStream *stream, const nsACString &contentType=EmptyCString())
nsresult NS_NewInputStreamChannel (nsIChannel **result, nsIURI *uri, nsIInputStream *stream, const nsACString &contentType, const nsACString &contentCharset)
nsresult NS_NewInputStreamPump (nsIInputStreamPump **result, nsIInputStream *stream, PRInt64 streamPos=nsInt64(-1), PRInt64 streamLen=nsInt64(-1), PRUint32 segsize=0, PRUint32 segcount=0, PRBool closeWhenDone=PR_FALSE)
nsresult NS_NewAsyncStreamCopier (nsIAsyncStreamCopier **result, nsIInputStream *source, nsIOutputStream *sink, nsIEventTarget *target, PRBool sourceBuffered=PR_TRUE, PRBool sinkBuffered=PR_TRUE, PRUint32 chunkSize=0)
nsresult NS_NewLoadGroup (nsILoadGroup **result, nsIRequestObserver *obs)
nsresult NS_NewDownloader (nsIStreamListener **result, nsIDownloadObserver *observer, nsIFile *downloadLocation=nsnull)
nsresult NS_NewStreamLoader (nsIStreamLoader **aResult, nsIChannel *aChannel, nsIStreamLoaderObserver *aObserver, nsISupports *aContext)
nsresult NS_NewStreamLoader (nsIStreamLoader **result, nsIURI *uri, nsIStreamLoaderObserver *observer, nsISupports *context=nsnull, nsILoadGroup *loadGroup=nsnull, nsIInterfaceRequestor *callbacks=nsnull, PRUint32 loadFlags=nsIRequest::LOAD_NORMAL, nsIURI *referrer=nsnull)
nsresult NS_NewUnicharStreamLoader (nsIUnicharStreamLoader **aResult, nsIChannel *aChannel, nsIUnicharStreamLoaderObserver *aObserver, nsISupports *aContext=nsnull, PRUint32 aSegmentSize=nsIUnicharStreamLoader::DEFAULT_SEGMENT_SIZE)
nsresult NS_NewSyncStreamListener (nsIStreamListener **aResult, nsIInputStream **aStream)
nsresult NS_ImplementChannelOpen (nsIChannel *aChannel, nsIInputStream **aResult)
 Implement the nsIChannel::Open(nsIInputStream**) method using the channel's AsyncOpen method.
nsresult NS_NewRequestObserverProxy (nsIRequestObserver **aResult, nsIRequestObserver *aObserver, nsIEventQueue *aEventQ=nsnull)
nsresult NS_NewSimpleStreamListener (nsIStreamListener **aResult, nsIOutputStream *aSink, nsIRequestObserver *aObserver=nsnull)
nsresult NS_NewAsyncStreamListener (nsIStreamListener **result, nsIStreamListener *receiver, nsIEventQueue *eventQueue)
nsresult NS_CheckPortSafety (PRInt32 port, const char *scheme, nsIIOService *ioService=nsnull)
nsresult NS_NewProxyInfo (const nsACString &type, const nsACString &host, PRInt32 port, PRUint32 flags, nsIProxyInfo **result)
nsresult NS_GetFileProtocolHandler (nsIFileProtocolHandler **result, nsIIOService *ioService=nsnull)
nsresult NS_GetFileFromURLSpec (const nsACString &inURL, nsIFile **result, nsIIOService *ioService=nsnull)
nsresult NS_GetURLSpecFromFile (nsIFile *aFile, nsACString &aUrl, nsIIOService *ioService=nsnull)
nsresult NS_ExamineForProxy (const char *scheme, const char *host, PRInt32 port, nsIProxyInfo **proxyInfo)
nsresult NS_ParseContentType (const nsACString &rawContentType, nsCString &contentType, nsCString &contentCharset)
nsresult NS_NewLocalFileInputStream (nsIInputStream **aResult, nsIFile *aFile, PRInt32 aIOFlags=-1, PRInt32 aPerm=-1, PRInt32 aBehaviorFlags=0)
nsresult NS_NewLocalFileOutputStream (nsIOutputStream **aResult, nsIFile *aFile, PRInt32 aIOFlags=-1, PRInt32 aPerm=-1, PRInt32 aBehaviorFlags=0)
nsresult NS_NewSafeLocalFileOutputStream (nsIOutputStream **aResult, nsIFile *aFile, PRInt32 aIOFlags=-1, PRInt32 aPerm=-1, PRInt32 aBehaviorFlags=0)
nsresult NS_BackgroundInputStream (nsIInputStream **aResult, nsIInputStream *aStream, PRUint32 aSegmentSize=0, PRUint32 aSegmentCount=0)
nsresult NS_BackgroundOutputStream (nsIOutputStream **aResult, nsIOutputStream *aStream, PRUint32 aSegmentSize=0, PRUint32 aSegmentCount=0)
nsresult NS_NewBufferedInputStream (nsIInputStream **aResult, nsIInputStream *aStr, PRUint32 aBufferSize)
nsresult NS_NewBufferedOutputStream (nsIOutputStream **aResult, nsIOutputStream *aStr, PRUint32 aBufferSize)
nsresult NS_NewPostDataStream (nsIInputStream **result, PRBool isFile, const nsACString &data, PRUint32 encodeFlags, nsIIOService *unused=nsnull)
nsresult NS_LoadPersistentPropertiesFromURI (nsIPersistentProperties **result, nsIURI *uri, nsIIOService *ioService=nsnull)
nsresult NS_LoadPersistentPropertiesFromURISpec (nsIPersistentProperties **result, const nsACString &spec, const char *charset=nsnull, nsIURI *baseURI=nsnull, nsIIOService *ioService=nsnull)
void NS_QueryNotificationCallbacks (nsIChannel *aChannel, const nsIID &aIID, void **aResult)
 NS_QueryNotificationCallbacks implements the canonical algorithm for querying interfaces from a channel's notification callbacks.
template<class T >
void NS_QueryNotificationCallbacks (nsIChannel *aChannel, nsCOMPtr< T > &aResult)
void NS_QueryNotificationCallbacks (nsIInterfaceRequestor *aCallbacks, nsILoadGroup *aLoadGroup, const nsIID &aIID, void **aResult)
 Alternate form of NS_QueryNotificationCallbacks designed for use by nsIChannel implementations.
template<class T >
void NS_QueryNotificationCallbacks (nsIInterfaceRequestor *aCallbacks, nsILoadGroup *aLoadGroup, nsCOMPtr< T > &aResult)
template<class T >
void NS_QueryNotificationCallbacks (const nsCOMPtr< nsIInterfaceRequestor > &aCallbacks, const nsCOMPtr< nsILoadGroup > &aLoadGroup, nsCOMPtr< T > &aResult)
template<class T >
void NS_QueryNotificationCallbacks (const nsCOMPtr< nsIChannel > &aChannel, nsCOMPtr< T > &aResult)
nsresult NS_NewNotificationCallbacksAggregation (nsIInterfaceRequestor *aCallbacks, nsILoadGroup *aLoadGroup, nsIInterfaceRequestor **aResult)
 This function returns a nsIInterfaceRequestor instance that returns the same result as NS_QueryNotificationCallbacks when queried.

Function Documentation

const nsGetServiceByCIDWithError do_GetIOService ( nsresult error = 0) [inline]

Definition at line 93 of file nsNetUtil.h.

{
    static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
    return nsGetServiceByCIDWithError(kIOServiceCID, error);
}

Here is the caller graph for this function:

nsresult net_EnsureIOService ( nsIIOService **  ios,
nsCOMPtr< nsIIOService > &  grip 
) [inline]

Definition at line 101 of file nsNetUtil.h.

{
    nsresult rv = NS_OK;
    if (!*ios) {
        grip = do_GetIOService(&rv);
        *ios = grip;
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_BackgroundInputStream ( nsIInputStream **  aResult,
nsIInputStream aStream,
PRUint32  aSegmentSize = 0,
PRUint32  aSegmentCount = 0 
) [inline]

Definition at line 766 of file nsNetUtil.h.

{
    nsresult rv;
    nsCOMPtr<nsIStreamTransportService> sts =
        do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID, &rv);
    if (NS_SUCCEEDED(rv)) {
        nsCOMPtr<nsITransport> inTransport;
        rv = sts->CreateInputTransport(aStream, nsInt64(-1), nsInt64(-1), PR_TRUE,
                                       getter_AddRefs(inTransport));
        if (NS_SUCCEEDED(rv))
            rv = inTransport->OpenInputStream(nsITransport::OPEN_BLOCKING,
                                              aSegmentSize, aSegmentCount,
                                              aResult);
    }
    return rv;
}

Here is the call graph for this function:

nsresult NS_BackgroundOutputStream ( nsIOutputStream **  aResult,
nsIOutputStream aStream,
PRUint32  aSegmentSize = 0,
PRUint32  aSegmentCount = 0 
) [inline]

Definition at line 790 of file nsNetUtil.h.

{
    nsresult rv;
    nsCOMPtr<nsIStreamTransportService> sts =
        do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID, &rv);
    if (NS_SUCCEEDED(rv)) {
        nsCOMPtr<nsITransport> inTransport;
        rv = sts->CreateOutputTransport(aStream, nsInt64(-1), nsInt64(-1), PR_TRUE,
                                        getter_AddRefs(inTransport));
        if (NS_SUCCEEDED(rv))
            rv = inTransport->OpenOutputStream(nsITransport::OPEN_BLOCKING,
                                               aSegmentSize, aSegmentCount,
                                               aResult);
    }
    return rv;
}

Here is the call graph for this function:

nsresult NS_CheckPortSafety ( PRInt32  port,
const char *  scheme,
nsIIOService ioService = nsnull 
) [inline]

Definition at line 580 of file nsNetUtil.h.

{
    nsresult rv;
    nsCOMPtr<nsIIOService> grip;
    rv = net_EnsureIOService(&ioService, grip);
    if (ioService) {
        PRBool allow;
        rv = ioService->AllowPort(port, scheme, &allow);
        if (NS_SUCCEEDED(rv) && !allow)
            rv = NS_ERROR_PORT_ACCESS_NOT_ALLOWED;
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_ExamineForProxy ( const char *  scheme,
const char *  host,
PRInt32  port,
nsIProxyInfo **  proxyInfo 
) [inline]

Definition at line 655 of file nsNetUtil.h.

{
    nsresult rv;
    static NS_DEFINE_CID(kPPSServiceCID, NS_PROTOCOLPROXYSERVICE_CID);
    nsCOMPtr<nsIProtocolProxyService> pps = do_GetService(kPPSServiceCID, &rv);
    if (NS_SUCCEEDED(rv)) {
        nsCAutoString spec(scheme);
        spec.Append("://");
        spec.Append(host);
        spec.Append(':');
        spec.AppendInt(port);
        // XXXXX - Under no circumstances whatsoever should any code which
        // wants a uri do this. I do this here because I do not, in fact,
        // actually want a uri (the dummy uris created here may not be 
        // syntactically valid for the specific protocol), and all we need
        // is something which has a valid scheme, hostname, and a string
        // to pass to PAC if needed - bbaetz
        static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID);    
        nsCOMPtr<nsIURI> uri = do_CreateInstance(kStandardURLCID, &rv);
        if (NS_SUCCEEDED(rv)) {
            rv = uri->SetSpec(spec);
            if (NS_SUCCEEDED(rv))
                rv = pps->Resolve(uri, 0, proxyInfo);
        }
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_GetFileFromURLSpec ( const nsACString &  inURL,
nsIFile **  result,
nsIIOService ioService = nsnull 
) [inline]

Definition at line 629 of file nsNetUtil.h.

{
    nsresult rv;
    nsCOMPtr<nsIFileProtocolHandler> fileHandler;
    rv = NS_GetFileProtocolHandler(getter_AddRefs(fileHandler), ioService);
    if (NS_SUCCEEDED(rv))
        rv = fileHandler->GetFileFromURLSpec(inURL, result);
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_GetFileProtocolHandler ( nsIFileProtocolHandler **  result,
nsIIOService ioService = nsnull 
) [inline]

Definition at line 613 of file nsNetUtil.h.

{
    nsresult rv;
    nsCOMPtr<nsIIOService> grip;
    rv = net_EnsureIOService(&ioService, grip);
    if (ioService) {
        nsCOMPtr<nsIProtocolHandler> handler;
        rv = ioService->GetProtocolHandler("file", getter_AddRefs(handler));
        if (NS_SUCCEEDED(rv))
            rv = CallQueryInterface(handler, result);
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_GetURLSpecFromFile ( nsIFile aFile,
nsACString &  aUrl,
nsIIOService ioService = nsnull 
) [inline]

Definition at line 642 of file nsNetUtil.h.

{
    nsresult rv;
    nsCOMPtr<nsIFileProtocolHandler> fileHandler;
    rv = NS_GetFileProtocolHandler(getter_AddRefs(fileHandler), ioService);
    if (NS_SUCCEEDED(rv))
        rv = fileHandler->GetURLSpecFromFile(aFile, aUrl);
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_ImplementChannelOpen ( nsIChannel aChannel,
nsIInputStream **  aResult 
) [inline]

Implement the nsIChannel::Open(nsIInputStream**) method using the channel's AsyncOpen method.

NOTE: Reading from the returned nsIInputStream may spin the current thread's event queue, which could result in any event being processed.

Definition at line 508 of file nsNetUtil.h.

{
    nsCOMPtr<nsIStreamListener> listener;
    nsCOMPtr<nsIInputStream> stream;
    nsresult rv = NS_NewSyncStreamListener(getter_AddRefs(listener),
                                           getter_AddRefs(stream));
    if (NS_SUCCEEDED(rv)) {
        rv = aChannel->AsyncOpen(listener, nsnull);
        if (NS_SUCCEEDED(rv)) {
            PRUint32 n;
            // block until the initial response is received or an error occurs.
            rv = stream->Available(&n);
            if (NS_SUCCEEDED(rv))
                NS_ADDREF(*aResult = stream);
        }
    }
    return rv;
}

Here is the call graph for this function:

nsresult NS_LoadPersistentPropertiesFromURI ( nsIPersistentProperties **  result,
nsIURI uri,
nsIIOService ioService = nsnull 
) [inline]

Definition at line 875 of file nsNetUtil.h.

{
    nsCOMPtr<nsIInputStream> in;
    nsresult rv = NS_OpenURI(getter_AddRefs(in), uri, ioService);
    if (NS_SUCCEEDED(rv)) {
        nsCOMPtr<nsIPersistentProperties> properties = 
            do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID, &rv);
        if (NS_SUCCEEDED(rv)) {
            rv = properties->Load(in);
            if (NS_SUCCEEDED(rv))
                NS_ADDREF(*result = properties);
        }
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_LoadPersistentPropertiesFromURISpec ( nsIPersistentProperties **  result,
const nsACString &  spec,
const char *  charset = nsnull,
nsIURI baseURI = nsnull,
nsIIOService ioService = nsnull 
) [inline]

Definition at line 894 of file nsNetUtil.h.

{
    nsCOMPtr<nsIURI> uri;
    nsresult rv = 
        NS_NewURI(getter_AddRefs(uri), spec, charset, baseURI, ioService);

    if (NS_SUCCEEDED(rv))
        rv = NS_LoadPersistentPropertiesFromURI(result, uri, ioService);

    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_MakeAbsoluteURI ( nsACString &  result,
const nsACString &  spec,
nsIURI baseURI,
nsIIOService unused = nsnull 
) [inline]

Definition at line 238 of file nsNetUtil.h.

{
    nsresult rv;
    if (!baseURI) {
        NS_WARNING("It doesn't make sense to not supply a base URI");
        result = spec;
        rv = NS_OK;
    }
    else if (spec.IsEmpty())
        rv = baseURI->GetSpec(result);
    else
        rv = baseURI->Resolve(spec, result);
    return rv;
}

Here is the caller graph for this function:

nsresult NS_MakeAbsoluteURI ( char **  result,
const char *  spec,
nsIURI baseURI,
nsIIOService unused = nsnull 
) [inline]

Definition at line 257 of file nsNetUtil.h.

{
    nsresult rv;
    nsCAutoString resultBuf;
    rv = NS_MakeAbsoluteURI(resultBuf, nsDependentCString(spec), baseURI);
    if (NS_SUCCEEDED(rv)) {
        *result = ToNewCString(resultBuf);
        if (!*result)
            rv = NS_ERROR_OUT_OF_MEMORY;
    }
    return rv;
}

Here is the call graph for this function:

nsresult NS_MakeAbsoluteURI ( nsAString &  result,
const nsAString &  spec,
nsIURI baseURI,
nsIIOService unused = nsnull 
) [inline]

Definition at line 274 of file nsNetUtil.h.

{
    nsresult rv;
    if (!baseURI) {
        NS_WARNING("It doesn't make sense to not supply a base URI");
        result = spec;
        rv = NS_OK;
    }
    else {
        nsCAutoString resultBuf;
        if (spec.IsEmpty())
            rv = baseURI->GetSpec(resultBuf);
        else
            rv = baseURI->Resolve(NS_ConvertUCS2toUTF8(spec), resultBuf);
        if (NS_SUCCEEDED(rv))
            CopyUTF8toUTF16(resultBuf, result);
    }
    return rv;
}

Here is the call graph for this function:

nsresult NS_NewAsyncStreamCopier ( nsIAsyncStreamCopier **  result,
nsIInputStream source,
nsIOutputStream sink,
nsIEventTarget target,
PRBool  sourceBuffered = PR_TRUE,
PRBool  sinkBuffered = PR_TRUE,
PRUint32  chunkSize = 0 
) [inline]

Definition at line 367 of file nsNetUtil.h.

{
    nsresult rv;
    static NS_DEFINE_CID(kAsyncStreamCopierCID, NS_ASYNCSTREAMCOPIER_CID);
    nsCOMPtr<nsIAsyncStreamCopier> copier =
        do_CreateInstance(kAsyncStreamCopierCID, &rv);
    if (NS_SUCCEEDED(rv)) {
        rv = copier->Init(source, sink, target, sourceBuffered, sinkBuffered, chunkSize);
        if (NS_SUCCEEDED(rv))
            NS_ADDREF(*result = copier);
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewAsyncStreamListener ( nsIStreamListener **  result,
nsIStreamListener receiver,
nsIEventQueue eventQueue 
) [inline]

Definition at line 563 of file nsNetUtil.h.

{
    nsresult rv;
    static NS_DEFINE_CID(kAsyncStreamListenerCID, NS_ASYNCSTREAMLISTENER_CID);
    nsCOMPtr<nsIAsyncStreamListener> lsnr =
        do_CreateInstance(kAsyncStreamListenerCID, &rv);
    if (NS_SUCCEEDED(rv)) {
        rv = lsnr->Init(receiver, eventQueue);
        if (NS_SUCCEEDED(rv))
            NS_ADDREF(*result = lsnr);
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewBufferedInputStream ( nsIInputStream **  aResult,
nsIInputStream aStr,
PRUint32  aBufferSize 
) [inline]

Definition at line 811 of file nsNetUtil.h.

{
    nsresult rv;
    static NS_DEFINE_CID(kBufferedInputStreamCID, NS_BUFFEREDINPUTSTREAM_CID);
    nsCOMPtr<nsIBufferedInputStream> in =
        do_CreateInstance(kBufferedInputStreamCID, &rv);
    if (NS_SUCCEEDED(rv)) {
        rv = in->Init(aStr, aBufferSize);
        if (NS_SUCCEEDED(rv))
            NS_ADDREF(*aResult = in);
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewBufferedOutputStream ( nsIOutputStream **  aResult,
nsIOutputStream aStr,
PRUint32  aBufferSize 
) [inline]

Definition at line 830 of file nsNetUtil.h.

{
    nsresult rv;
    static NS_DEFINE_CID(kBufferedOutputStreamCID, NS_BUFFEREDOUTPUTSTREAM_CID);
    nsCOMPtr<nsIBufferedOutputStream> out =
        do_CreateInstance(kBufferedOutputStreamCID, &rv);
    if (NS_SUCCEEDED(rv)) {
        rv = out->Init(aStr, aBufferSize);
        if (NS_SUCCEEDED(rv))
            NS_ADDREF(*aResult = out);
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewChannel ( nsIChannel **  result,
nsIURI uri,
nsIIOService ioService = nsnull,
nsILoadGroup loadGroup = nsnull,
nsIInterfaceRequestor callbacks = nsnull,
PRUint32  loadFlags = nsIRequest::LOAD_NORMAL 
) [inline]

Definition at line 159 of file nsNetUtil.h.

{
    nsresult rv;
    nsCOMPtr<nsIIOService> grip;
    rv = net_EnsureIOService(&ioService, grip);
    if (ioService) {
        nsIChannel *chan;
        rv = ioService->NewChannelFromURI(uri, &chan);
        if (NS_SUCCEEDED(rv)) {
            if (loadGroup)
                rv |= chan->SetLoadGroup(loadGroup);
            if (callbacks)
                rv |= chan->SetNotificationCallbacks(callbacks);
            if (loadFlags != nsIRequest::LOAD_NORMAL)
                rv |= chan->SetLoadFlags(loadFlags);
            if (NS_SUCCEEDED(rv))
                *result = chan;
            else
                NS_RELEASE(chan);
        }
    }
    return rv;
}

Here is the call graph for this function:

nsresult NS_NewDownloader ( nsIStreamListener **  result,
nsIDownloadObserver observer,
nsIFile downloadLocation = nsnull 
) [inline]

Definition at line 404 of file nsNetUtil.h.

{
    nsresult rv;
    static NS_DEFINE_CID(kDownloaderCID, NS_DOWNLOADER_CID);
    nsCOMPtr<nsIDownloader> downloader =
        do_CreateInstance(kDownloaderCID, &rv);
    if (NS_SUCCEEDED(rv)) {
        rv = downloader->Init(observer, downloadLocation);
        if (NS_SUCCEEDED(rv))
            NS_ADDREF(*result = downloader);
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewFileURI ( nsIURI **  result,
nsIFile spec,
nsIIOService ioService = nsnull 
) [inline]

Definition at line 146 of file nsNetUtil.h.

{
    nsresult rv;
    nsCOMPtr<nsIIOService> grip;
    rv = net_EnsureIOService(&ioService, grip);
    if (ioService)
        rv = ioService->NewFileURI(spec, result);
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewInputStreamChannel ( nsIChannel **  result,
nsIURI uri,
nsIInputStream stream,
const nsACString &  contentType,
const nsACString *  contentCharset 
) [inline]

Definition at line 298 of file nsNetUtil.h.

{
    nsresult rv;
    static NS_DEFINE_CID(kInputStreamChannelCID, NS_INPUTSTREAMCHANNEL_CID);
    nsCOMPtr<nsIInputStreamChannel> channel =
        do_CreateInstance(kInputStreamChannelCID, &rv);
    if (NS_SUCCEEDED(rv)) {
        rv |= channel->SetURI(uri);
        rv |= channel->SetContentStream(stream);
        rv |= channel->SetContentType(contentType);
        if (contentCharset && !contentCharset->IsEmpty()) {
            rv |= channel->SetContentCharset(*contentCharset);
        }
        if (NS_SUCCEEDED(rv))
            NS_ADDREF(*result = channel);
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewInputStreamChannel ( nsIChannel **  result,
nsIURI uri,
nsIInputStream stream,
const nsACString &  contentType = EmptyCString() 
) [inline]

Definition at line 322 of file nsNetUtil.h.

{
    return NS_NewInputStreamChannel(result, uri, stream, contentType, nsnull);
}

Here is the call graph for this function:

nsresult NS_NewInputStreamChannel ( nsIChannel **  result,
nsIURI uri,
nsIInputStream stream,
const nsACString &  contentType,
const nsACString &  contentCharset 
) [inline]

Definition at line 331 of file nsNetUtil.h.

{
    return NS_NewInputStreamChannel(result, uri, stream, contentType,
                                    &contentCharset);
}

Here is the call graph for this function:

nsresult NS_NewInputStreamPump ( nsIInputStreamPump **  result,
nsIInputStream stream,
PRInt64  streamPos = nsInt64(-1),
PRInt64  streamLen = nsInt64(-1),
PRUint32  segsize = 0,
PRUint32  segcount = 0,
PRBool  closeWhenDone = PR_FALSE 
) [inline]

Definition at line 342 of file nsNetUtil.h.

{
    nsresult rv;
    static NS_DEFINE_CID(kInputStreamPumpCID, NS_INPUTSTREAMPUMP_CID);
    nsCOMPtr<nsIInputStreamPump> pump =
        do_CreateInstance(kInputStreamPumpCID, &rv);
    if (NS_SUCCEEDED(rv)) {
        rv = pump->Init(stream, streamPos, streamLen,
                        segsize, segcount, closeWhenDone);
        if (NS_SUCCEEDED(rv))
            NS_ADDREF(*result = pump);
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewLoadGroup ( nsILoadGroup **  result,
nsIRequestObserver obs 
) [inline]

Definition at line 388 of file nsNetUtil.h.

{
    nsresult rv;
    static NS_DEFINE_CID(kLoadGroupCID, NS_LOADGROUP_CID);
    nsCOMPtr<nsILoadGroup> group =
        do_CreateInstance(kLoadGroupCID, &rv);
    if (NS_SUCCEEDED(rv)) {
        rv = group->SetGroupObserver(obs);
        if (NS_SUCCEEDED(rv))
            NS_ADDREF(*result = group);
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewLocalFileInputStream ( nsIInputStream **  aResult,
nsIFile aFile,
PRInt32  aIOFlags = -1,
PRInt32  aPerm = -1,
PRInt32  aBehaviorFlags = 0 
) [inline]

Definition at line 705 of file nsNetUtil.h.

{
    nsresult rv;
    static NS_DEFINE_CID(kLocalFileInputStreamCID, NS_LOCALFILEINPUTSTREAM_CID);
    nsCOMPtr<nsIFileInputStream> in =
        do_CreateInstance(kLocalFileInputStreamCID, &rv);
    if (NS_SUCCEEDED(rv)) {
        rv = in->Init(aFile, aIOFlags, aPerm, aBehaviorFlags);
        if (NS_SUCCEEDED(rv))
            NS_ADDREF(*aResult = in);
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewLocalFileOutputStream ( nsIOutputStream **  aResult,
nsIFile aFile,
PRInt32  aIOFlags = -1,
PRInt32  aPerm = -1,
PRInt32  aBehaviorFlags = 0 
) [inline]

Definition at line 724 of file nsNetUtil.h.

{
    nsresult rv;
    static NS_DEFINE_CID(kLocalFileOutputStreamCID, NS_LOCALFILEOUTPUTSTREAM_CID);
    nsCOMPtr<nsIFileOutputStream> out =
        do_CreateInstance(kLocalFileOutputStreamCID, &rv);
    if (NS_SUCCEEDED(rv)) {
        rv = out->Init(aFile, aIOFlags, aPerm, aBehaviorFlags);
        if (NS_SUCCEEDED(rv))
            NS_ADDREF(*aResult = out);
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

This function returns a nsIInterfaceRequestor instance that returns the same result as NS_QueryNotificationCallbacks when queried.

It is useful as the value for nsISocketTransport::securityCallbacks.

Definition at line 1009 of file nsNetUtil.h.

{
    nsCOMPtr<nsIInterfaceRequestor> cbs;
    if (aLoadGroup)
        aLoadGroup->GetNotificationCallbacks(getter_AddRefs(cbs));
    return NS_NewInterfaceRequestorAggregation(aCallbacks, cbs, aResult);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewPostDataStream ( nsIInputStream **  result,
PRBool  isFile,
const nsACString &  data,
PRUint32  encodeFlags,
nsIIOService unused = nsnull 
) [inline]

Definition at line 848 of file nsNetUtil.h.

{
    if (isFile) {
        nsresult rv;
        nsCOMPtr<nsILocalFile> file;
        nsCOMPtr<nsIInputStream> fileStream;

        rv = NS_NewNativeLocalFile(data, PR_FALSE, getter_AddRefs(file));
        if (NS_SUCCEEDED(rv)) {
            rv = NS_NewLocalFileInputStream(getter_AddRefs(fileStream), file);
            if (NS_SUCCEEDED(rv)) {
                // wrap the file stream with a buffered input stream
                rv = NS_NewBufferedInputStream(result, fileStream, 8192);
            }
        }
        return rv;
    }

    // otherwise, create a string stream for the data (copies)
    return NS_NewCStringInputStream(result, data);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewProxyInfo ( const nsACString &  type,
const nsACString &  host,
PRInt32  port,
PRUint32  flags,
nsIProxyInfo **  result 
) [inline]

Definition at line 597 of file nsNetUtil.h.

{
    nsresult rv;
    static NS_DEFINE_CID(kPPSServiceCID, NS_PROTOCOLPROXYSERVICE_CID);
    nsCOMPtr<nsIProtocolProxyService> pps = do_GetService(kPPSServiceCID, &rv);
    if (NS_SUCCEEDED(rv))
        rv = pps->NewProxyInfo(type, host, port, flags, PR_UINT32_MAX, nsnull,
                               result);
    return rv; 
}

Here is the call graph for this function:

nsresult NS_NewRequestObserverProxy ( nsIRequestObserver **  aResult,
nsIRequestObserver aObserver,
nsIEventQueue aEventQ = nsnull 
) [inline]

Definition at line 529 of file nsNetUtil.h.

{
    nsresult rv;
    static NS_DEFINE_CID(kRequestObserverProxyCID, NS_REQUESTOBSERVERPROXY_CID);
    nsCOMPtr<nsIRequestObserverProxy> proxy =
        do_CreateInstance(kRequestObserverProxyCID, &rv);
    if (NS_SUCCEEDED(rv)) {
        rv = proxy->Init(aObserver, aEventQ);
        if (NS_SUCCEEDED(rv))
            NS_ADDREF(*aResult = proxy);
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewSafeLocalFileOutputStream ( nsIOutputStream **  aResult,
nsIFile aFile,
PRInt32  aIOFlags = -1,
PRInt32  aPerm = -1,
PRInt32  aBehaviorFlags = 0 
) [inline]

Definition at line 744 of file nsNetUtil.h.

{
    nsresult rv;
    static NS_DEFINE_CID(kSafeLocalFileOutputStreamCID, NS_SAFELOCALFILEOUTPUTSTREAM_CID);
    nsCOMPtr<nsIFileOutputStream> out =
        do_CreateInstance(kSafeLocalFileOutputStreamCID, &rv);
    if (NS_SUCCEEDED(rv)) {
        rv = out->Init(aFile, aIOFlags, aPerm, aBehaviorFlags);
        if (NS_SUCCEEDED(rv))
            NS_ADDREF(*aResult = out);
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewSimpleStreamListener ( nsIStreamListener **  aResult,
nsIOutputStream aSink,
nsIRequestObserver aObserver = nsnull 
) [inline]

Definition at line 546 of file nsNetUtil.h.

{
    nsresult rv;
    static NS_DEFINE_CID(kSimpleStreamListenerCID, NS_SIMPLESTREAMLISTENER_CID);
    nsCOMPtr<nsISimpleStreamListener> listener = 
        do_CreateInstance(kSimpleStreamListenerCID, &rv);
    if (NS_SUCCEEDED(rv)) {
        rv = listener->Init(aSink, aObserver);
        if (NS_SUCCEEDED(rv))
            NS_ADDREF(*aResult = listener);
    }
    return rv;
}

Here is the call graph for this function:

nsresult NS_NewStreamLoader ( nsIStreamLoader **  aResult,
nsIChannel aChannel,
nsIStreamLoaderObserver aObserver,
nsISupports *  aContext 
) [inline]

Definition at line 421 of file nsNetUtil.h.

{
    nsresult rv;
    static NS_DEFINE_CID(kStreamLoaderCID, NS_STREAMLOADER_CID);
    nsCOMPtr<nsIStreamLoader> loader =
        do_CreateInstance(kStreamLoaderCID, &rv);
    if (NS_SUCCEEDED(rv)) {
        rv = loader->Init(aChannel, aObserver, aContext);
        if (NS_SUCCEEDED(rv))
            NS_ADDREF(*aResult = loader);
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewStreamLoader ( nsIStreamLoader **  result,
nsIURI uri,
nsIStreamLoaderObserver observer,
nsISupports *  context = nsnull,
nsILoadGroup loadGroup = nsnull,
nsIInterfaceRequestor callbacks = nsnull,
PRUint32  loadFlags = nsIRequest::LOAD_NORMAL,
nsIURI referrer = nsnull 
) [inline]

Definition at line 439 of file nsNetUtil.h.

{
    nsresult rv;
    nsCOMPtr<nsIChannel> channel;
    rv = NS_NewChannel(getter_AddRefs(channel),
                       uri,
                       nsnull,
                       loadGroup,
                       callbacks,
                       loadFlags);
    if (NS_SUCCEEDED(rv)) {
        nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
        if (httpChannel)
            httpChannel->SetReferrer(referrer);
        rv = NS_NewStreamLoader(result, channel, observer, context);
    }
    return rv;
}

Here is the call graph for this function:

nsresult NS_NewSyncStreamListener ( nsIStreamListener **  aResult,
nsIInputStream **  aStream 
) [inline]

Definition at line 485 of file nsNetUtil.h.

{
    nsresult rv;
    static NS_DEFINE_CID(kSyncStreamListenerCID, NS_SYNCSTREAMLISTENER_CID);
    nsCOMPtr<nsISyncStreamListener> listener =
        do_CreateInstance(kSyncStreamListenerCID, &rv);
    if (NS_SUCCEEDED(rv)) {
        rv = listener->GetInputStream(aStream);
        if (NS_SUCCEEDED(rv))
            NS_ADDREF(*aResult = listener);
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewUnicharStreamLoader ( nsIUnicharStreamLoader **  aResult,
nsIChannel aChannel,
nsIUnicharStreamLoaderObserver aObserver,
nsISupports *  aContext = nsnull,
PRUint32  aSegmentSize = nsIUnicharStreamLoader::DEFAULT_SEGMENT_SIZE 
) [inline]

Definition at line 466 of file nsNetUtil.h.

{
    nsresult rv;
    static NS_DEFINE_CID(kUnicharStreamLoaderCID, NS_UNICHARSTREAMLOADER_CID);
    nsCOMPtr<nsIUnicharStreamLoader> loader =
        do_CreateInstance(kUnicharStreamLoaderCID, &rv);
    if (NS_SUCCEEDED(rv)) {
        rv = loader->Init(aChannel, aObserver, aContext, aSegmentSize);
        if (NS_SUCCEEDED(rv))
            NS_ADDREF(*aResult = loader);
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewURI ( nsIURI **  result,
const nsACString &  spec,
const char *  charset = nsnull,
nsIURI baseURI = nsnull,
nsIIOService ioService = nsnull 
) [inline]

Definition at line 112 of file nsNetUtil.h.

{
    nsresult rv;
    nsCOMPtr<nsIIOService> grip;
    rv = net_EnsureIOService(&ioService, grip);
    if (ioService)
        rv = ioService->NewURI(spec, charset, baseURI, result);
    return rv; 
}

Here is the call graph for this function:

nsresult NS_NewURI ( nsIURI **  result,
const nsAString &  spec,
const char *  charset = nsnull,
nsIURI baseURI = nsnull,
nsIIOService ioService = nsnull 
) [inline]

Definition at line 127 of file nsNetUtil.h.

{
    return NS_NewURI(result, NS_ConvertUCS2toUTF8(spec), charset, baseURI, ioService);
}

Here is the call graph for this function:

nsresult NS_NewURI ( nsIURI **  result,
const char *  spec,
nsIURI baseURI = nsnull,
nsIIOService ioService = nsnull 
) [inline]

Definition at line 137 of file nsNetUtil.h.

{
    return NS_NewURI(result, nsDependentCString(spec), nsnull, baseURI, ioService);
}

Here is the call graph for this function:

nsresult NS_OpenURI ( nsIInputStream **  result,
nsIURI uri,
nsIIOService ioService = nsnull,
nsILoadGroup loadGroup = nsnull,
nsIInterfaceRequestor callbacks = nsnull,
PRUint32  loadFlags = nsIRequest::LOAD_NORMAL,
nsIChannel **  channelOut = nsnull 
) [inline]

Definition at line 193 of file nsNetUtil.h.

{
    nsresult rv;
    nsCOMPtr<nsIChannel> channel;
    rv = NS_NewChannel(getter_AddRefs(channel), uri, ioService,
                       loadGroup, callbacks, loadFlags);
    if (NS_SUCCEEDED(rv)) {
        nsIInputStream *stream;
        rv = channel->Open(&stream);
        if (NS_SUCCEEDED(rv)) {
            *result = stream;
            if (channelOut) {
                *channelOut = nsnull;
                channel.swap(*channelOut);
            }
        }
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_OpenURI ( nsIStreamListener listener,
nsISupports *  context,
nsIURI uri,
nsIIOService ioService = nsnull,
nsILoadGroup loadGroup = nsnull,
nsIInterfaceRequestor callbacks = nsnull,
PRUint32  loadFlags = nsIRequest::LOAD_NORMAL 
) [inline]

Definition at line 220 of file nsNetUtil.h.

{
    nsresult rv;
    nsCOMPtr<nsIChannel> channel;
    rv = NS_NewChannel(getter_AddRefs(channel), uri, ioService,
                       loadGroup, callbacks, loadFlags);
    if (NS_SUCCEEDED(rv))
        rv = channel->AsyncOpen(listener, context);
    return rv;
}

Here is the call graph for this function:

nsresult NS_ParseContentType ( const nsACString &  rawContentType,
nsCString contentType,
nsCString contentCharset 
) [inline]

Definition at line 687 of file nsNetUtil.h.

{
    // contentCharset is left untouched if not present in rawContentType
    nsresult rv;
    nsCOMPtr<nsINetUtil> util = do_GetIOService(&rv);
    NS_ENSURE_SUCCESS(rv, rv);
    nsCString charset;
    PRBool hadCharset;
    rv = util->ParseContentType(rawContentType, charset, &hadCharset,
                                contentType);
    if (NS_SUCCEEDED(rv) && hadCharset)
        contentCharset = charset;
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void NS_QueryNotificationCallbacks ( nsIChannel aChannel,
const nsIID aIID,
void **  aResult 
) [inline]

NS_QueryNotificationCallbacks implements the canonical algorithm for querying interfaces from a channel's notification callbacks.

It first searches the channel's notificationCallbacks attribute, and if the interface is not found there, then it inspects the notificationCallbacks attribute of the channel's loadGroup.

Definition at line 918 of file nsNetUtil.h.

{
    NS_PRECONDITION(aChannel, "null channel");
    *aResult = nsnull;

    nsCOMPtr<nsIInterfaceRequestor> cbs;
    aChannel->GetNotificationCallbacks(getter_AddRefs(cbs));
    if (cbs)
        cbs->GetInterface(aIID, aResult);
    if (!*aResult) {
        // try load group's notification callbacks...
        nsCOMPtr<nsILoadGroup> loadGroup;
        aChannel->GetLoadGroup(getter_AddRefs(loadGroup));
        if (loadGroup) {
            loadGroup->GetNotificationCallbacks(getter_AddRefs(cbs));
            if (cbs)
                cbs->GetInterface(aIID, aResult);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T >
void NS_QueryNotificationCallbacks ( nsIChannel aChannel,
nsCOMPtr< T > &  aResult 
) [inline]

Definition at line 943 of file nsNetUtil.h.

Here is the call graph for this function:

void NS_QueryNotificationCallbacks ( nsIInterfaceRequestor aCallbacks,
nsILoadGroup aLoadGroup,
const nsIID aIID,
void **  aResult 
) [inline]

Alternate form of NS_QueryNotificationCallbacks designed for use by nsIChannel implementations.

Definition at line 955 of file nsNetUtil.h.

{
    *aResult = nsnull;

    if (aCallbacks)
        aCallbacks->GetInterface(aIID, aResult);
    if (!*aResult) {
        // try load group's notification callbacks...
        if (aLoadGroup) {
            nsCOMPtr<nsIInterfaceRequestor> cbs;
            aLoadGroup->GetNotificationCallbacks(getter_AddRefs(cbs));
            if (cbs)
                cbs->GetInterface(aIID, aResult);
        }
    }
}

Here is the call graph for this function:

template<class T >
void NS_QueryNotificationCallbacks ( nsIInterfaceRequestor aCallbacks,
nsILoadGroup aLoadGroup,
nsCOMPtr< T > &  aResult 
) [inline]

Definition at line 977 of file nsNetUtil.h.

{
    NS_QueryNotificationCallbacks(aCallbacks, aLoadGroup,
                                  NS_GET_IID(T),
                                  getter_AddRefs(aResult));
}

Here is the call graph for this function:

template<class T >
void NS_QueryNotificationCallbacks ( const nsCOMPtr< nsIInterfaceRequestor > &  aCallbacks,
const nsCOMPtr< nsILoadGroup > &  aLoadGroup,
nsCOMPtr< T > &  aResult 
) [inline]

Definition at line 988 of file nsNetUtil.h.

{
    NS_QueryNotificationCallbacks(aCallbacks.get(), aLoadGroup.get(), aResult);
}

Here is the call graph for this function:

template<class T >
void NS_QueryNotificationCallbacks ( const nsCOMPtr< nsIChannel > &  aChannel,
nsCOMPtr< T > &  aResult 
) [inline]

Definition at line 997 of file nsNetUtil.h.

Here is the call graph for this function: