Back to index

lightning-sunbird  0.9+nobinonly
Classes | Public Types | Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes
nsHttpChannel Class Reference

#include <nsHttpChannel.h>

Inheritance diagram for nsHttpChannel:
Inheritance graph
[legend]
Collaboration diagram for nsHttpChannel:
Collaboration graph
[legend]

List of all members.

Classes

struct  nsAsyncCallEvent
class  nsContentEncodings

Public Types

typedef void(nsHttpChannel::* nsAsyncCallback )(void)

Public Member Functions

NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIREQUEST
NS_DECL_NSICHANNEL
NS_DECL_NSIHTTPCHANNEL
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSICACHINGCHANNEL
NS_DECL_NSIUPLOADCHANNEL
NS_DECL_NSICACHELISTENER
NS_DECL_NSIENCODEDCHANNEL
NS_DECL_NSIHTTPCHANNELINTERNAL
NS_DECL_NSITRANSPORTEVENTSINK
NS_DECL_NSIRESUMABLECHANNEL
NS_DECL_NSISUPPORTSPRIORITY
NS_DECL_NSIPROTOCOLPROXYCALLBACK 
nsHttpChannel ()
virtual ~nsHttpChannel ()
nsresult Init (nsIURI *uri, PRUint8 capabilities, nsProxyInfo *proxyInfo)
ACString getRequestHeader (in ACString aHeader)
 Get the value of a particular request header.
void setRequestHeader (in ACString aHeader, in ACString aValue, in boolean aMerge)
 Set the value of a particular request header.
void visitRequestHeaders (in nsIHttpHeaderVisitor aVisitor)
 Call this method to visit all request headers.
ACString getResponseHeader (in ACString header)
 Get the value of a particular response header.
void setResponseHeader (in ACString header, in ACString value, in boolean merge)
 Set the value of a particular response header.
void visitResponseHeaders (in nsIHttpHeaderVisitor aVisitor)
 Call this method to visit all response headers.
boolean isNoStoreResponse ()
 Returns true if the server sent a "Cache-Control: no-store" response header.
boolean isNoCacheResponse ()
 Returns true if the server sent the equivalent of a "Cache-control: no-cache" response header.
nsIInputStream open ()
 Synchronously open the channel.
void asyncOpen (in nsIStreamListener aListener, in nsISupports aContext)
 Asynchronously open this channel.
boolean isPending ()
 Indicates whether the request is pending.
void cancel (in nsresult aStatus)
 Cancels the current request.
void suspend ()
 Suspends the current request.
void resume ()
 Resumes the current request.
void getRequestVersion (out unsigned long major, out unsigned long minor)
 Get the major/minor version numbers for the request.
void getResponseVersion (out unsigned long major, out unsigned long minor)
 Get the major/minor version numbers for the response.
void setCookie (in string aCookieHeader)
 Helper method to set a cookie with a consumer-provided cookie header, but using the channel's other information (URI's, prompters, date headers etc).
void onDataAvailable (in nsIRequest aRequest, in nsISupports aContext, in nsIInputStream aInputStream, in unsigned long aOffset, in unsigned long aCount)
 Called when the next chunk of data (corresponding to the request) may be read without blocking the calling thread.
void onStartRequest (in nsIRequest aRequest, in nsISupports aContext)
 Called to signify the beginning of an asynchronous request.
void onStopRequest (in nsIRequest aRequest, in nsISupports aContext, in nsresult aStatusCode)
 Called to signify the end of an asynchronous request.
boolean isFromCache ()
 TRUE if this channel's data is being loaded from the cache.
void setUploadStream (in nsIInputStream aStream, in ACString aContentType, in long aContentLength)
 Sets a stream to be uploaded by this channel.
void onCacheEntryAvailable (in nsICacheEntryDescriptor descriptor, in nsCacheAccessMode accessGranted, in nsresult status)
 Called when the requested access (or appropriate subset) is acquired.
void onTransportStatus (in nsITransport aTransport, in nsresult aStatus, in unsigned long long aProgress, in unsigned long long aProgressMax)
 Transport status notification.
void resumeAt (in unsigned long long startPos, in ACString entityID)
 Prepare this channel for resuming.
void adjustPriority (in long delta)
 This method adjusts the priority attribute by a given delta.
void onProxyAvailable (in nsICancelable aRequest, in nsIURI aURI, in nsIProxyInfo aProxyInfo, in nsresult aStatus)
 This method is called when proxy info is available or when an error in the proxy resolution occurs.

Public Attributes

attribute ACString requestMethod
 Set/get the HTTP request method (default is "GET").
attribute nsIURI referrer
 Get/set the HTTP referrer URI.
attribute boolean allowPipelining
 This attribute is a hint to the channel to indicate whether or not the underlying HTTP transaction should be allowed to be pipelined with other transactions.
attribute unsigned long redirectionLimit
 This attribute specifies the number of redirects this channel is allowed to make.
readonly attribute unsigned long responseStatus
 Get the HTTP response code (e.g., 200).
readonly attribute ACString responseStatusText
 Get the HTTP response status text (e.g., "OK").
readonly attribute boolean requestSucceeded
 Returns true if the HTTP response code indicates success.
attribute nsIURI originalURI
 The original URI used to construct the channel.
readonly attribute nsIURI URI
 The URI corresponding to the channel.
attribute nsISupports owner
 The owner, corresponding to the entity that is responsible for this channel.
attribute nsIInterfaceRequestor notificationCallbacks
 The notification callbacks for the channel.
readonly attribute nsISupports securityInfo
 Transport-level security information (if any) corresponding to the channel.
attribute ACString contentType
 The MIME type of the channel's content if available.
attribute ACString contentCharset
 The character set of the channel's content if available and if applicable.
attribute long contentLength
 The length of the data associated with the channel if available.
const unsigned long LOAD_DOCUMENT_URI = 1 << 16
 Set (e.g., by the docshell) to indicate whether or not the channel corresponds to a document URI.
const unsigned long LOAD_RETARGETED_DOCUMENT_URI = 1 << 17
 If the end consumer for this load has been retargeted after discovering it's content, this flag will be set:
const unsigned long LOAD_REPLACE = 1 << 18
 This flag is set to indicate that onStopRequest may be followed by another onStartRequest/onStopRequest pair.
const unsigned long LOAD_INITIAL_DOCUMENT_URI = 1 << 19
 Set (e.g., by the docshell) to indicate whether or not the channel corresponds to an initial document URI load (e.g., link click).
const unsigned long LOAD_TARGETED = 1 << 20
 Set (e.g., by the URILoader) to indicate whether or not the end consumer for this load has been determined.
const unsigned long LOAD_CALL_CONTENT_SNIFFERS = 1 << 21
 If this flag is set, the channel should call the content sniffers as described in nsNetCID.h about NS_CONTENT_SNIFFER_CATEGORY.
readonly attribute AUTF8String name
 The name of the request.
readonly attribute nsresult status
 The error status associated with the request.
attribute nsILoadGroup loadGroup
 The load group of this request.
attribute nsLoadFlags loadFlags
 The load flags of this request.
const unsigned long LOAD_NORMAL = 0
 No special load flags:
const unsigned long LOAD_BACKGROUND = 1 << 0
 Don't deliver status notifications to the nsIProgressEventSink, or keep this load from completing the nsILoadGroup it may belong to.
const unsigned long INHIBIT_CACHING = 1 << 7
 This flag prevents caching of any kind.
const unsigned long INHIBIT_PERSISTENT_CACHING = 1 << 8
 This flag prevents caching on disk (or other persistent media), which may be needed to preserve privacy.
const unsigned long LOAD_BYPASS_CACHE = 1 << 9
 Force an end-to-end download of content data from the origin server.
const unsigned long LOAD_FROM_CACHE = 1 << 10
 Load from the cache, bypassing protocol specific validation logic.
const unsigned long VALIDATE_ALWAYS = 1 << 11
 The following flags control the frequency of cached content validation when neither LOAD_BYPASS_CACHE or LOAD_FROM_CACHE are set.
const unsigned long VALIDATE_NEVER = 1 << 12
const unsigned long VALIDATE_ONCE_PER_SESSION = 1 << 13
attribute nsIURI documentURI
 An http channel can own a reference to the document URI.
readonly attribute nsIProxyInfo proxyInfo
 Get the proxy info in use by the channel.
attribute nsISupports cacheToken
 Set/get the cache token...
attribute nsISupports cacheKey
 Set/get the cache key...
attribute boolean cacheAsFile
 Specifies whether or not the data should be cached to a file.
readonly attribute nsIFile cacheFile
 Get the "file" where the cached data can be found.
const unsigned long LOAD_BYPASS_LOCAL_CACHE = 1 << 28
 This load flag causes the local cache to be skipped when fetching a request.
const unsigned long LOAD_BYPASS_LOCAL_CACHE_IF_BUSY = 1 << 29
 This load flag causes the local cache to be skipped if the request would otherwise block waiting to access the cache.
const unsigned long LOAD_ONLY_FROM_CACHE = 1 << 30
 This load flag inhibits fetching from the net if the data in the cache has been evicted.
const unsigned long LOAD_ONLY_IF_MODIFIED = 1 << 31
 This load flag controls what happens when a document would be loaded from the cache to satisfy a call to AsyncOpen.
readonly attribute nsIInputStream uploadStream
 Get the stream (to be) uploaded by this channel.
readonly attribute
nsIUTF8StringEnumerator 
contentEncodings
 This attribute holds the MIME types corresponding to the content encodings on the channel.
attribute boolean applyConversion
 This attribute controls whether or not content conversion should be done per the Content-Encoding response header.
readonly attribute ACString entityID
 The entity id for this URI.
const long PRIORITY_HIGHEST = -20
 Typical priority values.
const long PRIORITY_HIGH = -10
const long PRIORITY_NORMAL = 0
const long PRIORITY_LOW = 10
const long PRIORITY_LOWEST = 20
attribute long priority
 This attribute may be modified to change the priority of this object.

Private Member Functions

template<class T >
void GetCallback (nsCOMPtr< T > &aResult)
nsresult AsyncCall (nsAsyncCallback funcPtr)
PRBool RequestIsConditional ()
nsresult Connect (PRBool firstTime=PR_TRUE)
nsresult AsyncAbort (nsresult status)
nsresult SetupTransaction ()
void AddCookiesToRequest ()
void ApplyContentConversions ()
nsresult CallOnStartRequest ()
nsresult ProcessResponse ()
nsresult ProcessNormal ()
nsresult ProcessNotModified ()
nsresult ProcessRedirection (PRUint32 httpStatus)
nsresult ProcessAuthentication (PRUint32 httpStatus)
PRBool ResponseWouldVary ()
void HandleAsyncRedirect ()
void HandleAsyncNotModified ()
nsresult PromptTempRedirect ()
nsresult SetupReplacementChannel (nsIURI *, nsIChannel *, PRBool preserveMethod)
nsresult ProxyFailover ()
nsresult ReplaceWithProxy (nsIProxyInfo *)
nsresult ResolveProxy ()
nsresult OpenCacheEntry (PRBool offline, PRBool *delayed)
nsresult GenerateCacheKey (nsACString &key)
nsresult UpdateExpirationTime ()
nsresult CheckCache ()
nsresult ReadFromCache ()
nsresult CloseCacheEntry (nsresult status)
nsresult InitCacheEntry ()
nsresult StoreAuthorizationMetaData ()
nsresult FinalizeCacheEntry ()
nsresult InstallCacheListener (PRUint32 offset=0)
nsresult SetupByteRangeRequest (PRUint32 partialLen)
nsresult ProcessPartialContent ()
nsresult OnDoneReadingPartialCacheEntry (PRBool *streamDone)
nsresult PrepareForAuthentication (PRBool proxyAuth)
nsresult GenCredsAndSetEntry (nsIHttpAuthenticator *, PRBool proxyAuth, const char *scheme, const char *host, PRInt32 port, const char *dir, const char *realm, const char *challenge, const nsHttpAuthIdentity &ident, nsCOMPtr< nsISupports > &session, char **result)
nsresult GetCredentials (const char *challenges, PRBool proxyAuth, nsAFlatCString &creds)
nsresult GetCredentialsForChallenge (const char *challenge, const char *scheme, PRBool proxyAuth, nsIHttpAuthenticator *auth, nsAFlatCString &creds)
nsresult GetAuthenticator (const char *challenge, nsCString &scheme, nsIHttpAuthenticator **auth)
void ParseRealm (const char *challenge, nsACString &realm)
void GetIdentityFromURI (PRUint32 authFlags, nsHttpAuthIdentity &)
nsresult PromptForIdentity (const char *scheme, const char *host, PRInt32 port, PRBool proxyAuth, const char *realm, const char *authType, PRUint32 authFlags, nsHttpAuthIdentity &)
PRBool ConfirmAuth (const nsString &bundleKey, PRBool doYesNoPrompt)
void CheckForSuperfluousAuth ()
void SetAuthorizationHeader (nsHttpAuthCache *, nsHttpAtom header, const char *scheme, const char *host, PRInt32 port, const char *path, nsHttpAuthIdentity &ident)
void AddAuthorizationHeaders ()
nsresult GetCurrentPath (nsACString &)
void ClearPasswordManagerEntry (const char *scheme, const char *host, PRInt32 port, const char *realm, const PRUnichar *user)
nsresult DoAuthRetry (nsAHttpConnection *)

Static Private Member Functions

static void *PR_CALLBACK AsyncCall_EventHandlerFunc (PLEvent *)
static void PR_CALLBACK AsyncCall_EventCleanupFunc (PLEvent *)

Private Attributes

nsCOMPtr< nsIURImOriginalURI
nsCOMPtr< nsIURImURI
nsCOMPtr< nsIURImDocumentURI
nsCOMPtr< nsIStreamListenermListener
nsCOMPtr< nsISupports > mListenerContext
nsCOMPtr< nsILoadGroupmLoadGroup
nsCOMPtr< nsISupports > mOwner
nsCOMPtr< nsIInterfaceRequestormCallbacks
nsCOMPtr< nsIProgressEventSinkmProgressSink
nsCOMPtr< nsIInputStreammUploadStream
nsCOMPtr< nsIURImReferrer
nsCOMPtr< nsISupports > mSecurityInfo
nsCOMPtr< nsIEventQueuemEventQ
nsCOMPtr< nsICancelablemProxyRequest
nsHttpRequestHead mRequestHead
nsHttpResponseHeadmResponseHead
nsRefPtr< nsInputStreamPumpmTransactionPump
nsHttpTransactionmTransaction
nsHttpConnectionInfomConnectionInfo
nsCString mSpec
PRUint32 mLoadFlags
PRUint32 mStatus
nsUint64 mLogicalOffset
PRUint8 mCaps
PRInt16 mPriority
nsCString mContentTypeHint
nsCString mContentCharsetHint
nsCString mUserSetCookieHeader
nsCOMPtr< nsICacheEntryDescriptormCacheEntry
nsRefPtr< nsInputStreamPumpmCachePump
nsHttpResponseHeadmCachedResponseHead
nsCacheAccessMode mCacheAccess
PRUint32 mPostID
PRUint32 mRequestTime
nsISupports * mProxyAuthContinuationState
nsCString mProxyAuthType
nsISupports * mAuthContinuationState
nsCString mAuthType
nsHttpAuthIdentity mIdent
nsHttpAuthIdentity mProxyIdent
nsCString mEntityID
PRUint64 mStartPos
PRUint8 mRedirectionLimit
PRUint32 mIsPending: 1
PRUint32 mApplyConversion: 1
PRUint32 mAllowPipelining: 1
PRUint32 mCachedContentIsValid: 1
PRUint32 mCachedContentIsPartial: 1
PRUint32 mResponseHeadersModified: 1
PRUint32 mCanceled: 1
PRUint32 mTransactionReplaced: 1
PRUint32 mUploadStreamHasHeaders: 1
PRUint32 mAuthRetryPending: 1
PRUint32 mSuppressDefensiveAuth: 1
PRUint32 mResuming: 1
PRUint32 mOpenedCacheForWriting: 1

Detailed Description

Definition at line 92 of file nsHttpChannel.h.


Member Typedef Documentation

typedef void(nsHttpChannel:: * nsHttpChannel::nsAsyncCallback)(void)

Definition at line 130 of file nsHttpChannel.h.


Constructor & Destructor Documentation

Definition at line 137 of file nsHttpChannel.cpp.


Member Function Documentation

Definition at line 3000 of file nsHttpChannel.cpp.

{
    LOG(("nsHttpChannel::AddAuthorizationHeaders? [this=%x]\n", this));

    // this getter never fails
    nsHttpAuthCache *authCache = gHttpHandler->AuthCache();

    // check if proxy credentials should be sent
    const char *proxyHost = mConnectionInfo->ProxyHost();
    if (proxyHost && mConnectionInfo->UsingHttpProxy())
        SetAuthorizationHeader(authCache, nsHttp::Proxy_Authorization,
                               "http", proxyHost, mConnectionInfo->ProxyPort(),
                               nsnull, // proxy has no path
                               mProxyIdent);

    // check if server credentials should be sent
    nsCAutoString path, scheme;
    if (NS_SUCCEEDED(GetCurrentPath(path)) &&
        NS_SUCCEEDED(mURI->GetScheme(scheme))) {
        SetAuthorizationHeader(authCache, nsHttp::Authorization,
                               scheme.get(),
                               mConnectionInfo->Host(),
                               mConnectionInfo->Port(),
                               path.get(),
                               mIdent);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 628 of file nsHttpChannel.cpp.

{
    nsXPIDLCString cookie;

    nsICookieService *cs = gHttpHandler->GetCookieService();
    if (cs)
        cs->GetCookieStringFromHttp(mURI,
                                    mDocumentURI ? mDocumentURI : mOriginalURI,
                                    this,
                                    getter_Copies(cookie));
    if (cookie.IsEmpty())
        cookie = mUserSetCookieHeader;
    else if (!mUserSetCookieHeader.IsEmpty())
        cookie.Append(NS_LITERAL_CSTRING("; ") + mUserSetCookieHeader);

    // overwrite any existing cookie headers.  be sure to clear any
    // existing cookies if we have no cookies to set or if the cookie
    // service is unavailable.
    mRequestHead.SetHeader(nsHttp::Cookie, cookie, PR_FALSE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

This method adjusts the priority attribute by a given delta.

It helps reduce the amount of coding required to increment or decrement the value of the priority attribute.

Definition at line 650 of file nsHttpChannel.cpp.

{
    if (!mResponseHead)
        return;

    LOG(("nsHttpChannel::ApplyContentConversions [this=%x]\n", this));

    if (!mApplyConversion) {
        LOG(("not applying conversion per mApplyConversion\n"));
        return;
    }

    const char *val = mResponseHead->PeekHeader(nsHttp::Content_Encoding);
    if (gHttpHandler->IsAcceptableEncoding(val)) {
        nsCOMPtr<nsIStreamConverterService> serv;
        nsresult rv = gHttpHandler->
                GetStreamConverterService(getter_AddRefs(serv));
        // we won't fail to load the page just because we couldn't load the
        // stream converter service.. carry on..
        if (NS_SUCCEEDED(rv)) {
            nsCOMPtr<nsIStreamListener> converter;
            nsCAutoString from(val);
            ToLowerCase(from);
            rv = serv->AsyncConvertData(from.get(),
                                        "uncompressed",
                                        mListener,
                                        mListenerContext,
                                        getter_AddRefs(converter));
            if (NS_SUCCEEDED(rv)) {
                LOG(("converter installed from \'%s\' to \'uncompressed\'\n", val));
                mListener = converter;
            }
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 394 of file nsHttpChannel.cpp.

{
    LOG(("nsHttpChannel::AsyncAbort [this=%x status=%x]\n", this, status));

    mStatus = status;
    mIsPending = PR_FALSE;

    // create a proxy for the listener..
    nsCOMPtr<nsIRequestObserver> observer;
    NS_NewRequestObserverProxy(getter_AddRefs(observer), mListener, mEventQ);
    if (observer) {
        observer->OnStartRequest(this, mListenerContext);
        observer->OnStopRequest(this, mListenerContext, mStatus);
    }
    else {
        NS_ERROR("unable to create request observer proxy");
        // XXX else, no proxy object manager... what do we do?
    }
    mListener = 0;
    mListenerContext = 0;

    // finally remove ourselves from the load group.
    if (mLoadGroup)
        mLoadGroup->RemoveRequest(this, nsnull, status);

    return NS_OK;
}

Here is the call graph for this function:

Definition at line 252 of file nsHttpChannel.cpp.

{
    nsresult rv;

    nsAsyncCallEvent *event = new nsAsyncCallEvent;
    if (!event)
        return NS_ERROR_OUT_OF_MEMORY;

    event->mFuncPtr = funcPtr;

    NS_ADDREF_THIS();

    PL_InitEvent(event, this,
                 nsHttpChannel::AsyncCall_EventHandlerFunc,
                 nsHttpChannel::AsyncCall_EventCleanupFunc);

    rv = mEventQ->PostEvent(event);
    if (NS_FAILED(rv)) {
        PL_DestroyEvent(event);
        NS_RELEASE_THIS();
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 293 of file nsHttpChannel.cpp.

{
    delete (nsAsyncCallEvent *) ev;
}

Here is the caller graph for this function:

Definition at line 277 of file nsHttpChannel.cpp.

{
    nsHttpChannel *chan =
        NS_STATIC_CAST(nsHttpChannel *, PL_GetEventOwner(ev));

    nsAsyncCallEvent *ace = (nsAsyncCallEvent *) ev;
    nsAsyncCallback funcPtr = ace->mFuncPtr;

    if (chan) {
        (chan->*funcPtr)();
        NS_RELEASE(chan);
    }
    return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIChannel::asyncOpen ( in nsIStreamListener  aListener,
in nsISupports  aContext 
) [inherited]

Asynchronously open this channel.

Data is fed to the specified stream listener as it becomes available. The stream listener's methods are called on the thread that calls asyncOpen and are not called until after asyncOpen returns.

Parameters:
aListenerthe nsIStreamListener implementation
aContextan opaque parameter forwarded to aListener's methods

Definition at line 706 of file nsHttpChannel.cpp.

{
    if (mResponseHead && mResponseHead->ContentType().IsEmpty()) {
        if (!mContentTypeHint.IsEmpty())
            mResponseHead->SetContentType(mContentTypeHint);
        else {
            // Uh-oh.  We had better find out what type we are!

            // XXX This does not work with content-encodings...  but
            // neither does applying the conversion from the URILoader

            nsCOMPtr<nsIStreamConverterService> serv;
            nsresult rv = gHttpHandler->
                GetStreamConverterService(getter_AddRefs(serv));
            // If we failed, we just fall through to the "normal" case
            if (NS_SUCCEEDED(rv)) {
                nsCOMPtr<nsIStreamListener> converter;
                rv = serv->AsyncConvertData(UNKNOWN_CONTENT_TYPE,
                                            "*/*",
                                            mListener,
                                            mListenerContext,
                                            getter_AddRefs(converter));
                if (NS_SUCCEEDED(rv)) {
                    mListener = converter;
                }
            }
        }
    }

    if (mResponseHead && mResponseHead->ContentCharset().IsEmpty())
        mResponseHead->SetContentCharset(mContentCharsetHint);

    if (mResponseHead)
        SetPropertyAsInt64(NS_CHANNEL_PROP_CONTENT_LENGTH,
                           mResponseHead->ContentLength());

    // Allow consumers to override our content type
    if ((mLoadFlags & LOAD_CALL_CONTENT_SNIFFERS) &&
        gIOService->GetContentSniffers().Count() != 0) {
        // NOTE: We can have both a txn pump and a cache pump when the cache
        // content is partial. In that case, we need to read from the cache,
        // because that's the one that has the initial contents.
        nsInputStreamPump* pump = mCachePump ? mCachePump : mTransactionPump;
        pump->PeekStream(CallTypeSniffers, NS_STATIC_CAST(nsIChannel*, this));
    }

    LOG(("  calling mListener->OnStartRequest\n"));
    nsresult rv = mListener->OnStartRequest(this, mListenerContext);
    if (NS_FAILED(rv)) return rv;

    // install stream converter if required
    ApplyContentConversions();

    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIRequest::cancel ( in nsresult  aStatus) [inherited]

Cancels the current request.

This will close any open input or output streams and terminate any async requests. Users should normally pass NS_BINDING_ABORTED, although other errors may also be passed. The error passed in will become the value of the status attribute.

Parameters:
aStatusthe reason for canceling this request.

NOTE: most nsIRequest implementations expect aStatus to be a failure code; however, some implementations may allow aStatus to be a success code such as NS_OK. In general, aStatus should be a failure code.

Definition at line 1419 of file nsHttpChannel.cpp.

{
    nsresult rv = NS_OK;

    LOG(("nsHTTPChannel::CheckCache [this=%x entry=%x]",
        this, mCacheEntry.get()));
    
    // Be pessimistic: assume the cache entry has no useful data.
    mCachedContentIsValid = PR_FALSE;

    // Don't proceed unless we have opened a cache entry for reading.
    if (!mCacheEntry || !(mCacheAccess & nsICache::ACCESS_READ))
        return NS_OK;

    nsXPIDLCString buf;

    // Get the method that was used to generate the cached response
    rv = mCacheEntry->GetMetaDataElement("request-method", getter_Copies(buf));
    if (NS_FAILED(rv)) return rv;

    nsHttpAtom method = nsHttp::ResolveAtom(buf);
    if (method == nsHttp::Head) {
        // The cached response does not contain an entity.  We can only reuse
        // the response if the current request is also HEAD.
        if (mRequestHead.Method() != nsHttp::Head)
            return NS_OK;
    }
    buf.Adopt(0);

    // We'll need this value in later computations...
    PRUint32 lastModifiedTime;
    rv = mCacheEntry->GetLastModified(&lastModifiedTime);
    if (NS_FAILED(rv)) return rv;

    // Determine if this is the first time that this cache entry
    // has been accessed during this session.
    PRBool fromPreviousSession =
            (gHttpHandler->SessionStartTime() > lastModifiedTime);

    // Get the cached HTTP response headers
    rv = mCacheEntry->GetMetaDataElement("response-head", getter_Copies(buf));
    if (NS_FAILED(rv)) return rv;

    // Parse the cached HTTP response headers
    NS_ASSERTION(!mCachedResponseHead, "memory leak detected");
    mCachedResponseHead = new nsHttpResponseHead();
    if (!mCachedResponseHead)
        return NS_ERROR_OUT_OF_MEMORY;
    rv = mCachedResponseHead->Parse((char *) buf.get());
    if (NS_FAILED(rv)) return rv;
    buf.Adopt(0);

    // If we were only granted read access, then assume the entry is valid.
    // unless it is INHBIT_CACHING
    if (mCacheAccess == nsICache::ACCESS_READ &&
        !(mLoadFlags & INHIBIT_CACHING)) {
        mCachedContentIsValid = PR_TRUE;
        return NS_OK;
    }

    PRUint16 isCachedRedirect = mCachedResponseHead->Status()/100 == 3;

    if (method != nsHttp::Head && !isCachedRedirect) {
        // If the cached content-length is set and it does not match the data
        // size of the cached content, then the cached response is partial...
        // either we need to issue a byte range request or we need to refetch
        // the entire document.
        nsInt64 contentLength = mCachedResponseHead->ContentLength();
        if (contentLength != nsInt64(-1)) {
            PRUint32 size;
            rv = mCacheEntry->GetDataSize(&size);
            if (NS_FAILED(rv)) return rv;

            if (nsInt64(size) != contentLength) {
                LOG(("Cached data size does not match the Content-Length header "
                     "[content-length=%lld size=%u]\n", PRInt64(contentLength), size));
                if ((nsInt64(size) < contentLength) && mCachedResponseHead->IsResumable()) {
                    // looks like a partial entry.
                    rv = SetupByteRangeRequest(size);
                    if (NS_FAILED(rv)) return rv;
                    mCachedContentIsPartial = PR_TRUE;
                }
                return NS_OK;
            }
        }
    }

    PRBool doValidation = PR_FALSE;

    // Be optimistic: assume that we won't need to do validation
    mRequestHead.ClearHeader(nsHttp::If_Modified_Since);
    mRequestHead.ClearHeader(nsHttp::If_None_Match);

    // If the LOAD_FROM_CACHE flag is set, any cached data can simply be used.
    if (mLoadFlags & LOAD_FROM_CACHE) {
        LOG(("NOT validating based on LOAD_FROM_CACHE load flag\n"));
        doValidation = PR_FALSE;
    }
    // If the VALIDATE_ALWAYS flag is set, any cached data won't be used until
    // it's revalidated with the server.
    else if (mLoadFlags & VALIDATE_ALWAYS) {
        LOG(("Validating based on VALIDATE_ALWAYS load flag\n"));
        doValidation = PR_TRUE;
    }
    // Even if the VALIDATE_NEVER flag is set, there are still some cases in
    // which we must validate the cached response with the server.
    else if (mLoadFlags & VALIDATE_NEVER) {
        LOG(("VALIDATE_NEVER set\n"));
        // if no-store or if no-cache and ssl, validate cached response (see
        // bug 112564 for an explanation of this logic)
        if (mCachedResponseHead->NoStore() ||
           (mCachedResponseHead->NoCache() && mConnectionInfo->UsingSSL())) {
            LOG(("Validating based on (no-store || (no-cache && ssl)) logic\n"));
            doValidation = PR_TRUE;
        }
        else {
            LOG(("NOT validating based on VALIDATE_NEVER load flag\n"));
            doValidation = PR_FALSE;
        }
    }
    // check if validation is strictly required...
    else if (mCachedResponseHead->MustValidate()) {
        LOG(("Validating based on MustValidate() returning TRUE\n"));
        doValidation = PR_TRUE;
    }

    else if (ResponseWouldVary()) {
        LOG(("Validating based on Vary headers returning TRUE\n"));
        doValidation = PR_TRUE;
    }
    // Check if the cache entry has expired...
    else {
        PRUint32 time = 0; // a temporary variable for storing time values...

        rv = mCacheEntry->GetExpirationTime(&time);
        if (NS_FAILED(rv)) return rv;

        if (NowInSeconds() <= time)
            doValidation = PR_FALSE;
        else if (mCachedResponseHead->MustValidateIfExpired())
            doValidation = PR_TRUE;
        else if (mLoadFlags & VALIDATE_ONCE_PER_SESSION) {
            // If the cached response does not include expiration infor-
            // mation, then we must validate the response, despite whether
            // or not this is the first access this session.  This behavior
            // is consistent with existing browsers and is generally expected
            // by web authors.
            rv = mCachedResponseHead->ComputeFreshnessLifetime(&time);
            if (NS_FAILED(rv)) return rv;

            if (time == 0)
                doValidation = PR_TRUE;
            else
                doValidation = fromPreviousSession;
        }
        else
            doValidation = PR_TRUE;

        LOG(("%salidating based on expiration time\n", doValidation ? "V" : "Not v"));
    }

    if (!doValidation) {
        //
        // Check the authorization headers used to generate the cache entry.
        // We must validate the cache entry if:
        //
        // 1) the cache entry was generated prior to this session w/
        //    credentials (see bug 103402).
        // 2) the cache entry was generated w/o credentials, but would now
        //    require credentials (see bug 96705).
        //
        // NOTE: this does not apply to proxy authentication.
        //
        mCacheEntry->GetMetaDataElement("auth", getter_Copies(buf));
        doValidation =
            (fromPreviousSession && !buf.IsEmpty()) ||
            (buf.IsEmpty() && mRequestHead.PeekHeader(nsHttp::Authorization));
    }

    if (!doValidation) {
        // Sites redirect back to the original URI after setting a session/tracking
        // cookie. In such cases, force revalidation so that we hit the net and do not
        // cycle thru cached responses.
        if (isCachedRedirect && mRequestHead.PeekHeader(nsHttp::Cookie))
            doValidation = PR_TRUE;
    }

    mCachedContentIsValid = !doValidation;

    if (doValidation) {
        //
        // now, we are definitely going to issue a HTTP request to the server.
        // make it conditional if possible.
        //
        // do not attempt to validate no-store content, since servers will not
        // expect it to be cached.  (we only keep it in our cache for the
        // purposes of back/forward, etc.)
        //
        // the request method MUST be either GET or HEAD (see bug 175641).
        //
        if (!mCachedResponseHead->NoStore() &&
            (mRequestHead.Method() == nsHttp::Get ||
             mRequestHead.Method() == nsHttp::Head)) {
            const char *val;
            // Add If-Modified-Since header if a Last-Modified was given
            val = mCachedResponseHead->PeekHeader(nsHttp::Last_Modified);
            if (val)
                mRequestHead.SetHeader(nsHttp::If_Modified_Since,
                                       nsDependentCString(val));
            // Add If-None-Match header if an ETag was given in the response
            val = mCachedResponseHead->PeekHeader(nsHttp::ETag);
            if (val)
                mRequestHead.SetHeader(nsHttp::If_None_Match,
                                       nsDependentCString(val));
        }
    }

    LOG(("CheckCache [this=%x doValidation=%d]\n", this, doValidation));
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2895 of file nsHttpChannel.cpp.

{
    // we've been called because it has been determined that this channel is
    // getting loaded without taking the userpass from the URL.  if the URL
    // contained a userpass, then (provided some other conditions are true),
    // we'll give the user an opportunity to abort the channel as this might be
    // an attempt to spoof a different site (see bug 232567).
    if (!mAuthRetryPending) {
        // ask user...
        if (!ConfirmAuth(NS_LITERAL_STRING("SuperfluousAuth"), PR_TRUE)) {
            // calling cancel here sets our mStatus and aborts the HTTP
            // transaction, which prevents OnDataAvailable events.
            Cancel(NS_ERROR_ABORT);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsHttpChannel::ClearPasswordManagerEntry ( const char *  scheme,
const char *  host,
PRInt32  port,
const char *  realm,
const PRUnichar user 
) [private]

Definition at line 4464 of file nsHttpChannel.cpp.

{
    // XXX scheme is currently unused.  see comments in PromptForIdentity

    nsresult rv;
    nsCOMPtr<nsIPasswordManager> passWordManager = do_GetService(NS_PASSWORDMANAGER_CONTRACTID, &rv);
    if (passWordManager) {
        nsCAutoString domain;
        domain.Assign(host);
        domain.Append(':');
        domain.AppendInt(port);

        domain.AppendLiteral(" (");
        domain.Append(realm);
        domain.Append(')');

        passWordManager->RemoveUser(domain, nsDependentString(user));
    }
} 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1702 of file nsHttpChannel.cpp.

{
    nsresult rv = NS_OK;
    if (mCacheEntry) {
        LOG(("nsHttpChannel::CloseCacheEntry [this=%x status=%x]", this, status));

        // don't doom the cache entry if only reading from it...
        if (NS_FAILED(status)
                && (mCacheAccess & nsICache::ACCESS_WRITE) && !mCachePump) {
            LOG(("dooming cache entry!!"));
            rv = mCacheEntry->Doom();
        }

        if (mCachedResponseHead) {
            delete mCachedResponseHead;
            mCachedResponseHead = 0;
        }

        mCachePump = 0;
        mCacheEntry = 0;
        mCacheAccess = 0;
        mOpenedCacheForWriting = PR_FALSE;
    }
    return rv;
}

Here is the caller graph for this function:

PRBool nsHttpChannel::ConfirmAuth ( const nsString bundleKey,
PRBool  doYesNoPrompt 
) [private]

Definition at line 2816 of file nsHttpChannel.cpp.

{
    // skip prompting the user if
    //   1) we've already prompted the user
    //   2) we're not a toplevel channel
    //   3) the userpass length is less than the "phishy" threshold

    if (mSuppressDefensiveAuth || !(mLoadFlags & LOAD_INITIAL_DOCUMENT_URI))
        return PR_TRUE;

    nsresult rv;
    nsCAutoString userPass;
    rv = mURI->GetUserPass(userPass);
    if (NS_FAILED(rv) || (userPass.Length() < gHttpHandler->PhishyUserPassLength()))
        return PR_TRUE;

    // we try to confirm by prompting the user.  if we cannot do so, then
    // assume the user said ok.  this is done to keep things working in
    // embedded builds, where the string bundle might not be present, etc.

    nsCOMPtr<nsIStringBundleService> bundleService =
            do_GetService(NS_STRINGBUNDLE_CONTRACTID);
    if (!bundleService)
        return PR_TRUE;

    nsCOMPtr<nsIStringBundle> bundle;
    bundleService->CreateBundle(NECKO_MSGS_URL, getter_AddRefs(bundle));
    if (!bundle)
        return PR_TRUE;

    nsCAutoString host;
    rv = mURI->GetHost(host);
    if (NS_FAILED(rv))
        return PR_TRUE;

    nsCAutoString user;
    rv = mURI->GetUsername(user);
    if (NS_FAILED(rv))
        return PR_TRUE;

    NS_ConvertUTF8toUTF16 ucsHost(host), ucsUser(user);
    const PRUnichar *strs[2] = { ucsHost.get(), ucsUser.get() };

    nsXPIDLString msg;
    bundle->FormatStringFromName(bundleKey.get(), strs, 2, getter_Copies(msg));
    if (!msg)
        return PR_TRUE;
    
    nsCOMPtr<nsIPrompt> prompt;
    GetCallback(prompt);
    if (!prompt)
        return PR_TRUE;

    // do not prompt again
    mSuppressDefensiveAuth = PR_TRUE;

    PRBool confirmed;
    if (doYesNoPrompt) {
        PRInt32 choice;
        rv = prompt->ConfirmEx(nsnull, msg,
                               nsIPrompt::BUTTON_POS_1_DEFAULT +
                               nsIPrompt::BUTTON_TITLE_YES * nsIPrompt::BUTTON_POS_0 +
                               nsIPrompt::BUTTON_TITLE_NO  * nsIPrompt::BUTTON_POS_1,
                               nsnull, nsnull, nsnull, nsnull, nsnull, &choice);
        if (NS_FAILED(rv))
            return PR_TRUE;

        confirmed = choice == 0;
    }
    else {
        rv = prompt->Confirm(nsnull, msg, &confirmed);
        if (NS_FAILED(rv))
            return PR_TRUE;
    }

    return confirmed;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsHttpChannel::Connect ( PRBool  firstTime = PR_TRUE) [private]

Definition at line 310 of file nsHttpChannel.cpp.

{
    nsresult rv;

    LOG(("nsHttpChannel::Connect [this=%x]\n", this));

    // ensure that we are using a valid hostname
    if (!net_IsValidHostName(nsDependentCString(mConnectionInfo->Host())))
        return NS_ERROR_UNKNOWN_HOST;

    // true when called from AsyncOpen
    if (firstTime) {
        PRBool delayed = PR_FALSE;
        PRBool offline = PR_FALSE;
    
        // are we offline?
        nsCOMPtr<nsIIOService> ioService;
        rv = gHttpHandler->GetIOService(getter_AddRefs(ioService));
        if (NS_FAILED(rv)) return rv;

        ioService->GetOffline(&offline);
        if (offline)
            mLoadFlags |= LOAD_ONLY_FROM_CACHE;
        else if (PL_strcmp(mConnectionInfo->ProxyType(), "unknown") == 0)
            return ResolveProxy();  // Lazily resolve proxy info

        // Don't allow resuming when cache must be used
        if (mResuming && (mLoadFlags & LOAD_ONLY_FROM_CACHE)) {
            LOG(("Resuming from cache is not supported yet"));
            return NS_ERROR_DOCUMENT_NOT_CACHED;
        }

        // open a cache entry for this channel...
        rv = OpenCacheEntry(offline, &delayed);

        if (NS_FAILED(rv)) {
            LOG(("OpenCacheEntry failed [rv=%x]\n", rv));
            // if this channel is only allowed to pull from the cache, then
            // we must fail if we were unable to open a cache entry.
            if (mLoadFlags & LOAD_ONLY_FROM_CACHE)
                return NS_ERROR_DOCUMENT_NOT_CACHED;
            // otherwise, let's just proceed without using the cache.
        }
 
        if (NS_SUCCEEDED(rv) && delayed)
            return NS_OK;
    }

    // we may or may not have a cache entry at this point
    if (mCacheEntry) {
        // inspect the cache entry to determine whether or not we need to go
        // out to net to validate it.  this call sets mCachedContentIsValid
        // and may set request headers as required for cache validation.
        rv = CheckCache();
        NS_ASSERTION(NS_SUCCEEDED(rv), "cache check failed");

        // read straight from the cache if possible...
        if (mCachedContentIsValid) {
            return ReadFromCache();
        }
        else if (mLoadFlags & LOAD_ONLY_FROM_CACHE) {
            // the cache contains the requested resource, but it must be 
            // validated before we can reuse it.  since we are not allowed
            // to hit the net, there's nothing more to do.  the document
            // is effectively not in the cache.
            return NS_ERROR_DOCUMENT_NOT_CACHED;
        }
    }

    // check to see if authorization headers should be included
    AddAuthorizationHeaders();

    // hit the net...
    rv = SetupTransaction();
    if (NS_FAILED(rv)) return rv;

    rv = gHttpHandler->InitiateTransaction(mTransaction, mPriority);
    if (NS_FAILED(rv)) return rv;

    return mTransactionPump->AsyncRead(this, nsnull);
}

Here is the call graph for this function:

Definition at line 4489 of file nsHttpChannel.cpp.

{
    LOG(("nsHttpChannel::DoAuthRetry [this=%x]\n", this));

    NS_ASSERTION(!mTransaction, "should not have a transaction");
    nsresult rv;

    // toggle mIsPending to allow nsIObserver implementations to modify
    // the request headers (bug 95044).
    mIsPending = PR_FALSE;

    // fetch cookies, and add them to the request header.
    // the server response could have included cookies that must be sent with
    // this authentication attempt (bug 84794).
    AddCookiesToRequest();

    // notify "http-on-modify-request" observers
    gHttpHandler->OnModifyRequest(this);

    mIsPending = PR_TRUE;

    // get rid of the old response headers
    delete mResponseHead;
    mResponseHead = nsnull;

    // set sticky connection flag and disable pipelining.
    mCaps |=  NS_HTTP_STICKY_CONNECTION;
    mCaps &= ~NS_HTTP_ALLOW_PIPELINING;
   
    // and create a new one...
    rv = SetupTransaction();
    if (NS_FAILED(rv)) return rv;

    // transfer ownership of connection to transaction
    if (conn)
        mTransaction->SetConnection(conn);

    // rewind the upload stream
    if (mUploadStream) {
        nsCOMPtr<nsISeekableStream> seekable = do_QueryInterface(mUploadStream);
        if (seekable)
            seekable->Seek(nsISeekableStream::NS_SEEK_SET, 0);
    }

    rv = gHttpHandler->InitiateTransaction(mTransaction, mPriority);
    if (NS_FAILED(rv)) return rv;

    return mTransactionPump->AsyncRead(this, nsnull);
}

Here is the call graph for this function:

Definition at line 1838 of file nsHttpChannel.cpp.

{
    LOG(("nsHttpChannel::FinalizeCacheEntry [this=%x]\n", this));

    if (mResponseHead && mResponseHeadersModified) {
        // Set the expiration time for this cache entry
        nsresult rv = UpdateExpirationTime();
        if (NS_FAILED(rv)) return rv;
    }
    return NS_OK;
}

Here is the call graph for this function:

nsresult nsHttpChannel::GenCredsAndSetEntry ( nsIHttpAuthenticator auth,
PRBool  proxyAuth,
const char *  scheme,
const char *  host,
PRInt32  port,
const char *  dir,
const char *  realm,
const char *  challenge,
const nsHttpAuthIdentity ident,
nsCOMPtr< nsISupports > &  session,
char **  result 
) [private]

Definition at line 2178 of file nsHttpChannel.cpp.

{
    nsresult rv;
    PRUint32 authFlags;

    rv = auth->GetAuthFlags(&authFlags);
    if (NS_FAILED(rv)) return rv;

    nsISupports *ss = sessionState;

    // set informations that depend on whether
    // we're authenticating against a proxy
    // or a webserver
    nsISupports **continuationState;

    if (proxyAuth) {
        continuationState = &mProxyAuthContinuationState;
    } else {
        continuationState = &mAuthContinuationState;
    }

    rv = auth->GenerateCredentials(this,
                                   challenge,
                                   proxyAuth,
                                   ident.Domain(),
                                   ident.User(),
                                   ident.Password(),
                                   &ss,
                                   &*continuationState,
                                   result);

    sessionState.swap(ss);
    if (NS_FAILED(rv)) return rv;

    // don't log this in release build since it could contain sensitive info.
#ifdef DEBUG 
    LOG(("generated creds: %s\n", *result));
#endif

    // find out if this authenticator allows reuse of credentials and/or
    // challenge.
    PRBool saveCreds =
        authFlags & nsIHttpAuthenticator::REUSABLE_CREDENTIALS;
    PRBool saveChallenge =
        authFlags & nsIHttpAuthenticator::REUSABLE_CHALLENGE;

    // this getter never fails
    nsHttpAuthCache *authCache = gHttpHandler->AuthCache();

    // create a cache entry.  we do this even though we don't yet know that
    // these credentials are valid b/c we need to avoid prompting the user
    // more than once in case the credentials are valid.
    //
    // if the credentials are not reusable, then we don't bother sticking
    // them in the auth cache.
    rv = authCache->SetAuthEntry(scheme, host, port, directory, realm,
                                 saveCreds ? *result : nsnull,
                                 saveChallenge ? challenge : nsnull,
                                 ident, sessionState);
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsHttpChannel::GenerateCacheKey ( nsACString &  key) [private]

Definition at line 1349 of file nsHttpChannel.cpp.

{
    if (mPostID) {
        char buf[32];
        PR_snprintf(buf, sizeof(buf), "id=%x&uri=", mPostID);
        cacheKey.Assign(buf);
    } else
        cacheKey.Truncate();
    
    // Strip any trailing #ref from the URL before using it as the key
    const char *spec = mSpec.get();
    const char *p = strchr(spec, '#');
    if (p)
        cacheKey.Append(spec, p - spec);
    else
        cacheKey.Append(spec);
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsHttpChannel::GetAuthenticator ( const char *  challenge,
nsCString scheme,
nsIHttpAuthenticator **  auth 
) [private]

Definition at line 2620 of file nsHttpChannel.cpp.

{
    LOG(("nsHttpChannel::GetAuthenticator [this=%x]\n", this));

    const char *p;
  
    // get the challenge type
    if ((p = strchr(challenge, ' ')) != nsnull)
        authType.Assign(challenge, p - challenge);
    else
        authType.Assign(challenge);
  
    // normalize to lowercase
    ToLowerCase(authType);

    nsCAutoString contractid;
    contractid.Assign(NS_HTTP_AUTHENTICATOR_CONTRACTID_PREFIX);
    contractid.Append(authType);

    return CallGetService(contractid.get(), auth);
}

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T >
void nsHttpChannel::GetCallback ( nsCOMPtr< T > &  aResult) [inline, private]

Definition at line 136 of file nsHttpChannel.h.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsHttpChannel::GetCredentials ( const char *  challenges,
PRBool  proxyAuth,
nsAFlatCString creds 
) [private]

Definition at line 2351 of file nsHttpChannel.cpp.

{
    nsCOMPtr<nsIHttpAuthenticator> auth;
    nsCAutoString challenge;

    nsCString authType; // force heap allocation to enable string sharing since
                        // we'll be assigning this value into mAuthType.

    // set informations that depend on whether we're authenticating against a
    // proxy or a webserver
    nsISupports **currentContinuationState;
    nsCString *currentAuthType;

    if (proxyAuth) {
        currentContinuationState = &mProxyAuthContinuationState;
        currentAuthType = &mProxyAuthType;
    } else {
        currentContinuationState = &mAuthContinuationState;
        currentAuthType = &mAuthType;
    }

    nsresult rv = NS_ERROR_NOT_AVAILABLE;
    PRBool gotCreds = PR_FALSE;
    
    // figure out which challenge we can handle and which authenticator to use.
    for (const char *eol = challenges - 1; eol; ) {
        const char *p = eol + 1;

        // get the challenge string (LF separated -- see nsHttpHeaderArray)
        if ((eol = strchr(p, '\n')) != nsnull)
            challenge.Assign(p, eol - p);
        else
            challenge.Assign(p);

        rv = GetAuthenticator(challenge.get(), authType, getter_AddRefs(auth));
        if (NS_SUCCEEDED(rv)) {
            //
            // if we've already selected an auth type from a previous challenge
            // received while processing this channel, then skip others until
            // we find a challenge corresponding to the previously tried auth
            // type.
            //
            if (!currentAuthType->IsEmpty() && authType != *currentAuthType)
                continue;

            //
            // we allow the routines to run all the way through before we
            // decide if they are valid.
            //
            // we don't worry about the auth cache being altered because that
            // would have been the last step, and if the error is from updating
            // the authcache it wasn't really altered anyway. -CTN 
            //
            // at this point the code is really only useful for client side
            // errors (it will not automatically fail over to do a different
            // auth type if the server keeps rejecting what is being sent, even
            // if a particular auth method only knows 1 thing, like a
            // non-identity based authentication method)
            //
            rv = GetCredentialsForChallenge(challenge.get(), authType.get(),
                                            proxyAuth, auth, creds);
            if (NS_SUCCEEDED(rv)) {
                gotCreds = PR_TRUE;
                *currentAuthType = authType;

                break;
            }

            // reset the auth type and continuation state
            NS_IF_RELEASE(*currentContinuationState);
            currentAuthType->Truncate();
        }
    }

    if (!gotCreds && !currentAuthType->IsEmpty()) {
        // looks like we never found the auth type we were looking for.
        // reset the auth type and continuation state, and try again.
        currentAuthType->Truncate();
        NS_IF_RELEASE(*currentContinuationState);

        rv = GetCredentials(challenges, proxyAuth, creds);
    }

    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsHttpChannel::GetCredentialsForChallenge ( const char *  challenge,
const char *  scheme,
PRBool  proxyAuth,
nsIHttpAuthenticator auth,
nsAFlatCString creds 
) [private]

Definition at line 2440 of file nsHttpChannel.cpp.

{
    LOG(("nsHttpChannel::GetCredentialsForChallenge [this=%x proxyAuth=%d challenges=%s]\n",
        this, proxyAuth, challenge));

    // this getter never fails
    nsHttpAuthCache *authCache = gHttpHandler->AuthCache();

    PRUint32 authFlags;
    nsresult rv = auth->GetAuthFlags(&authFlags);
    if (NS_FAILED(rv)) return rv;

    nsCAutoString realm;
    ParseRealm(challenge, realm);

    // if no realm, then use the auth type as the realm.  ToUpperCase so the
    // ficticious realm stands out a bit more.
    // XXX this will cause some single signon misses!
    // XXX this will cause problems when we expose the auth cache to OJI!
    // XXX this was meant to be used with NTLM, which supplies no realm.
    /*
    if (realm.IsEmpty()) {
        realm = authType;
        ToUpperCase(realm);
    }
    */

    // set informations that depend on whether
    // we're authenticating against a proxy
    // or a webserver
    const char *host;
    PRInt32 port;
    nsHttpAuthIdentity *ident;
    nsCAutoString path, scheme;
    PRBool identFromURI = PR_FALSE;
    nsISupports **continuationState;

    if (proxyAuth) {
        NS_ASSERTION (mConnectionInfo->UsingHttpProxy(), "proxyAuth is true, but no HTTP proxy is configured!");

        host = mConnectionInfo->ProxyHost();
        port = mConnectionInfo->ProxyPort();
        ident = &mProxyIdent;
        scheme.AssignLiteral("http");

        continuationState = &mProxyAuthContinuationState;
    }
    else {
        host = mConnectionInfo->Host();
        port = mConnectionInfo->Port();
        ident = &mIdent;

        rv = GetCurrentPath(path);
        if (NS_FAILED(rv)) return rv;

        rv = mURI->GetScheme(scheme);
        if (NS_FAILED(rv)) return rv;

        // if this is the first challenge, then try using the identity
        // specified in the URL.
        if (mIdent.IsEmpty()) {
            GetIdentityFromURI(authFlags, mIdent);
            identFromURI = !mIdent.IsEmpty();
        }

        continuationState = &mAuthContinuationState;
    }

    //
    // if we already tried some credentials for this transaction, then
    // we need to possibly clear them from the cache, unless the credentials
    // in the cache have changed, in which case we'd want to give them a
    // try instead.
    //
    nsHttpAuthEntry *entry = nsnull;
    authCache->GetAuthEntryForDomain(scheme.get(), host, port, realm.get(), &entry);

    // hold reference to the auth session state (in case we clear our
    // reference to the entry).
    nsCOMPtr<nsISupports> sessionStateGrip;
    if (entry)
        sessionStateGrip = entry->mMetaData;

    // for digest auth, maybe our cached nonce value simply timed out...
    PRBool identityInvalid;
    nsISupports *sessionState = sessionStateGrip;
    rv = auth->ChallengeReceived(this,
                                 challenge,
                                 proxyAuth,
                                 &sessionState,
                                 &*continuationState,
                                 &identityInvalid);
    sessionStateGrip.swap(sessionState);
    if (NS_FAILED(rv)) return rv;

    LOG(("  identity invalid = %d\n", identityInvalid));

    if (identityInvalid) {
        if (entry) {
            if (ident->Equals(entry->Identity())) {
                LOG(("  clearing bad auth cache entry\n"));
                // ok, we've already tried this user identity, so clear the
                // corresponding entry from the auth cache.
                ClearPasswordManagerEntry(scheme.get(), host, port, realm.get(), entry->User());
                authCache->ClearAuthEntry(scheme.get(), host, port, realm.get());
                entry = nsnull;
                ident->Clear();
            }
            else if (!identFromURI || nsCRT::strcmp(ident->User(), entry->Identity().User()) == 0) {
                LOG(("  taking identity from auth cache\n"));
                // the password from the auth cache is more likely to be
                // correct than the one in the URL.  at least, we know that it
                // works with the given username.  it is possible for a server
                // to distinguish logons based on the supplied password alone,
                // but that would be quite unusual... and i don't think we need
                // to worry about such unorthodox cases.
                ident->Set(entry->Identity());
                identFromURI = PR_FALSE;
                if (entry->Creds()[0] != '\0') {
                    LOG(("    using cached credentials!\n"));
                    creds.Assign(entry->Creds());
                    return entry->AddPath(path.get());
                }
            }
        }
        else if (!identFromURI) {
            // hmm... identity invalid, but no auth entry!  the realm probably
            // changed (see bug 201986).
            ident->Clear();
        }

        if (!entry && ident->IsEmpty()) {
            // at this point we are forced to interact with the user to get
            // their username and password for this domain.
            rv = PromptForIdentity(scheme.get(), host, port, proxyAuth, realm.get(), 
                                   authType, authFlags, *ident);
            if (NS_FAILED(rv)) return rv;
            identFromURI = PR_FALSE;
        }
    }

    if (identFromURI) {
        // Warn the user before automatically using the identity from the URL
        // to automatically log them into a site (see bug 232567).
        if (!ConfirmAuth(NS_LITERAL_STRING("AutomaticAuth"), PR_FALSE)) {
            // calling cancel here sets our mStatus and aborts the HTTP
            // transaction, which prevents OnDataAvailable events.
            Cancel(NS_ERROR_ABORT);
            // this return code alone is not equivalent to Cancel, since
            // it only instructs our caller that authentication failed.
            // without an explicit call to Cancel, our caller would just
            // load the page that accompanies the HTTP auth challenge.
            return NS_ERROR_ABORT;
        }
    }

    //
    // get credentials for the given user:pass
    //
    // always store the credentials we're trying now so that they will be used
    // on subsequent links.  This will potentially remove good credentials from
    // the cache.  This is ok as we don't want to use cached credentials if the
    // user specified something on the URI or in another manner.  This is so
    // that we don't transparently authenticate as someone they're not
    // expecting to authenticate as.
    //
    nsXPIDLCString result;
    rv = GenCredsAndSetEntry(auth, proxyAuth, scheme.get(), host, port, path.get(),
                             realm.get(), challenge, *ident, sessionStateGrip,
                             getter_Copies(result));
    if (NS_SUCCEEDED(rv))
        creds = result;
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsHttpChannel::GetCurrentPath ( nsACString &  path) [private]

Definition at line 3029 of file nsHttpChannel.cpp.

{
    nsresult rv;
    nsCOMPtr<nsIURL> url = do_QueryInterface(mURI);
    if (url)
        rv = url->GetDirectory(path);
    else
        rv = mURI->GetPath(path);
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsHttpChannel::GetIdentityFromURI ( PRUint32  authFlags,
nsHttpAuthIdentity ident 
) [private]

Definition at line 2645 of file nsHttpChannel.cpp.

{
    LOG(("nsHttpChannel::GetIdentityFromURI [this=%x]\n", this));

    nsAutoString userBuf;
    nsAutoString passBuf;

    // XXX i18n
    nsCAutoString buf;
    mURI->GetUsername(buf);
    if (!buf.IsEmpty()) {
        NS_UnescapeURL(buf);
        CopyASCIItoUCS2(buf, userBuf);
        mURI->GetPassword(buf);
        if (!buf.IsEmpty()) {
            NS_UnescapeURL(buf);
            CopyASCIItoUCS2(buf, passBuf);
        }
    }

    if (!userBuf.IsEmpty())
        SetIdent(ident, authFlags, (PRUnichar *) userBuf.get(), (PRUnichar *) passBuf.get());
}

Here is the call graph for this function:

Here is the caller graph for this function:

ACString nsIHttpChannel::getRequestHeader ( in ACString  aHeader) [inherited]

Get the value of a particular request header.

Parameters:
aHeaderThe case-insensitive name of the request header to query (e.g., "Cache-Control").
Returns:
the value of the request header.
Exceptions:
NS_ERROR_NOT_AVAILABLEif the header is not set.
void nsIHttpChannelInternal::getRequestVersion ( out unsigned long  major,
out unsigned long  minor 
) [inherited]

Get the major/minor version numbers for the request.

ACString nsIHttpChannel::getResponseHeader ( in ACString  header) [inherited]

Get the value of a particular response header.

Parameters:
aHeaderThe case-insensitive name of the response header to query (e.g., "Set-Cookie").
Returns:
the value of the response header.
Exceptions:
NS_ERROR_NOT_AVAILABLEif called before the response has been received (before onStartRequest) or if the header is not set in the response.
void nsIHttpChannelInternal::getResponseVersion ( out unsigned long  major,
out unsigned long  minor 
) [inherited]

Get the major/minor version numbers for the response.

Definition at line 459 of file nsHttpChannel.cpp.

{
    LOG(("nsHttpChannel::HandleAsyncNotModified [this=%p]\n", this));

    if (mListener) {
        mListener->OnStartRequest(this, mListenerContext);
        mListener->OnStopRequest(this, mListenerContext, mStatus);
        mListener = 0;
        mListenerContext = 0;
    }

    CloseCacheEntry(NS_OK);

    mIsPending = PR_FALSE;

    if (mLoadGroup)
        mLoadGroup->RemoveRequest(this, nsnull, mStatus);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 423 of file nsHttpChannel.cpp.

{
    nsresult rv = NS_OK;

    LOG(("nsHttpChannel::HandleAsyncRedirect [this=%p]\n", this));

    // since this event is handled asynchronously, it is possible that this
    // channel could have been canceled, in which case there would be no point
    // in processing the redirect.
    if (NS_SUCCEEDED(mStatus)) {
        rv = ProcessRedirection(mResponseHead->Status());
        if (NS_FAILED(rv)) {
            // If ProcessRedirection fails, then we have to send out the
            // OnStart/OnStop notifications.
            LOG(("ProcessRedirection failed [rv=%x]\n", rv));
            mStatus = rv;
            if (mListener) {
                mListener->OnStartRequest(this, mListenerContext);
                mListener->OnStopRequest(this, mListenerContext, mStatus);
                mListener = 0;
                mListenerContext = 0;
            }
        }
    }

    // close the cache entry... blow it away if we couldn't process
    // the redirect for some reason.
    CloseCacheEntry(rv);

    mIsPending = PR_FALSE;

    if (mLoadGroup)
        mLoadGroup->RemoveRequest(this, nsnull, mStatus);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsHttpChannel::Init ( nsIURI uri,
PRUint8  capabilities,
nsProxyInfo proxyInfo 
)

Definition at line 162 of file nsHttpChannel.cpp.

{
    LOG(("nsHttpChannel::Init [this=%x]\n", this));

    NS_PRECONDITION(uri, "null uri");

    nsresult rv = nsHashPropertyBag::Init();
    if (NS_FAILED(rv))
        return rv;

    mURI = uri;
    mOriginalURI = uri;
    mDocumentURI = nsnull;
    mCaps = caps;

    //
    // Construct connection info object
    //
    nsCAutoString host;
    PRInt32 port = -1;
    PRBool usingSSL = PR_FALSE;
    
    rv = mURI->SchemeIs("https", &usingSSL);
    if (NS_FAILED(rv)) return rv;

    rv = mURI->GetAsciiHost(host);
    if (NS_FAILED(rv)) return rv;

    // reject the URL if it doesn't specify a host
    if (host.IsEmpty())
        return NS_ERROR_MALFORMED_URI;

    rv = mURI->GetPort(&port);
    if (NS_FAILED(rv)) return rv;

    LOG(("host=%s port=%d\n", host.get(), port));

    rv = mURI->GetAsciiSpec(mSpec);
    if (NS_FAILED(rv)) return rv;

    LOG(("uri=%s\n", mSpec.get()));

    mConnectionInfo = new nsHttpConnectionInfo(host, port,
                                               proxyInfo, usingSSL);
    if (!mConnectionInfo)
        return NS_ERROR_OUT_OF_MEMORY;
    NS_ADDREF(mConnectionInfo);

    // make sure our load flags include this bit if this is a secure channel.
    if (usingSSL && !gHttpHandler->IsPersistentHttpsCachingEnabled()) 
        mLoadFlags |= INHIBIT_PERSISTENT_CACHING;

    // Set default request method
    mRequestHead.SetMethod(nsHttp::Get);

    //
    // Set request headers
    //
    nsCAutoString hostLine;
    if (strchr(host.get(), ':')) {
        // host is an IPv6 address literal and must be encapsulated in []'s
        hostLine.Assign('[');
        hostLine.Append(host);
        hostLine.Append(']');
    }
    else
        hostLine.Assign(host);
    if (port != -1) {
        hostLine.Append(':');
        hostLine.AppendInt(port);
    }

    rv = mRequestHead.SetHeader(nsHttp::Host, hostLine);
    if (NS_FAILED(rv)) return rv;

    rv = gHttpHandler->
        AddStandardRequestHeaders(&mRequestHead.Headers(), caps,
                                  !mConnectionInfo->UsingSSL() &&
                                  mConnectionInfo->UsingHttpProxy());

    return rv;
}

Here is the call graph for this function:

Definition at line 1734 of file nsHttpChannel.cpp.

{
    nsresult rv;

    NS_ENSURE_TRUE(mCacheEntry, NS_ERROR_UNEXPECTED);
    // if only reading, nothing to be done here.
    if (mCacheAccess == nsICache::ACCESS_READ)
        return NS_OK;

    // Don't cache the response again if already cached...
    if (mCachedContentIsValid)
        return NS_OK;

    LOG(("nsHttpChannel::InitCacheEntry [this=%x entry=%x]\n",
        this, mCacheEntry.get()));

    // The no-store directive within the 'Cache-Control:' header indicates
    // that we must not store the response in a persistent cache.
    if (mResponseHead->NoStore())
        mLoadFlags |= INHIBIT_PERSISTENT_CACHING;

    // For HTTPS transactions, the storage policy will already be IN_MEMORY.
    // We are concerned instead about load attributes which may have changed.
    if (mLoadFlags & INHIBIT_PERSISTENT_CACHING) {
        rv = mCacheEntry->SetStoragePolicy(nsICache::STORE_IN_MEMORY);
        if (NS_FAILED(rv)) return rv;
    }

    // Store secure data in memory only
    if (mSecurityInfo)
        mCacheEntry->SetSecurityInfo(mSecurityInfo);

    // Set the expiration time for this cache entry
    rv = UpdateExpirationTime();
    if (NS_FAILED(rv)) return rv;

    // Store the HTTP request method with the cache entry so we can distinguish
    // for example GET and HEAD responses.
    rv = mCacheEntry->SetMetaDataElement("request-method", mRequestHead.Method().get());
    if (NS_FAILED(rv)) return rv;

    // Store the HTTP authorization scheme used if any...
    rv = StoreAuthorizationMetaData();
    if (NS_FAILED(rv)) return rv;

    // Iterate over the headers listed in the Vary response header, and
    // store the value of the corresponding request header so we can verify
    // that it has not varied when we try to re-use the cached response at
    // a later time.  Take care not to store "Cookie" headers though.  We
    // take care of "Vary: cookie" in ResponseWouldVary.
    //
    // NOTE: if "Vary: accept, cookie", then we will store the "accept" header
    // in the cache.  we could try to avoid needlessly storing the "accept"
    // header in this case, but it doesn't seem worth the extra code to perform
    // the check.
    {
        nsCAutoString buf, metaKey;
        mResponseHead->GetHeader(nsHttp::Vary, buf);
        if (!buf.IsEmpty()) {
            NS_NAMED_LITERAL_CSTRING(prefix, "request-");
           
            char *val = buf.BeginWriting(); // going to munge buf
            char *token = nsCRT::strtok(val, NS_HTTP_HEADER_SEPS, &val);
            while (token) {
                if ((*token != '*') && (PL_strcasecmp(token, "cookie") != 0)) {
                    nsHttpAtom atom = nsHttp::ResolveAtom(token);
                    const char *requestVal = mRequestHead.PeekHeader(atom);
                    if (requestVal) {
                        // build cache meta data key and set meta data element...
                        metaKey = prefix + nsDependentCString(token);
                        mCacheEntry->SetMetaDataElement(metaKey.get(), requestVal);
                    }
                }
                token = nsCRT::strtok(val, NS_HTTP_HEADER_SEPS, &val);
            }
        }
    }


    // Store the received HTTP head with the cache entry as an element of
    // the meta data.
    nsCAutoString head;
    mResponseHead->Flatten(head, PR_TRUE);
    return mCacheEntry->SetMetaDataElement("response-head", head.get());
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1853 of file nsHttpChannel.cpp.

{
    nsresult rv;

    LOG(("Preparing to write data into the cache [uri=%s]\n", mSpec.get()));

    NS_ASSERTION(mCacheEntry, "no cache entry");
    NS_ASSERTION(mListener, "no listener");

    nsCOMPtr<nsIOutputStream> out;
    rv = mCacheEntry->OpenOutputStream(offset, getter_AddRefs(out));
    if (NS_FAILED(rv)) return rv;

    mOpenedCacheForWriting = PR_TRUE;

    // XXX disk cache does not support overlapped i/o yet
#if 0
    // Mark entry valid inorder to allow simultaneous reading...
    rv = mCacheEntry->MarkValid();
    if (NS_FAILED(rv)) return rv;
#endif

    nsCOMPtr<nsIStreamListenerTee> tee =
        do_CreateInstance(kStreamListenerTeeCID, &rv);
    if (NS_FAILED(rv)) return rv;

    rv = tee->Init(mListener, out);
    if (NS_FAILED(rv)) return rv;

    mListener = tee;
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

TRUE if this channel's data is being loaded from the cache.

This value is undefined before the channel fires its OnStartRequest notification and after the channel fires its OnStopRequest notification.

Returns true if the server sent the equivalent of a "Cache-control: no-cache" response header.

Equivalent response headers include: "Pragma: no-cache", "Expires: 0", and "Expires" with a date value in the past relative to the value of the "Date" header.

Exceptions:
NS_ERROR_NOT_AVAILABLEif called before the response has been received (before onStartRequest).

Returns true if the server sent a "Cache-Control: no-store" response header.

Exceptions:
NS_ERROR_NOT_AVAILABLEif called before the response has been received (before onStartRequest).
boolean nsIRequest::isPending ( ) [inherited]

Indicates whether the request is pending.

nsIRequest::isPending is true when there is an outstanding asynchronous event that will make the request no longer be pending. Requests do not necessarily start out pending; in some cases, requests have to be explicitly initiated (e.g. nsIChannel implementations are only pending once asyncOpen returns successfully).

Requests can become pending multiple times during their lifetime.

Returns:
TRUE if the request has yet to reach completion.
FALSE if the request has reached completion (e.g., after OnStopRequest has fired).
Note:
Suspended requests are still considered pending.
void nsICacheListener::onCacheEntryAvailable ( in nsICacheEntryDescriptor  descriptor,
in nsCacheAccessMode  accessGranted,
in nsresult  status 
) [inherited]

Called when the requested access (or appropriate subset) is acquired.

The status parameter equals NS_OK on success. See nsICacheService.idl for accessGranted values.

void nsIStreamListener::onDataAvailable ( in nsIRequest  aRequest,
in nsISupports  aContext,
in nsIInputStream  aInputStream,
in unsigned long  aOffset,
in unsigned long  aCount 
) [inherited]

Called when the next chunk of data (corresponding to the request) may be read without blocking the calling thread.

The onDataAvailable impl must read exactly |aCount| bytes of data before returning.

Parameters:
aRequestrequest corresponding to the source of the data
aContextuser defined context
aInputStreaminput stream containing the data chunk
aOffsetNumber of bytes that were sent in previous onDataAvailable calls for this request. In other words, the sum of all previous count parameters. If that number is greater than or equal to 2^32, this parameter will be PR_UINT32_MAX (2^32 - 1).
aCountnumber of bytes available in the stream

NOTE: The aInputStream parameter must implement readSegments.

An exception thrown from onDataAvailable has the side-effect of causing the request to be canceled.

Definition at line 1176 of file nsHttpChannel.cpp.

{
    nsresult rv;

    LOG(("nsHttpChannel::OnDoneReadingPartialCacheEntry [this=%x]", this));

    // by default, assume we would have streamed all data or failed...
    *streamDone = PR_TRUE;

    // setup cache listener to append to cache entry
    PRUint32 size;
    rv = mCacheEntry->GetDataSize(&size);
    if (NS_FAILED(rv)) return rv;

    rv = InstallCacheListener(size);
    if (NS_FAILED(rv)) return rv;

    // need to track the logical offset of the data being sent to our listener
    mLogicalOffset = size;

    // we're now completing the cached content, so we can clear this flag.
    // this puts us in the state of a regular download.
    mCachedContentIsPartial = PR_FALSE;

    // resume the transaction if it exists, otherwise the pipe contained the
    // remaining part of the document and we've now streamed all of the data.
    if (mTransactionPump) {
        rv = mTransactionPump->Resume();
        if (NS_SUCCEEDED(rv))
            *streamDone = PR_FALSE;
    }
    else
        NS_NOTREACHED("no transaction");
    return rv;
}

Here is the call graph for this function:

void nsIProtocolProxyCallback::onProxyAvailable ( in nsICancelable  aRequest,
in nsIURI  aURI,
in nsIProxyInfo  aProxyInfo,
in nsresult  aStatus 
) [inherited]

This method is called when proxy info is available or when an error in the proxy resolution occurs.

Parameters:
aRequestThe value returned from asyncResolve.
aURIThe URI passed to asyncResolve.
aProxyInfoThe resulting proxy info or null if there is no associated proxy info for aURI. As with the result of nsIProtocolProxyService's resolve method, a null result implies that a direct connection should be used.
aStatusThe status of the callback. This is a failure code if the request could not be satisfied, in which case the value of aStatus indicates the reason for the failure.
void nsIRequestObserver::onStartRequest ( in nsIRequest  aRequest,
in nsISupports  aContext 
) [inherited]

Called to signify the beginning of an asynchronous request.

Parameters:
aRequestrequest being observed
aContextuser defined context

An exception thrown from onStartRequest has the side-effect of causing the request to be canceled.

Here is the caller graph for this function:

void nsIRequestObserver::onStopRequest ( in nsIRequest  aRequest,
in nsISupports  aContext,
in nsresult  aStatusCode 
) [inherited]

Called to signify the end of an asynchronous request.

This call is always preceded by a call to onStartRequest.

Parameters:
aRequestrequest being observed
aContextuser defined context
aStatusCodereason for stopping (NS_OK if completed successfully)

An exception thrown from onStopRequest is generally ignored.

Here is the caller graph for this function:

void nsITransportEventSink::onTransportStatus ( in nsITransport  aTransport,
in nsresult  aStatus,
in unsigned long long  aProgress,
in unsigned long long  aProgressMax 
) [inherited]

Transport status notification.

Parameters:
aTransportthe transport sending this status notification.
aStatusthe transport status (resolvable to a string using nsIErrorService). See nsISocketTransport for socket specific status codes and more comments.
aProgressthe amount of data either read or written depending on the value of the status code. this value is relative to aProgressMax.
aProgressMaxthe maximum amount of data that will be read or written. if unknown, 0xFFFFFFFF will be passed.

Synchronously open the channel.

Returns:
blocking input stream to the channel's data.

NOTE: nsIChannel implementations are not required to implement this method. Moreover, since this method may block the calling thread, it should not be called on a thread that processes UI events.

nsresult nsHttpChannel::OpenCacheEntry ( PRBool  offline,
PRBool delayed 
) [private]

Definition at line 1257 of file nsHttpChannel.cpp.

{
    nsresult rv;

    *delayed = PR_FALSE;

    LOG(("nsHttpChannel::OpenCacheEntry [this=%x]", this));

    // make sure we're not abusing this function
    NS_PRECONDITION(!mCacheEntry, "cache entry already open");

    nsCAutoString cacheKey;

    if (mRequestHead.Method() == nsHttp::Post) {
        // If the post id is already set then this is an attempt to replay
        // a post transaction via the cache.  Otherwise, we need a unique
        // post id for this transaction.
        if (mPostID == 0)
            mPostID = gHttpHandler->GenerateUniqueID();
    }
    else if ((mRequestHead.Method() != nsHttp::Get) &&
             (mRequestHead.Method() != nsHttp::Head)) {
        // don't use the cache for other types of requests
        return NS_OK;
    }

    if (mRequestHead.PeekHeader(nsHttp::Range)) {
        // we don't support caching for byte range requests initiated
        // by our clients or via nsIResumableChannel.
        // XXX perhaps we could munge their byte range into the cache
        // key to make caching sort'a work.
        return NS_OK;
    }

    if (RequestIsConditional()) {
        // don't use the cache if our consumer is making a conditional request
        // (see bug 331825).
        return NS_OK;
    }

    GenerateCacheKey(cacheKey);

    // Get a cache session with appropriate storage policy
    nsCacheStoragePolicy storagePolicy;
    if (mLoadFlags & INHIBIT_PERSISTENT_CACHING)
        storagePolicy = nsICache::STORE_IN_MEMORY;
    else
        storagePolicy = nsICache::STORE_ANYWHERE; // allow on disk
    nsCOMPtr<nsICacheSession> session;
    rv = gHttpHandler->GetCacheSession(storagePolicy,
                                       getter_AddRefs(session));
    if (NS_FAILED(rv)) return rv;

    // Set the desired cache access mode accordingly...
    nsCacheAccessMode accessRequested;
    if (offline || (mLoadFlags & INHIBIT_CACHING)) {
        // If we have been asked to bypass the cache and not write to the
        // cache, then don't use the cache at all.
        if (BYPASS_LOCAL_CACHE(mLoadFlags) && !offline)
            return NS_ERROR_NOT_AVAILABLE;
        accessRequested = nsICache::ACCESS_READ;
    }
    else if (BYPASS_LOCAL_CACHE(mLoadFlags))
        accessRequested = nsICache::ACCESS_WRITE; // replace cache entry
    else
        accessRequested = nsICache::ACCESS_READ_WRITE; // normal browsing

    // we'll try to synchronously open the cache entry... however, it may be
    // in use and not yet validated, in which case we'll try asynchronously
    // opening the cache entry.
    rv = session->OpenCacheEntry(cacheKey, accessRequested, PR_FALSE,
                                 getter_AddRefs(mCacheEntry));
    if (rv == NS_ERROR_CACHE_WAIT_FOR_VALIDATION) {
        // access to the cache entry has been denied (because the cache entry
        // is probably in use by another channel).
        if (mLoadFlags & LOAD_BYPASS_LOCAL_CACHE_IF_BUSY) {
            LOG(("bypassing local cache since it is busy\n"));
            return NS_ERROR_NOT_AVAILABLE;
        }
        rv = session->AsyncOpenCacheEntry(cacheKey, accessRequested, this);
        if (NS_FAILED(rv)) return rv;
        // we'll have to wait for the cache entry
        *delayed = PR_TRUE;
    }
    else if (NS_SUCCEEDED(rv)) {
        mCacheEntry->GetAccessGranted(&mCacheAccess);
        LOG(("got cache entry [access=%x]\n", mCacheAccess));
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsHttpChannel::ParseRealm ( const char *  challenge,
nsACString &  realm 
) [private]

Definition at line 2670 of file nsHttpChannel.cpp.

{
    //
    // From RFC2617 section 1.2, the realm value is defined as such:
    //
    //    realm       = "realm" "=" realm-value
    //    realm-value = quoted-string
    //
    // but, we'll accept anything after the the "=" up to the first space, or
    // end-of-line, if the string is not quoted.
    //
    const char *p = PL_strcasestr(challenge, "realm=");
    if (p) {
        p += 6;
        if (*p == '"')
            p++;
        const char *end = PL_strchr(p, '"');
        if (!end)
            end = PL_strchr(p, ' ');
        if (end)
            realm.Assign(p, end - p);
        else
            realm.Assign(p);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2304 of file nsHttpChannel.cpp.

{
    LOG(("nsHttpChannel::PrepareForAuthentication [this=%x]\n", this));

    if (!proxyAuth) {
        // reset the current proxy continuation state because our last
        // authentication attempt was completed successfully.
        NS_IF_RELEASE(mProxyAuthContinuationState);
        LOG(("  proxy continuation state has been reset"));
    }

    if (!mConnectionInfo->UsingHttpProxy() || mProxyAuthType.IsEmpty())
        return NS_OK;

    // We need to remove any Proxy_Authorization header left over from a
    // non-request based authentication handshake (e.g., for NTLM auth).

    nsCAutoString contractId;
    contractId.Assign(NS_HTTP_AUTHENTICATOR_CONTRACTID_PREFIX);
    contractId.Append(mProxyAuthType);

    nsresult rv;
    nsCOMPtr<nsIHttpAuthenticator> precedingAuth =
        do_GetService(contractId.get(), &rv);
    if (NS_FAILED(rv))
        return rv;

    PRUint32 precedingAuthFlags;
    rv = precedingAuth->GetAuthFlags(&precedingAuthFlags);
    if (NS_FAILED(rv))
        return rv;

    if (!(precedingAuthFlags & nsIHttpAuthenticator::REQUEST_BASED)) {
        const char *challenges =
                mResponseHead->PeekHeader(nsHttp::Proxy_Authenticate);
        if (!challenges) {
            // delete the proxy authorization header because we weren't
            // asked to authenticate
            mRequestHead.ClearHeader(nsHttp::Proxy_Authorization);
            LOG(("  cleared proxy authorization header"));
        }
    }

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2251 of file nsHttpChannel.cpp.

{
    LOG(("nsHttpChannel::ProcessAuthentication [this=%x code=%u]\n",
        this, httpStatus));

    const char *challenges;
    PRBool proxyAuth = (httpStatus == 407);

    nsresult rv = PrepareForAuthentication(proxyAuth);
    if (NS_FAILED(rv))
        return rv;

    if (proxyAuth) {
        // only allow a proxy challenge if we have a proxy server configured.
        // otherwise, we could inadvertantly expose the user's proxy
        // credentials to an origin server.  We could attempt to proceed as
        // if we had received a 401 from the server, but why risk flirting
        // with trouble?  IE similarly rejects 407s when a proxy server is
        // not configured, so there's no reason not to do the same.
        if (!mConnectionInfo->UsingHttpProxy()) {
            LOG(("rejecting 407 when proxy server not configured!\n"));
            return NS_ERROR_UNEXPECTED;
        }
        if (mConnectionInfo->UsingSSL() && !mTransaction->SSLConnectFailed()) {
            // we need to verify that this challenge came from the proxy
            // server itself, and not some server on the other side of the
            // SSL tunnel.
            LOG(("rejecting 407 from origin server!\n"));
            return NS_ERROR_UNEXPECTED;
        }
        challenges = mResponseHead->PeekHeader(nsHttp::Proxy_Authenticate);
    }
    else
        challenges = mResponseHead->PeekHeader(nsHttp::WWW_Authenticate);
    NS_ENSURE_TRUE(challenges, NS_ERROR_UNEXPECTED);

    nsCAutoString creds;
    rv = GetCredentials(challenges, proxyAuth, creds);
    if (NS_FAILED(rv))
        LOG(("unable to authenticate\n"));
    else {
        // set the authentication credentials
        if (proxyAuth)
            mRequestHead.SetHeader(nsHttp::Proxy_Authorization, creds);
        else
            mRequestHead.SetHeader(nsHttp::Authorization, creds);

        mAuthRetryPending = PR_TRUE; // see DoAuthRetry
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 866 of file nsHttpChannel.cpp.

{
    nsresult rv;

    LOG(("nsHttpChannel::ProcessNormal [this=%x]\n", this));

    // if we're here, then any byte-range requests failed to result in a partial
    // response.  we must clear this flag to prevent BufferPartialContent from
    // being called inside our OnDataAvailable (see bug 136678).
    mCachedContentIsPartial = PR_FALSE;

    // For .gz files, apache sends both a Content-Type: application/x-gzip
    // as well as Content-Encoding: gzip, which is completely wrong.  In
    // this case, we choose to ignore the rogue Content-Encoding header. We
    // must do this early on so as to prevent it from being seen up stream.
    // The same problem exists for Content-Encoding: compress in default
    // Apache installs.
    const char *encoding = mResponseHead->PeekHeader(nsHttp::Content_Encoding);
    if (encoding && PL_strcasestr(encoding, "gzip") && (
        mResponseHead->ContentType().EqualsLiteral(APPLICATION_GZIP) ||
        mResponseHead->ContentType().EqualsLiteral(APPLICATION_GZIP2) ||
        mResponseHead->ContentType().EqualsLiteral(APPLICATION_GZIP3))) {
        // clear the Content-Encoding header
        mResponseHead->ClearHeader(nsHttp::Content_Encoding);
    }
    else if (encoding && PL_strcasestr(encoding, "compress") && (
             mResponseHead->ContentType().EqualsLiteral(APPLICATION_COMPRESS) ||
             mResponseHead->ContentType().EqualsLiteral(APPLICATION_COMPRESS2))) {
        // clear the Content-Encoding header
        mResponseHead->ClearHeader(nsHttp::Content_Encoding);
    }

    // this must be called before firing OnStartRequest, since http clients,
    // such as imagelib, expect our cache entry to already have the correct
    // expiration time (bug 87710).
    if (mCacheEntry) {
        rv = InitCacheEntry();
        if (NS_FAILED(rv))
            CloseCacheEntry(NS_BINDING_ABORTED);
    }

    // Check that the server sent us what we were asking for
    if (mResuming) {
        // Create an entity id from the response
        nsCAutoString id;
        rv = GetEntityID(id);
        if (NS_FAILED(rv)) {
            // If creating an entity id is not possible -> error
            Cancel(NS_ERROR_NOT_RESUMABLE);
        }
        // If we were passed an entity id, verify it's equal to the server's
        else if (!mEntityID.IsEmpty()) {
            if (!mEntityID.Equals(id))
                Cancel(NS_ERROR_ENTITY_CHANGED);
        }
    }

    rv = CallOnStartRequest();
    if (NS_FAILED(rv)) return rv;

    // install cache listener if we still have a cache entry open
    if (mCacheEntry && (mCacheAccess & nsICache::ACCESS_WRITE))
        rv = InstallCacheListener();

    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1217 of file nsHttpChannel.cpp.

{
    nsresult rv;

    LOG(("nsHttpChannel::ProcessNotModified [this=%x]\n", this)); 

    NS_ENSURE_TRUE(mCachedResponseHead, NS_ERROR_NOT_INITIALIZED);
    NS_ENSURE_TRUE(mCacheEntry, NS_ERROR_NOT_INITIALIZED);

    // merge any new headers with the cached response headers
    rv = mCachedResponseHead->UpdateHeaders(mResponseHead->Headers());
    if (NS_FAILED(rv)) return rv;

    // update the cached response head
    nsCAutoString head;
    mCachedResponseHead->Flatten(head, PR_TRUE);
    rv = mCacheEntry->SetMetaDataElement("response-head", head.get());
    if (NS_FAILED(rv)) return rv;

    // make the cached response be the current response
    delete mResponseHead;
    mResponseHead = mCachedResponseHead;
    mCachedResponseHead = 0;

    rv = UpdateExpirationTime();
    if (NS_FAILED(rv)) return rv;

    // notify observers interested in looking at a reponse that has been
    // merged with any cached headers
    gHttpHandler->OnExamineMergedResponse(this);

    mCachedContentIsValid = PR_TRUE;
    rv = ReadFromCache();
    if (NS_FAILED(rv)) return rv;

    mTransactionReplaced = PR_TRUE;
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1122 of file nsHttpChannel.cpp.

{
    // ok, we've just received a 206
    //
    // we need to stream whatever data is in the cache out first, and then
    // pick up whatever data is on the wire, writing it into the cache.

    LOG(("nsHttpChannel::ProcessPartialContent [this=%x]\n", this)); 

    NS_ENSURE_TRUE(mCachedResponseHead, NS_ERROR_NOT_INITIALIZED);
    NS_ENSURE_TRUE(mCacheEntry, NS_ERROR_NOT_INITIALIZED);

    // Check if the content-encoding we now got is different from the one we
    // got before
    if (PL_strcasecmp(mResponseHead->PeekHeader(nsHttp::Content_Encoding),
                      mCachedResponseHead->PeekHeader(nsHttp::Content_Encoding))
                      != 0) {
        Cancel(NS_ERROR_UNEXPECTED); // XXX need better error code
        return CallOnStartRequest();
    }


    // suspend the current transaction
    nsresult rv = mTransactionPump->Suspend();
    if (NS_FAILED(rv)) return rv;

    // merge any new headers with the cached response headers
    rv = mCachedResponseHead->UpdateHeaders(mResponseHead->Headers());
    if (NS_FAILED(rv)) return rv;

    // update the cached response head
    nsCAutoString head;
    mCachedResponseHead->Flatten(head, PR_TRUE);
    rv = mCacheEntry->SetMetaDataElement("response-head", head.get());
    if (NS_FAILED(rv)) return rv;

    // make the cached response be the current response
    delete mResponseHead;
    mResponseHead = mCachedResponseHead;
    mCachedResponseHead = 0;

    rv = UpdateExpirationTime();
    if (NS_FAILED(rv)) return rv;

    // notify observers interested in looking at a response that has been
    // merged with any cached headers (http-on-examine-merged-response).
    gHttpHandler->OnExamineMergedResponse(this);

    // the cached content is valid, although incomplete.
    mCachedContentIsValid = PR_TRUE;
    return ReadFromCache();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1991 of file nsHttpChannel.cpp.

{
    LOG(("nsHttpChannel::ProcessRedirection [this=%x type=%u]\n",
        this, redirectType));

    const char *location = mResponseHead->PeekHeader(nsHttp::Location);

    // if a location header was not given, then we can't perform the redirect,
    // so just carry on as though this were a normal response.
    if (!location)
        return NS_ERROR_FAILURE;

    // make sure non-ASCII characters in the location header are escaped.
    nsCAutoString locationBuf;
    if (NS_EscapeURL(location, -1, esc_OnlyNonASCII, locationBuf))
        location = locationBuf.get();

    if (mRedirectionLimit == 0) {
        LOG(("redirection limit reached!\n"));
        // this error code is fatal, and should be conveyed to our listener.
        Cancel(NS_ERROR_REDIRECT_LOOP);
        return NS_ERROR_REDIRECT_LOOP;
    }

    LOG(("redirecting to: %s [redirection-limit=%u]\n",
        location, PRUint32(mRedirectionLimit)));

    nsresult rv;
    nsCOMPtr<nsIChannel> newChannel;
    nsCOMPtr<nsIURI> newURI;

    // create a new URI using the location header and the current URL
    // as a base...
    nsCOMPtr<nsIIOService> ioService;
    rv = gHttpHandler->GetIOService(getter_AddRefs(ioService));
    if (NS_FAILED(rv)) return rv;

    // the new uri should inherit the origin charset of the current uri
    nsCAutoString originCharset;
    rv = mURI->GetOriginCharset(originCharset);
    if (NS_FAILED(rv))
        originCharset.Truncate();

    rv = ioService->NewURI(nsDependentCString(location), originCharset.get(), mURI,
                           getter_AddRefs(newURI));
    if (NS_FAILED(rv)) return rv;

    // verify that this is a legal redirect
    nsCOMPtr<nsIScriptSecurityManager> securityManager = 
             do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID);
    if (securityManager) {
        rv = securityManager->CheckLoadURI(mURI, newURI,
                                           nsIScriptSecurityManager::DISALLOW_FROM_MAIL |
                                           nsIScriptSecurityManager::DISALLOW_SCRIPT_OR_DATA);
        if (NS_FAILED(rv)) return rv;
    }

    // Kill the current cache entry if we are redirecting
    // back to ourself.
    PRBool redirectingBackToSameURI = PR_FALSE;
    if (mCacheEntry && (mCacheAccess & nsICache::ACCESS_WRITE) &&
        NS_SUCCEEDED(mURI->Equals(newURI, &redirectingBackToSameURI)) &&
        redirectingBackToSameURI)
            mCacheEntry->Doom();

    // move the reference of the old location to the new one if the new
    // one has none.
    nsCOMPtr<nsIURL> newURL = do_QueryInterface(newURI, &rv);
    if (NS_SUCCEEDED(rv)) {
        nsCAutoString ref;
        rv = newURL->GetRef(ref);
        if (NS_SUCCEEDED(rv) && ref.IsEmpty()) {
            nsCOMPtr<nsIURL> baseURL( do_QueryInterface(mURI, &rv) );
            if (NS_SUCCEEDED(rv)) {
                baseURL->GetRef(ref);
                if (!ref.IsEmpty())
                    newURL->SetRef(ref);
            }
        }
    }

    // if we need to re-send POST data then be sure to ask the user first.
    PRBool preserveMethod = (redirectType == 307);
    if (preserveMethod && mUploadStream) {
        rv = PromptTempRedirect();
        if (NS_FAILED(rv)) return rv;
    }

    rv = ioService->NewChannelFromURI(newURI, getter_AddRefs(newChannel));
    if (NS_FAILED(rv)) return rv;

    rv = SetupReplacementChannel(newURI, newChannel, preserveMethod);
    if (NS_FAILED(rv)) return rv;

    // call out to the event sink to notify it of this redirection.
    PRUint32 redirectFlags;
    if (redirectType == 301) // Moved Permanently
        redirectFlags = nsIChannelEventSink::REDIRECT_PERMANENT;
    else
        redirectFlags = nsIChannelEventSink::REDIRECT_TEMPORARY;
    rv = gHttpHandler->OnChannelRedirect(this, newChannel, redirectFlags);
    if (NS_FAILED(rv))
        return rv;

    // And now, the deprecated way
    nsCOMPtr<nsIHttpEventSink> httpEventSink;
    GetCallback(httpEventSink);
    if (httpEventSink) {
        // NOTE: nsIHttpEventSink is only used for compatibility with pre-1.8
        // versions.
        rv = httpEventSink->OnRedirect(this, newChannel);
        if (NS_FAILED(rv)) return rv;
    }
    // XXX we used to talk directly with the script security manager, but that
    // should really be handled by the event sink implementation.

    // begin loading the new channel
    rv = newChannel->AsyncOpen(mListener, mListenerContext);
    if (NS_FAILED(rv)) return rv;

    // close down this channel
    Cancel(NS_BINDING_REDIRECTED);
    
    // disconnect from our listener
    mListener = 0;
    mListenerContext = 0;
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 763 of file nsHttpChannel.cpp.

{
    nsresult rv;
    PRUint32 httpStatus = mResponseHead->Status();

    LOG(("nsHttpChannel::ProcessResponse [this=%x httpStatus=%u]\n",
        this, httpStatus));

    // notify "http-on-examine-response" observers
    gHttpHandler->OnExamineResponse(this);

    // set cookies, if any exist; done after OnExamineResponse to allow those
    // observers to modify the cookie response headers
    SetCookie(mResponseHead->PeekHeader(nsHttp::Set_Cookie));

    // handle unused username and password in url (see bug 232567)
    if (httpStatus != 401 && httpStatus != 407) {
        CheckForSuperfluousAuth();
        if (mCanceled)
            return CallOnStartRequest();

        if (mAuthContinuationState) {
            // reset the current continuation state because our last
            // authentication attempt has been completed successfully
            NS_RELEASE(mAuthContinuationState);
            LOG(("  continuation state has been reset"));
        }
    }

    // handle different server response categories.  Note that we handle
    // caching or not caching of error pages in
    // nsHttpResponseHead::MustValidate; if you change this switch, update that
    // one
    switch (httpStatus) {
    case 200:
    case 203:
        // Per RFC 2616, 14.35.2, "A server MAY ignore the Range header".
        // So if a server does that and sends 200 instead of 206 that we
        // expect, notify our caller.
        if (mResuming) {
            Cancel(NS_ERROR_NOT_RESUMABLE);
            rv = CallOnStartRequest();
            break;
        }
        // these can normally be cached
        rv = ProcessNormal();
        break;
    case 206:
        if (mCachedContentIsPartial) // an internal byte range request...
            rv = ProcessPartialContent();
        else
            rv = ProcessNormal();
        break;
    case 300:
    case 301:
    case 302:
    case 307:
    case 303:
#if 0
    case 305: // disabled as a security measure (see bug 187996).
#endif
        // don't store the response body for redirects
        rv = ProcessRedirection(httpStatus);
        if (NS_SUCCEEDED(rv))
            CloseCacheEntry(InitCacheEntry());
        else {
            LOG(("ProcessRedirection failed [rv=%x]\n", rv));
            rv = ProcessNormal();
        }
        break;
    case 304:
        rv = ProcessNotModified();
        if (NS_FAILED(rv)) {
            LOG(("ProcessNotModified failed [rv=%x]\n", rv));
            rv = ProcessNormal();
        }
        break;
    case 401:
    case 407:
        rv = ProcessAuthentication(httpStatus);
        if (NS_FAILED(rv)) {
            LOG(("ProcessAuthentication failed [rv=%x]\n", rv));
            CheckForSuperfluousAuth();
            rv = ProcessNormal();
        }
        break;
    case 412: // Precondition failed
    case 416: // Invalid range
        if (mResuming) {
            Cancel(NS_ERROR_ENTITY_CHANGED);
            rv = CallOnStartRequest();
            break;
        }
        // fall through
    default:
        rv = ProcessNormal();
        break;
    }

    return rv;
}

Here is the call graph for this function:

nsresult nsHttpChannel::PromptForIdentity ( const char *  scheme,
const char *  host,
PRInt32  port,
PRBool  proxyAuth,
const char *  realm,
const char *  authType,
PRUint32  authFlags,
nsHttpAuthIdentity ident 
) [private]

Definition at line 2697 of file nsHttpChannel.cpp.

{
    LOG(("nsHttpChannel::PromptForIdentity [this=%x]\n", this));

    // XXX authType should be included in the prompt

    // XXX i18n: IDN not supported.

    nsCOMPtr<nsIAuthPrompt> authPrompt;
    GetAuthPrompt(mCallbacks, proxyAuth, getter_AddRefs(authPrompt));
    if (!authPrompt && mLoadGroup) {
        nsCOMPtr<nsIInterfaceRequestor> cbs;
        mLoadGroup->GetNotificationCallbacks(getter_AddRefs(cbs));
        GetAuthPrompt(cbs, proxyAuth, getter_AddRefs(authPrompt));
    }
    if (!authPrompt)
        return NS_ERROR_NO_INTERFACE;

    // XXX i18n: need to support non-ASCII realm strings (see bug 41489)
    NS_ConvertASCIItoUTF16 realmU(realm);

    //
    // construct the single signon key
    //
    // we always add the port to domain since it is used as the key for storing
    // in password maanger.  THE FORMAT OF THIS KEY IS SACROSANCT!!  do not
    // even think about changing the format of this key.
    //
    // XXX we need to prefix this with "scheme://" at some point.  however, that
    // has to be done very carefully and probably with some cooperation from the
    // password manager to ensure that passwords remembered under the old key
    // format are not lost.
    //
    nsAutoString key;
    CopyASCIItoUTF16(host, key); // XXX IDN?
    key.Append(PRUnichar(':'));
    key.AppendInt(port);
    key.AppendLiteral(" (");
    key.Append(realmU);
    key.Append(PRUnichar(')'));

    nsresult rv;

    // construct the message string
    nsCOMPtr<nsIStringBundleService> bundleSvc =
            do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
    if (NS_FAILED(rv)) return rv;

    nsCOMPtr<nsIStringBundle> bundle;
    rv = bundleSvc->CreateBundle(NECKO_MSGS_URL, getter_AddRefs(bundle));
    if (NS_FAILED(rv)) return rv;

    // figure out what message to display...
    nsAutoString displayHost;
    CopyASCIItoUTF16(host, displayHost); // XXX IDN?
    // If not proxy auth then add port only if it was originally specified
    // in the URI.
    PRInt32 uriPort = -1;
    if (proxyAuth || (NS_SUCCEEDED(mURI->GetPort(&uriPort)) && uriPort != -1)) {
        displayHost.Append(PRUnichar(':'));
        displayHost.AppendInt(port);
    }

    nsXPIDLString message;
    {
        NS_NAMED_LITERAL_STRING(proxyText, "EnterUserPasswordForProxy");
        NS_NAMED_LITERAL_STRING(originText, "EnterUserPasswordForRealm");

        const PRUnichar *text;
        if (proxyAuth) {
            text = proxyText.get();
        } else {
            text = originText.get();

            // prepend "scheme://"
            nsAutoString schemeU; 
            CopyASCIItoUTF16(scheme, schemeU);
            schemeU.AppendLiteral("://");
            displayHost.Insert(schemeU, 0);
        }

        const PRUnichar *strings[] = { realmU.get(), displayHost.get() };

        rv = bundle->FormatStringFromName(text, strings, 2,
                                          getter_Copies(message));
    }
    if (NS_FAILED(rv)) return rv;

    // prompt the user...
    PRBool retval = PR_FALSE;
    PRUnichar *user = nsnull, *pass = nsnull;
    rv = authPrompt->PromptUsernameAndPassword(nsnull, message.get(),
                                               key.get(),
                                               nsIAuthPrompt::SAVE_PASSWORD_PERMANENTLY,
                                               &user, &pass, &retval);
    if (NS_FAILED(rv)) return rv;

    // remember that we successfully showed the user an auth dialog
    if (!proxyAuth)
        mSuppressDefensiveAuth = PR_TRUE;

    if (!retval || !user || !pass)
        rv = NS_ERROR_ABORT;
    else
        SetIdent(ident, authFlags, user, pass);
  
    if (user) nsMemory::Free(user);
    if (pass) nsMemory::Free(pass);
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 934 of file nsHttpChannel.cpp.

{
    nsresult rv;
    nsCOMPtr<nsIStringBundleService> bundleService =
            do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
    if (NS_FAILED(rv)) return rv;

    nsCOMPtr<nsIStringBundle> stringBundle;
    rv = bundleService->CreateBundle(NECKO_MSGS_URL, getter_AddRefs(stringBundle));
    if (NS_FAILED(rv)) return rv;

    nsXPIDLString messageString;
    rv = stringBundle->GetStringFromName(NS_LITERAL_STRING("RepostFormData").get(), getter_Copies(messageString));
    // GetStringFromName can return NS_OK and NULL messageString.
    if (NS_SUCCEEDED(rv) && messageString) {
        PRBool repost = PR_FALSE;

        nsCOMPtr<nsIPrompt> prompt;
        GetCallback(prompt);
        if (!prompt)
            return NS_ERROR_NO_INTERFACE;

        prompt->Confirm(nsnull, messageString, &repost);
        if (!repost)
            return NS_ERROR_FAILURE;
    }

    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 965 of file nsHttpChannel.cpp.

{
    LOG(("nsHttpChannel::ProxyFailover [this=%x]\n", this));

    nsresult rv;

    nsCOMPtr<nsIProtocolProxyService> pps =
            do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID, &rv);
    if (NS_FAILED(rv))
        return rv;

    nsCOMPtr<nsIProxyInfo> pi;
    rv = pps->GetFailoverForProxy(mConnectionInfo->ProxyInfo(), mURI, mStatus,
                                  getter_AddRefs(pi));
    if (NS_FAILED(rv))
        return rv;

    return ReplaceWithProxy(pi);
}

Here is the call graph for this function:

Definition at line 1645 of file nsHttpChannel.cpp.

{
    nsresult rv;

    NS_ENSURE_TRUE(mCacheEntry, NS_ERROR_FAILURE);
    NS_ENSURE_TRUE(mCachedContentIsValid, NS_ERROR_FAILURE);

    LOG(("nsHttpChannel::ReadFromCache [this=%x] "
         "Using cached copy of: %s\n", this, mSpec.get()));

    if (mCachedResponseHead) {
        NS_ASSERTION(!mResponseHead, "memory leak");
        mResponseHead = mCachedResponseHead;
        mCachedResponseHead = 0;
    }

    // if we don't already have security info, try to get it from the cache 
    // entry. there are two cases to consider here: 1) we are just reading
    // from the cache, or 2) this may be due to a 304 not modified response,
    // in which case we could have security info from a socket transport.
    if (!mSecurityInfo)
        mCacheEntry->GetSecurityInfo(getter_AddRefs(mSecurityInfo));

    if ((mCacheAccess & nsICache::ACCESS_WRITE) && !mCachedContentIsPartial) {
        // We have write access to the cache, but we don't need to go to the
        // server to validate at this time, so just mark the cache entry as
        // valid in order to allow others access to this cache entry.
        mCacheEntry->MarkValid();
    }

    // if this is a cached redirect, we must process the redirect asynchronously
    // since AsyncOpen may not have returned yet.  Make sure there is a Location
    // header, otherwise we'll have to treat this like a normal 200 response.
    if (mResponseHead && (mResponseHead->Status() / 100 == 3) 
                      && (mResponseHead->PeekHeader(nsHttp::Location)))
        return AsyncCall(&nsHttpChannel::HandleAsyncRedirect);

    // have we been configured to skip reading from the cache?
    if ((mLoadFlags & LOAD_ONLY_IF_MODIFIED) && !mCachedContentIsPartial) {
        LOG(("skipping read from cache based on LOAD_ONLY_IF_MODIFIED load flag\n"));
        return AsyncCall(&nsHttpChannel::HandleAsyncNotModified);
    }

    // open input stream for reading...
    nsCOMPtr<nsIInputStream> stream;
    rv = mCacheEntry->OpenInputStream(0, getter_AddRefs(stream));
    if (NS_FAILED(rv)) return rv;

    rv = nsInputStreamPump::Create(getter_AddRefs(mCachePump),
                                   stream, nsInt64(-1), nsInt64(-1), 0, 0,
                                   PR_TRUE);
    if (NS_FAILED(rv)) return rv;

    return mCachePump->AsyncRead(this, mListenerContext);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 986 of file nsHttpChannel.cpp.

{
    nsresult rv;

    nsCOMPtr<nsIChannel> newChannel;
    rv = gHttpHandler->NewProxiedChannel(mURI, pi, getter_AddRefs(newChannel));
    if (NS_FAILED(rv))
        return rv;

    rv = SetupReplacementChannel(mURI, newChannel, PR_TRUE);
    if (NS_FAILED(rv))
        return rv;

    // Inform consumers about this fake redirect
    PRUint32 flags = nsIChannelEventSink::REDIRECT_INTERNAL;
    rv = gHttpHandler->OnChannelRedirect(this, newChannel, flags);
    if (NS_FAILED(rv))
        return rv;

    // open new channel
    rv = newChannel->AsyncOpen(mListener, mListenerContext);
    if (NS_FAILED(rv))
        return rv;

    mStatus = NS_BINDING_REDIRECTED;
    mListener = nsnull;
    mListenerContext = nsnull;
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 299 of file nsHttpChannel.cpp.

{
    // Is our consumer issuing a conditional request?
    return mRequestHead.PeekHeader(nsHttp::If_Modified_Since) ||
           mRequestHead.PeekHeader(nsHttp::If_None_Match) ||
           mRequestHead.PeekHeader(nsHttp::If_Unmodified_Since) ||
           mRequestHead.PeekHeader(nsHttp::If_Match) ||
           mRequestHead.PeekHeader(nsHttp::If_Range);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1017 of file nsHttpChannel.cpp.

{
    LOG(("nsHttpChannel::ResolveProxy [this=%x]\n", this));

    nsresult rv;

    nsCOMPtr<nsIProtocolProxyService> pps =
            do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID, &rv);
    if (NS_FAILED(rv))
        return rv;

    return pps->AsyncResolve(mURI, 0, this, getter_AddRefs(mProxyRequest));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1032 of file nsHttpChannel.cpp.

{
    PRBool result = PR_FALSE;
    nsCAutoString buf, metaKey;
    mCachedResponseHead->GetHeader(nsHttp::Vary, buf);
    if (!buf.IsEmpty()) {
        NS_NAMED_LITERAL_CSTRING(prefix, "request-");

        // enumerate the elements of the Vary header...
        char *val = buf.BeginWriting(); // going to munge buf
        char *token = nsCRT::strtok(val, NS_HTTP_HEADER_SEPS, &val);
        while (token) {
            //
            // if "*", then assume response would vary.  technically speaking,
            // "Vary: header, *" is not permitted, but we allow it anyways.
            //
            // if the response depends on the value of the "Cookie" header, then
            // bail since we do not store cookies in the cache.  this is done
            // for the following reasons:
            //
            //   1- cookies can be very large in size
            //
            //   2- cookies may contain sensitive information.  (for parity with
            //      out policy of not storing Set-cookie headers in the cache
            //      meta data, we likewise do not want to store cookie headers
            //      here.)
            //
            // this implementation is obviously not fully standards compliant, but
            // it is perhaps most prudent given the above issues.
            //
            if ((*token == '*') || (PL_strcasecmp(token, "cookie") == 0)) {
                result = PR_TRUE;
                break;
            }
            else {
                // build cache meta data key...
                metaKey = prefix + nsDependentCString(token);

                // check the last value of the given request header to see if it has
                // since changed.  if so, then indeed the cached response is invalid.
                nsXPIDLCString lastVal;
                mCacheEntry->GetMetaDataElement(metaKey.get(), getter_Copies(lastVal));
                if (lastVal) {
                    nsHttpAtom atom = nsHttp::ResolveAtom(token);
                    const char *newVal = mRequestHead.PeekHeader(atom);
                    if (newVal && (strcmp(newVal, lastVal) != 0)) {
                        result = PR_TRUE; // yes, response would vary
                        break;
                    }
                }
                
                // next token...
                token = nsCRT::strtok(val, NS_HTTP_HEADER_SEPS, &val);
            }
        }
    }
    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIRequest::resume ( ) [inherited]

Resumes the current request.

This may have the effect of re-opening any underlying transport and will resume the delivery of data to any open streams.

void nsIResumableChannel::resumeAt ( in unsigned long long  startPos,
in ACString  entityID 
) [inherited]

Prepare this channel for resuming.

The request will not start until asyncOpen or open is called. Calling resumeAt after open or asyncOpen has been called has undefined behaviour.

Parameters:
startPosthe starting offset, in bytes, to use to download
entityIDinformation about the file, to match before obtaining the file. Pass an empty string to use anything.

During OnStartRequest, this channel will have a status of NS_ERROR_NOT_RESUMABLE if the file cannot be resumed, eg because the server doesn't support this. This error may occur even if startPos is 0, so that the front end can warn the user. Similarly, the status of this channel during OnStartRequest may be NS_ERROR_ENTITY_CHANGED, which indicates that the entity has changed, as indicated by a changed entityID. In both of these cases, no OnDataAvailable will be called, and OnStopRequest will immediately follow with the same status code.

void nsHttpChannel::SetAuthorizationHeader ( nsHttpAuthCache authCache,
nsHttpAtom  header,
const char *  scheme,
const char *  host,
PRInt32  port,
const char *  path,
nsHttpAuthIdentity ident 
) [private]

Definition at line 2913 of file nsHttpChannel.cpp.

{
    nsHttpAuthEntry *entry = nsnull;
    nsresult rv;

    // set informations that depend on whether
    // we're authenticating against a proxy
    // or a webserver
    nsISupports **continuationState;

    if (header == nsHttp::Proxy_Authorization) {
        continuationState = &mProxyAuthContinuationState;
    } else {
        continuationState = &mAuthContinuationState;
    }

    rv = authCache->GetAuthEntryForPath(scheme, host, port, path, &entry);
    if (NS_SUCCEEDED(rv)) {
        // if we are trying to add a header for origin server auth and if the
        // URL contains an explicit username, then try the given username first.
        // we only want to do this, however, if we know the URL requires auth
        // based on the presence of an auth cache entry for this URL (which is
        // true since we are here).  but, if the username from the URL matches
        // the username from the cache, then we should prefer the password
        // stored in the cache since that is most likely to be valid.
        if (header == nsHttp::Authorization && entry->Domain()[0] == '\0') {
            GetIdentityFromURI(0, ident);
            // if the usernames match, then clear the ident so we will pick
            // up the one from the auth cache instead.
            if (nsCRT::strcmp(ident.User(), entry->User()) == 0)
                ident.Clear();
        }
        PRBool identFromURI;
        if (ident.IsEmpty()) {
            ident.Set(entry->Identity());
            identFromURI = PR_FALSE;
        }
        else
            identFromURI = PR_TRUE;

        nsXPIDLCString temp;
        const char *creds     = entry->Creds();
        const char *challenge = entry->Challenge();
        // we can only send a preemptive Authorization header if we have either
        // stored credentials or a stored challenge from which to derive
        // credentials.  if the identity is from the URI, then we cannot use
        // the stored credentials.
        if ((!creds[0] || identFromURI) && challenge[0]) {
            nsCOMPtr<nsIHttpAuthenticator> auth;
            nsCAutoString unused;
            rv = GetAuthenticator(challenge, unused, getter_AddRefs(auth));
            if (NS_SUCCEEDED(rv)) {
                PRBool proxyAuth = (header == nsHttp::Proxy_Authorization);
                rv = GenCredsAndSetEntry(auth, proxyAuth, scheme, host, port, path,
                                         entry->Realm(), challenge, ident,
                                         entry->mMetaData, getter_Copies(temp));
                if (NS_SUCCEEDED(rv))
                    creds = temp.get();

                // make sure the continuation state is null since we do not
                // support mixing preemptive and 'multirequest' authentication.
                NS_IF_RELEASE(*continuationState);
            }
        }
        if (creds[0]) {
            LOG(("   adding \"%s\" request header\n", header.get()));
            mRequestHead.SetHeader(header, nsDependentCString(creds));

            // suppress defensive auth prompting for this channel since we know
            // that we already prompted at least once this session.  we only do
            // this for non-proxy auth since the URL's userpass is not used for
            // proxy auth.
            if (header == nsHttp::Authorization)
                mSuppressDefensiveAuth = PR_TRUE;
        }
        else
            ident.Clear(); // don't remember the identity
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIHttpChannelInternal::setCookie ( in string  aCookieHeader) [inherited]

Helper method to set a cookie with a consumer-provided cookie header, but using the channel's other information (URI's, prompters, date headers etc).

Parameters:
aCookieHeaderThe cookie header to be parsed.
void nsIHttpChannel::setRequestHeader ( in ACString  aHeader,
in ACString  aValue,
in boolean  aMerge 
) [inherited]

Set the value of a particular request header.

This method allows, for example, the cookies module to add "Cookie" headers to the outgoing HTTP request.

This method may only be called before the channel is opened.

Parameters:
aHeaderThe case-insensitive name of the request header to set (e.g., "Cookie").
aValueThe request header value to set (e.g., "X=1").
aMergeIf true, the new header value will be merged with any existing values for the specified header. This flag is ignored if the specified header does not support merging (e.g., the "Content- Type" header can only have one value). The list of headers for which this flag is ignored is an implementation detail. If this flag is false, then the header value will be replaced with the contents of |aValue|.

If aValue is empty and aMerge is false, the header will be cleared.

Exceptions:
NS_ERROR_IN_PROGRESSif called after the channel has been opened.
void nsIHttpChannel::setResponseHeader ( in ACString  header,
in ACString  value,
in boolean  merge 
) [inherited]

Set the value of a particular response header.

This method allows, for example, the HTML content sink to inform the HTTP channel about HTTP-EQUIV headers found in HTML <META> tags.

Parameters:
aHeaderThe case-insensitive name of the response header to set (e.g., "Cache-control").
aValueThe response header value to set (e.g., "no-cache").
aMergeIf true, the new header value will be merged with any existing values for the specified header. This flag is ignored if the specified header does not support merging (e.g., the "Content- Type" header can only have one value). The list of headers for which this flag is ignored is an implementation detail. If this flag is false, then the header value will be replaced with the contents of |aValue|.

If aValue is empty and aMerge is false, the header will be cleared.

Exceptions:
NS_ERROR_NOT_AVAILABLEif called before the response has been received (before onStartRequest).
NS_ERROR_ILLEGAL_VALUEif changing the value of this response header is not allowed.

Definition at line 1096 of file nsHttpChannel.cpp.

{
    // cached content has been found to be partial, add necessary request
    // headers to complete cache entry.

    // use strongest validator available...
    const char *val = mCachedResponseHead->PeekHeader(nsHttp::ETag);
    if (!val)
        val = mCachedResponseHead->PeekHeader(nsHttp::Last_Modified);
    if (!val) {
        // if we hit this code it means mCachedResponseHead->IsResumable() is
        // either broken or not being called.
        NS_NOTREACHED("no cache validator");
        return NS_ERROR_FAILURE;
    }

    char buf[32];
    PR_snprintf(buf, sizeof(buf), "bytes=%u-", partialLen);

    mRequestHead.SetHeader(nsHttp::Range, nsDependentCString(buf));
    mRequestHead.SetHeader(nsHttp::If_Range, nsDependentCString(val));

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIUploadChannel::setUploadStream ( in nsIInputStream  aStream,
in ACString  aContentType,
in long  aContentLength 
) [inherited]

Sets a stream to be uploaded by this channel.

Most implementations of this interface require that the stream: (1) implement threadsafe addRef and release (2) implement nsIInputStream::readSegments (3) implement nsISeekableStream::seek

History here is that we need to support both streams that already have headers (e.g., Content-Type and Content-Length) information prepended to the stream (by plugins) as well as clients (composer, uploading application) that want to upload data streams without any knowledge of protocol specifications. For this reason, we have a special meaning for the aContentType parameter (see below).

Parameters:
aStreamThe stream to be uploaded by this channel.
aContentTypeIf aContentType is empty, the protocol will assume that no content headers are to be added to the uploaded stream and that any required headers are already encoded in the stream. In the case of HTTP, if this parameter is non-empty, then its value will replace any existing Content-Type header on the HTTP request. In the case of FTP and FILE, this parameter is ignored.
aContentLengthA value of -1 indicates that the length of the stream should be determined by calling the stream's |available| method.
nsresult nsHttpChannel::SetupReplacementChannel ( nsIURI newURI,
nsIChannel newChannel,
PRBool  preserveMethod 
) [private]

Definition at line 1900 of file nsHttpChannel.cpp.

{
    PRUint32 newLoadFlags = mLoadFlags | LOAD_REPLACE;
    // if the original channel was using SSL and this channel is not using
    // SSL, then no need to inhibit persistent caching.  however, if the
    // original channel was not using SSL and has INHIBIT_PERSISTENT_CACHING
    // set, then allow the flag to apply to the redirected channel as well.
    // since we force set INHIBIT_PERSISTENT_CACHING on all HTTPS channels,
    // we only need to check if the original channel was using SSL.
    if (mConnectionInfo->UsingSSL())
        newLoadFlags &= ~INHIBIT_PERSISTENT_CACHING;

    newChannel->SetOriginalURI(mOriginalURI);
    newChannel->SetLoadGroup(mLoadGroup); 
    newChannel->SetNotificationCallbacks(mCallbacks);
    newChannel->SetLoadFlags(newLoadFlags);

    nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(newChannel);
    if (!httpChannel)
        return NS_OK; // no other options to set

    if (preserveMethod) {
        nsCOMPtr<nsIUploadChannel> uploadChannel = do_QueryInterface(httpChannel);
        if (mUploadStream && uploadChannel) {
            // rewind upload stream
            nsCOMPtr<nsISeekableStream> seekable = do_QueryInterface(mUploadStream);
            if (seekable)
                seekable->Seek(nsISeekableStream::NS_SEEK_SET, 0);

            // replicate original call to SetUploadStream...
            if (mUploadStreamHasHeaders)
                uploadChannel->SetUploadStream(mUploadStream, EmptyCString(), -1);
            else {
                const char *ctype = mRequestHead.PeekHeader(nsHttp::Content_Type);
                const char *clen  = mRequestHead.PeekHeader(nsHttp::Content_Length);
                if (ctype && clen)
                    uploadChannel->SetUploadStream(mUploadStream,
                                                   nsDependentCString(ctype),
                                                   atoi(clen));
            }
        }
        // must happen after setting upload stream since SetUploadStream
        // may change the request method.
        httpChannel->SetRequestMethod(nsDependentCString(mRequestHead.Method()));
    }
    // convey the referrer if one was used for this channel to the next one
    if (mReferrer)
        httpChannel->SetReferrer(mReferrer);
    // convey the mAllowPipelining flag
    httpChannel->SetAllowPipelining(mAllowPipelining);
    // convey the new redirection limit
    httpChannel->SetRedirectionLimit(mRedirectionLimit - 1);

    nsCOMPtr<nsIHttpChannelInternal> httpInternal = do_QueryInterface(newChannel);
    if (httpInternal) {
        // update the DocumentURI indicator since we are being redirected.
        // if this was a top-level document channel, then the new channel
        // should have its mDocumentURI point to newURI; otherwise, we
        // just need to pass along our mDocumentURI to the new channel.
        if (newURI && (mURI == mDocumentURI))
            httpInternal->SetDocumentURI(newURI);
        else
            httpInternal->SetDocumentURI(mDocumentURI);
    } 
    
    // convey the mApplyConversion flag (bug 91862)
    nsCOMPtr<nsIEncodedChannel> encodedChannel = do_QueryInterface(httpChannel);
    if (encodedChannel)
        encodedChannel->SetApplyConversion(mApplyConversion);

    // transfer the resume information
    if (mResuming) {
        nsCOMPtr<nsIResumableChannel> resumableChannel(do_QueryInterface(newChannel));
        if (!resumableChannel) {
            NS_WARNING("Got asked to resume, but redirected to non-resumable channel!");
            return NS_ERROR_NOT_RESUMABLE;
        }
        resumableChannel->ResumeAt(mStartPos, mEntityID);
    }

    // transfer any properties
    nsCOMPtr<nsIWritablePropertyBag> bag(do_QueryInterface(newChannel));
    if (bag)
        mPropertyHash.EnumerateRead(CopyProperties, bag.get());

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 479 of file nsHttpChannel.cpp.

{
    LOG(("nsHttpChannel::SetupTransaction [this=%x]\n", this));

    NS_ENSURE_TRUE(!mTransaction, NS_ERROR_ALREADY_INITIALIZED);

    nsresult rv;

    if (mCaps & NS_HTTP_ALLOW_PIPELINING) {
        //
        // disable pipelining if:
        //   (1) pipelining has been explicitly disabled
        //   (2) request corresponds to a top-level document load (link click)
        //   (3) request method is non-idempotent
        //
        // XXX does the toplevel document check really belong here?  or, should
        //     we push it out entirely to necko consumers?
        //
        if (!mAllowPipelining || (mLoadFlags & LOAD_INITIAL_DOCUMENT_URI) ||
            !(mRequestHead.Method() == nsHttp::Get ||
              mRequestHead.Method() == nsHttp::Head ||
              mRequestHead.Method() == nsHttp::Propfind ||
              mRequestHead.Method() == nsHttp::Proppatch)) {
            LOG(("  pipelining disallowed\n"));
            mCaps &= ~NS_HTTP_ALLOW_PIPELINING;
        }
    }

    // use the URI path if not proxying (transparent proxying such as SSL proxy
    // does not count here). also, figure out what version we should be speaking.
    nsCAutoString buf, path;
    nsCString* requestURI;
    if (mConnectionInfo->UsingSSL() || !mConnectionInfo->UsingHttpProxy()) {
        rv = mURI->GetPath(path);
        if (NS_FAILED(rv)) return rv;
        // path may contain UTF-8 characters, so ensure that they're escaped.
        if (NS_EscapeURL(path.get(), path.Length(), esc_OnlyNonASCII, buf))
            requestURI = &buf;
        else
            requestURI = &path;
        mRequestHead.SetVersion(gHttpHandler->HttpVersion());
    }
    else {
        rv = mURI->GetUserPass(buf);
        if (NS_FAILED(rv)) return rv;
        if (!buf.IsEmpty() && ((strncmp(mSpec.get(), "http:", 5) == 0) ||
                                strncmp(mSpec.get(), "https:", 6) == 0)) {
            nsCOMPtr<nsIURI> tempURI;
            rv = mURI->Clone(getter_AddRefs(tempURI));
            if (NS_FAILED(rv)) return rv;
            rv = tempURI->SetUserPass(EmptyCString());
            if (NS_FAILED(rv)) return rv;
            rv = tempURI->GetAsciiSpec(path);
            if (NS_FAILED(rv)) return rv;
            requestURI = &path;
        }
        else
            requestURI = &mSpec;
        mRequestHead.SetVersion(gHttpHandler->ProxyHttpVersion());
    }

    // trim off the #ref portion if any...
    PRInt32 ref = requestURI->FindChar('#');
    if (ref != kNotFound)
        requestURI->SetLength(ref);

    mRequestHead.SetRequestURI(*requestURI);

    // set the request time for cache expiration calculations
    mRequestTime = NowInSeconds();

    // if doing a reload, force end-to-end
    if (mLoadFlags & LOAD_BYPASS_CACHE) {
        // We need to send 'Pragma:no-cache' to inhibit proxy caching even if
        // no proxy is configured since we might be talking with a transparent
        // proxy, i.e. one that operates at the network level.  See bug #14772.
        mRequestHead.SetHeader(nsHttp::Pragma, NS_LITERAL_CSTRING("no-cache"), PR_TRUE);
        // If we're configured to speak HTTP/1.1 then also send 'Cache-control:
        // no-cache'
        if (mRequestHead.Version() >= NS_HTTP_VERSION_1_1)
            mRequestHead.SetHeader(nsHttp::Cache_Control, NS_LITERAL_CSTRING("no-cache"), PR_TRUE);
    }
    else if ((mLoadFlags & VALIDATE_ALWAYS) && (mCacheAccess & nsICache::ACCESS_READ)) {
        // We need to send 'Cache-Control: max-age=0' to force each cache along
        // the path to the origin server to revalidate its own entry, if any,
        // with the next cache or server.  See bug #84847.
        //
        // If we're configured to speak HTTP/1.0 then just send 'Pragma: no-cache'
        if (mRequestHead.Version() >= NS_HTTP_VERSION_1_1)
            mRequestHead.SetHeader(nsHttp::Cache_Control, NS_LITERAL_CSTRING("max-age=0"), PR_TRUE);
        else
            mRequestHead.SetHeader(nsHttp::Pragma, NS_LITERAL_CSTRING("no-cache"), PR_TRUE);
    }

    if (mResuming) {
        char byteRange[32];
        PR_snprintf(byteRange, sizeof(byteRange), "bytes=%llu-", mStartPos);
        mRequestHead.SetHeader(nsHttp::Range, nsDependentCString(byteRange));

        if (!mEntityID.IsEmpty()) {
            // Also, we want an error if this resource changed in the meantime
            // Format of the entity id is: escaped_etag/size/lastmod
            nsCString::const_iterator start, end, slash;
            mEntityID.BeginReading(start);
            mEntityID.EndReading(end);
            mEntityID.BeginReading(slash);

            if (FindCharInReadable('/', slash, end)) {
                nsCAutoString ifMatch;
                mRequestHead.SetHeader(nsHttp::If_Match,
                        NS_UnescapeURL(Substring(start, slash), 0, ifMatch));

                ++slash; // Incrementing, so that searching for '/' won't find
                         // the same slash again
            }

            if (FindCharInReadable('/', slash, end)) {
                mRequestHead.SetHeader(nsHttp::If_Unmodified_Since,
                        Substring(++slash, end));
            }
        }
    }

    // create wrapper for this channel's notification callbacks
    nsCOMPtr<nsIInterfaceRequestor> callbacks;
    NS_NewNotificationCallbacksAggregation(mCallbacks, mLoadGroup,
                                           getter_AddRefs(callbacks));
    if (!callbacks)
        return NS_ERROR_OUT_OF_MEMORY;

    // create the transaction object
    mTransaction = new nsHttpTransaction();
    if (!mTransaction)
        return NS_ERROR_OUT_OF_MEMORY;
    NS_ADDREF(mTransaction);

    nsCOMPtr<nsIAsyncInputStream> responseStream;
    rv = mTransaction->Init(mCaps, mConnectionInfo, &mRequestHead,
                            mUploadStream, mUploadStreamHasHeaders,
                            mEventQ, callbacks, this,
                            getter_AddRefs(responseStream));
    if (NS_FAILED(rv)) return rv;

    rv = nsInputStreamPump::Create(getter_AddRefs(mTransactionPump),
                                   responseStream);
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1821 of file nsHttpChannel.cpp.

{
    // Not applicable to proxy authorization...
    const char *val = mRequestHead.PeekHeader(nsHttp::Authorization);
    if (val) {
        // eg. [Basic realm="wally world"]
        nsCAutoString buf(Substring(val, strchr(val, ' ')));
        return mCacheEntry->SetMetaDataElement("auth", buf.get());
    }
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIRequest::suspend ( ) [inherited]

Suspends the current request.

This may have the effect of closing any underlying transport (in order to free up resources), although any open streams remain logically opened and will continue delivering data when the transport is resumed.

NOTE: some implementations are unable to immediately suspend, and may continue to deliver events already posted to an event queue. In general, callers should be capable of handling events even after suspending a request.

Definition at line 1378 of file nsHttpChannel.cpp.

{
    NS_ENSURE_TRUE(mResponseHead, NS_ERROR_FAILURE);

    PRUint32 expirationTime = 0;
    if (!mResponseHead->MustValidate()) {
        PRUint32 freshnessLifetime = 0;
        nsresult rv;

        rv = mResponseHead->ComputeFreshnessLifetime(&freshnessLifetime);
        if (NS_FAILED(rv)) return rv;

        if (freshnessLifetime > 0) {
            PRUint32 now = NowInSeconds(), currentAge = 0;

            rv = mResponseHead->ComputeCurrentAge(now, mRequestTime, &currentAge); 
            if (NS_FAILED(rv)) return rv;

            LOG(("freshnessLifetime = %u, currentAge = %u\n",
                freshnessLifetime, currentAge));

            if (freshnessLifetime > currentAge) {
                PRUint32 timeRemaining = freshnessLifetime - currentAge;
                // be careful... now + timeRemaining may overflow
                if (now + timeRemaining < now)
                    expirationTime = PRUint32(-1);
                else
                    expirationTime = now + timeRemaining;
            }
            else
                expirationTime = now;
        }
    }
    return mCacheEntry->SetExpirationTime(expirationTime);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Call this method to visit all request headers.

Calling setRequestHeader while visiting request headers has undefined behavior. Don't do it!

Parameters:
aVisitorthe header visitor instance.

Call this method to visit all response headers.

Calling setResponseHeader while visiting response headers has undefined behavior. Don't do it!

Parameters:
aVisitorthe header visitor instance.
Exceptions:
NS_ERROR_NOT_AVAILABLEif called before the response has been received (before onStartRequest).

Member Data Documentation

This attribute is a hint to the channel to indicate whether or not the underlying HTTP transaction should be allowed to be pipelined with other transactions.

This should be set to FALSE, for example, if the application knows that the corresponding document is likely to be very large.

This attribute is true by default, though other factors may prevent pipelining.

This attribute may only be set before the channel is opened.

Exceptions:
NS_ERROR_FAILUREif set after the channel has been opened.

Definition at line 160 of file nsIHttpChannel.idl.

This attribute controls whether or not content conversion should be done per the Content-Encoding response header.

applyConversion can only be set before or during OnStartRequest. Calling this during OnDataAvailable is an error.

TRUE by default.

Definition at line 75 of file nsIEncodedChannel.idl.

Specifies whether or not the data should be cached to a file.

This may fail if the disk cache is not present. The value of this attribute is usually only settable during the processing of a channel's OnStartRequest. The default value of this attribute depends on the particular implementation of nsICachingChannel.

Definition at line 98 of file nsICachingChannel.idl.

Get the "file" where the cached data can be found.

This is valid for as long as a reference to the cache token is held. This may return an error if cacheAsFile is false.

Definition at line 105 of file nsICachingChannel.idl.

attribute nsISupports nsICachingChannel::cacheKey [inherited]

Set/get the cache key...

uniquely identifies the data in the cache for this channel. Holding a reference to this key does NOT prevent the cached data from being removed.

A cache key retrieved from a particular instance of nsICachingChannel could be set on another instance of nsICachingChannel provided the underlying implementations are compatible and provided the new channel instance was created with the same URI. The implementation of nsICachingChannel would be expected to use the cache entry identified by the cache token. Depending on the value of nsIRequest::loadFlags, the cache entry may be validated, overwritten, or simply read.

The cache key may be NULL indicating that the URI of the channel is sufficient to locate the same cache entry. Setting a NULL cache key is likewise valid.

Definition at line 89 of file nsICachingChannel.idl.

attribute nsISupports nsICachingChannel::cacheToken [inherited]

Set/get the cache token...

uniquely identifies the data in the cache. Holding a reference to this token prevents the cached data from being removed.

A cache token retrieved from a particular instance of nsICachingChannel could be set on another instance of nsICachingChannel provided the underlying implementations are compatible. The implementation of nsICachingChannel would be expected to only read from the cache entry identified by the cache token and not try to validate it.

The cache token can be QI'd to a nsICacheEntryInfo if more detail about the cache entry is needed (e.g., expiration time).

Definition at line 70 of file nsICachingChannel.idl.

attribute ACString nsIChannel::contentCharset [inherited]

The character set of the channel's content if available and if applicable.

This attribute only applies to textual data.

The value of the contentCharset attribute is a mixedcase string.

Definition at line 148 of file nsIChannel.idl.

This attribute holds the MIME types corresponding to the content encodings on the channel.

The enumerator returns nsISupportsCString objects. The first one corresponds to the outermost encoding on the channel and then we work our way inward. "identity" is skipped and not represented on the list. Unknown encodings make the enumeration stop. If you want the actual Content-Encoding value, use getResponseHeader("Content-Encoding").

When there is no Content-Encoding header, this property is null.

Modifying the Content-Encoding header on the channel will cause this enumerator to have undefined behavior. Don't do it.

Also note that contentEncodings only exist during or after OnStartRequest. Calling contentEncodings before OnStartRequest is an error.

Definition at line 65 of file nsIEncodedChannel.idl.

The length of the data associated with the channel if available.

A value of -1 indicates that the content length is unknown.

Callers should prefer getting the "content-length" property as 64-bit value by QIing the channel to nsIPropertyBag2, if that interface is exposed by the channel.

Definition at line 158 of file nsIChannel.idl.

attribute ACString nsIChannel::contentType [inherited]

The MIME type of the channel's content if available.

NOTE: the content type can often be wrongly specified (e.g., wrong file extension, wrong MIME type, wrong document type stored on a server, etc.), and the caller most likely wants to verify with the actual data.

Setting contentType before the channel has been opened provides a hint to the channel as to what the MIME type is. The channel may ignore this hint in deciding on the actual MIME type that it will report.

Setting contentType after onStartRequest has been fired or after open() is called will override the type determined by the channel.

Setting contentType between the time that asyncOpen() is called and the time when onStartRequest is fired has undefined behavior at this time.

The value of the contentType attribute is a lowercase string. A value assigned to this attribute will be parsed and normalized as follows: 1- any parameters (delimited with a ';') will be stripped. 2- if a charset parameter is given, then its value will replace the the contentCharset attribute of the channel. 3- the stripped contentType will be lowercased. Any implementation of nsIChannel must follow these rules.

Definition at line 140 of file nsIChannel.idl.

An http channel can own a reference to the document URI.

Definition at line 54 of file nsIHttpChannelInternal.idl.

readonly attribute ACString nsIResumableChannel::entityID [inherited]

The entity id for this URI.

Available after OnStartRequest.

Exceptions:
NS_ERROR_NOT_RESUMABLEif this load is not resumable.

Definition at line 69 of file nsIResumableChannel.idl.

const unsigned long nsIRequest::INHIBIT_CACHING = 1 << 7 [inherited]

This flag prevents caching of any kind.

It does not, however, prevent cached content from being used to satisfy this request.

Definition at line 153 of file nsIRequest.idl.

const unsigned long nsIRequest::INHIBIT_PERSISTENT_CACHING = 1 << 8 [inherited]

This flag prevents caching on disk (or other persistent media), which may be needed to preserve privacy.

For HTTPS, this flag is set auto- matically.

Definition at line 160 of file nsIRequest.idl.

const unsigned long nsIRequest::LOAD_BACKGROUND = 1 << 0 [inherited]

Don't deliver status notifications to the nsIProgressEventSink, or keep this load from completing the nsILoadGroup it may belong to.

Definition at line 143 of file nsIRequest.idl.

const unsigned long nsIRequest::LOAD_BYPASS_CACHE = 1 << 9 [inherited]

Force an end-to-end download of content data from the origin server.

This flag is used for a shift-reload.

Definition at line 172 of file nsIRequest.idl.

const unsigned long nsICachingChannel::LOAD_BYPASS_LOCAL_CACHE = 1 << 28 [inherited]

This load flag causes the local cache to be skipped when fetching a request.

Unlike LOAD_BYPASS_CACHE, it does not force an end-to-end load (i.e., it does not affect proxy caches).

Definition at line 123 of file nsICachingChannel.idl.

This load flag causes the local cache to be skipped if the request would otherwise block waiting to access the cache.

Definition at line 129 of file nsICachingChannel.idl.

const unsigned long nsIChannel::LOAD_CALL_CONTENT_SNIFFERS = 1 << 21 [inherited]

If this flag is set, the channel should call the content sniffers as described in nsNetCID.h about NS_CONTENT_SNIFFER_CATEGORY.

Note: Channels may ignore this flag; however, new channel implementations should only do so with good reason.

Definition at line 227 of file nsIChannel.idl.

const unsigned long nsIChannel::LOAD_DOCUMENT_URI = 1 << 16 [inherited]

Set (e.g., by the docshell) to indicate whether or not the channel corresponds to a document URI.

Definition at line 193 of file nsIChannel.idl.

const unsigned long nsIRequest::LOAD_FROM_CACHE = 1 << 10 [inherited]

Load from the cache, bypassing protocol specific validation logic.

This flag is used when browsing via history. It is not recommended for normal browsing as it may likely violate reasonable assumptions made by the server and confuse users.

Definition at line 180 of file nsIRequest.idl.

const unsigned long nsIChannel::LOAD_INITIAL_DOCUMENT_URI = 1 << 19 [inherited]

Set (e.g., by the docshell) to indicate whether or not the channel corresponds to an initial document URI load (e.g., link click).

Definition at line 212 of file nsIChannel.idl.

const unsigned long nsIRequest::LOAD_NORMAL = 0 [inherited]

No special load flags:

Definition at line 137 of file nsIRequest.idl.

const unsigned long nsICachingChannel::LOAD_ONLY_FROM_CACHE = 1 << 30 [inherited]

This load flag inhibits fetching from the net if the data in the cache has been evicted.

An error of NS_ERROR_DOCUMENT_NOT_CACHED will be sent to the listener's onStopRequest in this case.

Definition at line 136 of file nsICachingChannel.idl.

const unsigned long nsICachingChannel::LOAD_ONLY_IF_MODIFIED = 1 << 31 [inherited]

This load flag controls what happens when a document would be loaded from the cache to satisfy a call to AsyncOpen.

If this attribute is set to TRUE, then the document will not be loaded from the cache. A stream listener can check nsICachingChannel::isFromCache to determine if the AsyncOpen will actually result in data being streamed.

If this flag has been set, and the request can be satisfied via the cache, then the OnDataAvailable events will be skipped. The listener will only see OnStartRequest followed by OnStopRequest.

Definition at line 149 of file nsICachingChannel.idl.

const unsigned long nsIChannel::LOAD_REPLACE = 1 << 18 [inherited]

This flag is set to indicate that onStopRequest may be followed by another onStartRequest/onStopRequest pair.

This flag is, for example, used by the multipart/replace stream converter.

Definition at line 206 of file nsIChannel.idl.

const unsigned long nsIChannel::LOAD_RETARGETED_DOCUMENT_URI = 1 << 17 [inherited]

If the end consumer for this load has been retargeted after discovering it's content, this flag will be set:

Definition at line 199 of file nsIChannel.idl.

const unsigned long nsIChannel::LOAD_TARGETED = 1 << 20 [inherited]

Set (e.g., by the URILoader) to indicate whether or not the end consumer for this load has been determined.

Definition at line 218 of file nsIChannel.idl.

The load flags of this request.

Bits 0-15 are reserved.

When added to a load group, this request's load flags are merged with the load flags of the load group.

Definition at line 128 of file nsIRequest.idl.

The load group of this request.

While pending, the request is a member of the load group. It is the responsibility of the request to implement this policy.

Definition at line 120 of file nsIRequest.idl.

Definition at line 275 of file nsHttpChannel.h.

Definition at line 274 of file nsHttpChannel.h.

nsISupports* nsHttpChannel::mAuthContinuationState [private]

Definition at line 260 of file nsHttpChannel.h.

Definition at line 282 of file nsHttpChannel.h.

Definition at line 261 of file nsHttpChannel.h.

Definition at line 253 of file nsHttpChannel.h.

Definition at line 277 of file nsHttpChannel.h.

Definition at line 276 of file nsHttpChannel.h.

Definition at line 252 of file nsHttpChannel.h.

Definition at line 250 of file nsHttpChannel.h.

Definition at line 251 of file nsHttpChannel.h.

Definition at line 222 of file nsHttpChannel.h.

Definition at line 279 of file nsHttpChannel.h.

Definition at line 242 of file nsHttpChannel.h.

Definition at line 235 of file nsHttpChannel.h.

Definition at line 246 of file nsHttpChannel.h.

Definition at line 245 of file nsHttpChannel.h.

Definition at line 217 of file nsHttpChannel.h.

Definition at line 266 of file nsHttpChannel.h.

Definition at line 227 of file nsHttpChannel.h.

Definition at line 262 of file nsHttpChannel.h.

Definition at line 273 of file nsHttpChannel.h.

Definition at line 218 of file nsHttpChannel.h.

nsCOMPtr<nsISupports> nsHttpChannel::mListenerContext [private]

Definition at line 219 of file nsHttpChannel.h.

Definition at line 239 of file nsHttpChannel.h.

Definition at line 220 of file nsHttpChannel.h.

Definition at line 241 of file nsHttpChannel.h.

Definition at line 285 of file nsHttpChannel.h.

Definition at line 215 of file nsHttpChannel.h.

nsCOMPtr<nsISupports> nsHttpChannel::mOwner [private]

Definition at line 221 of file nsHttpChannel.h.

Definition at line 254 of file nsHttpChannel.h.

Definition at line 243 of file nsHttpChannel.h.

Definition at line 223 of file nsHttpChannel.h.

Definition at line 258 of file nsHttpChannel.h.

Definition at line 259 of file nsHttpChannel.h.

Definition at line 263 of file nsHttpChannel.h.

Definition at line 228 of file nsHttpChannel.h.

Definition at line 270 of file nsHttpChannel.h.

Definition at line 225 of file nsHttpChannel.h.

Definition at line 230 of file nsHttpChannel.h.

Definition at line 255 of file nsHttpChannel.h.

Definition at line 231 of file nsHttpChannel.h.

Definition at line 278 of file nsHttpChannel.h.

Definition at line 284 of file nsHttpChannel.h.

nsCOMPtr<nsISupports> nsHttpChannel::mSecurityInfo [private]

Definition at line 226 of file nsHttpChannel.h.

Definition at line 237 of file nsHttpChannel.h.

Definition at line 267 of file nsHttpChannel.h.

Definition at line 240 of file nsHttpChannel.h.

Definition at line 283 of file nsHttpChannel.h.

Definition at line 234 of file nsHttpChannel.h.

Definition at line 233 of file nsHttpChannel.h.

Definition at line 280 of file nsHttpChannel.h.

Definition at line 224 of file nsHttpChannel.h.

Definition at line 281 of file nsHttpChannel.h.

Definition at line 216 of file nsHttpChannel.h.

Definition at line 247 of file nsHttpChannel.h.

readonly attribute AUTF8String nsIRequest::name [inherited]

The name of the request.

Often this is the URI of the request.

Definition at line 55 of file nsIRequest.idl.

The notification callbacks for the channel.

This is set by clients, who wish to provide a means to receive progress, status and protocol-specific notifications. If this value is NULL, the channel implementation may use the notification callbacks from its load group. The channel may also query the notification callbacks from its load group if its notification callbacks do not supply the requested interface.

Interfaces commonly requested include: nsIProgressEventSink, nsIPrompt, and nsIAuthPrompt.

When the channel is done, it must not continue holding references to this object.

NOTE: A channel implementation should take care when "caching" an interface pointer queried from its notification callbacks. If the notification callbacks are changed, then a cached interface pointer may become invalid and may therefore need to be re-queried.

Definition at line 108 of file nsIChannel.idl.

The original URI used to construct the channel.

This is used in the case of a redirect or URI "resolution" (e.g. resolving a resource: URI to a file: URI) so that the original pre-redirect URI can still be obtained.

NOTE: this is distinctly different from the http Referer (referring URI), which is typically the page that contained the original URI (accessible from nsIHttpChannel).

Definition at line 71 of file nsIChannel.idl.

attribute nsISupports nsIChannel::owner [inherited]

The owner, corresponding to the entity that is responsible for this channel.

Used by the security manager to grant or deny privileges to mobile code loaded from this channel.

NOTE: this is a strong reference to the owner, so if the owner is also holding a strong reference to the channel, care must be taken to explicitly drop its reference to the channel.

Definition at line 87 of file nsIChannel.idl.

This attribute may be modified to change the priority of this object.

The implementation of this interface is free to truncate a given priority value to whatever limits are appropriate. Typically, this attribute is initialized to PRIORITY_NORMAL, but implementations may choose to assign a different initial value.

Definition at line 69 of file nsISupportsPriority.idl.

Definition at line 57 of file nsISupportsPriority.idl.

Typical priority values.

Definition at line 56 of file nsISupportsPriority.idl.

Definition at line 59 of file nsISupportsPriority.idl.

Definition at line 60 of file nsISupportsPriority.idl.

Definition at line 58 of file nsISupportsPriority.idl.

Get the proxy info in use by the channel.

Definition at line 79 of file nsIHttpChannelInternal.idl.

This attribute specifies the number of redirects this channel is allowed to make.

If zero, the channel will fail to redirect and will generate a NS_ERROR_REDIRECT_LOOP failure status.

NOTE: An HTTP redirect results in a new channel being created. If the new channel supports nsIHttpChannel, then it will be assigned a value to its |redirectionLimit| attribute one less than the value of the redirected channel's |redirectionLimit| attribute. The initial value for this attribute may be a configurable preference (depending on the implementation).

Definition at line 174 of file nsIHttpChannel.idl.

Get/set the HTTP referrer URI.

This is the address (URI) of the resource from which this channel's URI was obtained (see RFC2616 section 14.36).

This attribute may only be set before the channel is opened.

NOTE: The channel may silently refuse to set the Referer header if the URI does not pass certain security checks (e.g., a "https://" URL will never be sent as the referrer for a plaintext HTTP request). The implementation is not required to throw an exception when the referrer URI is rejected.

Exceptions:
NS_ERROR_IN_PROGRESSif set after the channel has been opened.

Definition at line 92 of file nsIHttpChannel.idl.

Set/get the HTTP request method (default is "GET").

Setter is case insensitive; getter returns an uppercase string.

This attribute may only be set before the channel is opened.

NOTE: The data for a "POST" or "PUT" request can be configured via nsIUploadChannel; however, after setting the upload data, it may be necessary to set the request method explicitly. The documentation for nsIUploadChannel has further details.

Exceptions:
NS_ERROR_IN_PROGRESSif set after the channel has been opened.

Definition at line 75 of file nsIHttpChannel.idl.

Returns true if the HTTP response code indicates success.

The value of nsIRequest::status will be NS_OK even when processing a 404 response because a 404 response may include a message body that (in some cases) should be shown to the user.

Use this attribute to distinguish server error pages from normal pages, instead of comparing the response status manually against the set of valid response codes, if that is required by your application.

Exceptions:
NS_ERROR_NOT_AVAILABLEif called before the response has been received (before onStartRequest).

Definition at line 216 of file nsIHttpChannel.idl.

readonly attribute unsigned long nsIHttpChannel::responseStatus [inherited]

Get the HTTP response code (e.g., 200).

Exceptions:
NS_ERROR_NOT_AVAILABLEif called before the response has been received (before onStartRequest).

Definition at line 189 of file nsIHttpChannel.idl.

readonly attribute ACString nsIHttpChannel::responseStatusText [inherited]

Get the HTTP response status text (e.g., "OK").

NOTE: This returns the raw (possibly 8-bit) text from the server. There are no assumptions made about the charset of the returned text. You have been warned!

Exceptions:
NS_ERROR_NOT_AVAILABLEif called before the response has been received (before onStartRequest).

Definition at line 201 of file nsIHttpChannel.idl.

readonly attribute nsISupports nsIChannel::securityInfo [inherited]

Transport-level security information (if any) corresponding to the channel.

Definition at line 113 of file nsIChannel.idl.

readonly attribute nsresult nsIRequest::status [inherited]

The error status associated with the request.

Definition at line 77 of file nsIRequest.idl.

Get the stream (to be) uploaded by this channel.

Definition at line 89 of file nsIUploadChannel.idl.

readonly attribute nsIURI nsIChannel::URI [inherited]

The URI corresponding to the channel.

Its value is immutable.

Definition at line 76 of file nsIChannel.idl.

const unsigned long nsIRequest::VALIDATE_ALWAYS = 1 << 11 [inherited]

The following flags control the frequency of cached content validation when neither LOAD_BYPASS_CACHE or LOAD_FROM_CACHE are set.

By default, cached content is automatically validated if necessary before reuse.

VALIDATE_ALWAYS forces validation of any cached content independent of its expiration time.

VALIDATE_NEVER disables validation of expired content.

VALIDATE_ONCE_PER_SESSION disables validation of expired content, provided it has already been validated (at least once) since the start of this session.

NOTE TO IMPLEMENTORS: These flags are intended for normal browsing, and they should therefore not apply to content that must be validated before each use. Consider, for example, a HTTP response with a "Cache-control: no-cache" header. According to RFC2616, this response must be validated before it can be taken from a cache. Breaking this requirement could result in incorrect and potentially undesirable side-effects.

Definition at line 204 of file nsIRequest.idl.

const unsigned long nsIRequest::VALIDATE_NEVER = 1 << 12 [inherited]

Definition at line 205 of file nsIRequest.idl.

const unsigned long nsIRequest::VALIDATE_ONCE_PER_SESSION = 1 << 13 [inherited]

Definition at line 206 of file nsIRequest.idl.


The documentation for this class was generated from the following files: