Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* vim:set et cin ts=4 sw=4 sts=4: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef nsHttpChannel_h__ |
michael@0 | 8 | #define nsHttpChannel_h__ |
michael@0 | 9 | |
michael@0 | 10 | #include "HttpBaseChannel.h" |
michael@0 | 11 | #include "nsTArray.h" |
michael@0 | 12 | #include "nsICachingChannel.h" |
michael@0 | 13 | #include "nsICacheEntry.h" |
michael@0 | 14 | #include "nsICacheEntryOpenCallback.h" |
michael@0 | 15 | #include "nsIDNSListener.h" |
michael@0 | 16 | #include "nsIApplicationCacheChannel.h" |
michael@0 | 17 | #include "nsIProtocolProxyCallback.h" |
michael@0 | 18 | #include "nsIHttpAuthenticableChannel.h" |
michael@0 | 19 | #include "nsIAsyncVerifyRedirectCallback.h" |
michael@0 | 20 | #include "nsIThreadRetargetableRequest.h" |
michael@0 | 21 | #include "nsIThreadRetargetableStreamListener.h" |
michael@0 | 22 | #include "nsWeakReference.h" |
michael@0 | 23 | #include "TimingStruct.h" |
michael@0 | 24 | #include "AutoClose.h" |
michael@0 | 25 | |
michael@0 | 26 | class nsIPrincipal; |
michael@0 | 27 | class nsDNSPrefetch; |
michael@0 | 28 | class nsICacheEntryDescriptor; |
michael@0 | 29 | class nsICancelable; |
michael@0 | 30 | class nsIHttpChannelAuthProvider; |
michael@0 | 31 | class nsInputStreamPump; |
michael@0 | 32 | class nsPerformance; |
michael@0 | 33 | |
michael@0 | 34 | namespace mozilla { namespace net { |
michael@0 | 35 | |
michael@0 | 36 | //----------------------------------------------------------------------------- |
michael@0 | 37 | // nsHttpChannel |
michael@0 | 38 | //----------------------------------------------------------------------------- |
michael@0 | 39 | |
michael@0 | 40 | class nsHttpChannel : public HttpBaseChannel |
michael@0 | 41 | , public HttpAsyncAborter<nsHttpChannel> |
michael@0 | 42 | , public nsIStreamListener |
michael@0 | 43 | , public nsICachingChannel |
michael@0 | 44 | , public nsICacheEntryOpenCallback |
michael@0 | 45 | , public nsITransportEventSink |
michael@0 | 46 | , public nsIProtocolProxyCallback |
michael@0 | 47 | , public nsIHttpAuthenticableChannel |
michael@0 | 48 | , public nsIApplicationCacheChannel |
michael@0 | 49 | , public nsIAsyncVerifyRedirectCallback |
michael@0 | 50 | , public nsIThreadRetargetableRequest |
michael@0 | 51 | , public nsIThreadRetargetableStreamListener |
michael@0 | 52 | , public nsIDNSListener |
michael@0 | 53 | , public nsSupportsWeakReference |
michael@0 | 54 | { |
michael@0 | 55 | public: |
michael@0 | 56 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 57 | NS_DECL_NSIREQUESTOBSERVER |
michael@0 | 58 | NS_DECL_NSISTREAMLISTENER |
michael@0 | 59 | NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER |
michael@0 | 60 | NS_DECL_NSICACHEINFOCHANNEL |
michael@0 | 61 | NS_DECL_NSICACHINGCHANNEL |
michael@0 | 62 | NS_DECL_NSICACHEENTRYOPENCALLBACK |
michael@0 | 63 | NS_DECL_NSITRANSPORTEVENTSINK |
michael@0 | 64 | NS_DECL_NSIPROTOCOLPROXYCALLBACK |
michael@0 | 65 | NS_DECL_NSIPROXIEDCHANNEL |
michael@0 | 66 | NS_DECL_NSIAPPLICATIONCACHECONTAINER |
michael@0 | 67 | NS_DECL_NSIAPPLICATIONCACHECHANNEL |
michael@0 | 68 | NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK |
michael@0 | 69 | NS_DECL_NSITHREADRETARGETABLEREQUEST |
michael@0 | 70 | NS_DECL_NSIDNSLISTENER |
michael@0 | 71 | |
michael@0 | 72 | // nsIHttpAuthenticableChannel. We can't use |
michael@0 | 73 | // NS_DECL_NSIHTTPAUTHENTICABLECHANNEL because it duplicates cancel() and |
michael@0 | 74 | // others. |
michael@0 | 75 | NS_IMETHOD GetIsSSL(bool *aIsSSL); |
michael@0 | 76 | NS_IMETHOD GetProxyMethodIsConnect(bool *aProxyMethodIsConnect); |
michael@0 | 77 | NS_IMETHOD GetServerResponseHeader(nsACString & aServerResponseHeader); |
michael@0 | 78 | NS_IMETHOD GetProxyChallenges(nsACString & aChallenges); |
michael@0 | 79 | NS_IMETHOD GetWWWChallenges(nsACString & aChallenges); |
michael@0 | 80 | NS_IMETHOD SetProxyCredentials(const nsACString & aCredentials); |
michael@0 | 81 | NS_IMETHOD SetWWWCredentials(const nsACString & aCredentials); |
michael@0 | 82 | NS_IMETHOD OnAuthAvailable(); |
michael@0 | 83 | NS_IMETHOD OnAuthCancelled(bool userCancel); |
michael@0 | 84 | // Functions we implement from nsIHttpAuthenticableChannel but are |
michael@0 | 85 | // declared in HttpBaseChannel must be implemented in this class. We |
michael@0 | 86 | // just call the HttpBaseChannel:: impls. |
michael@0 | 87 | NS_IMETHOD GetLoadFlags(nsLoadFlags *aLoadFlags); |
michael@0 | 88 | NS_IMETHOD GetURI(nsIURI **aURI); |
michael@0 | 89 | NS_IMETHOD GetNotificationCallbacks(nsIInterfaceRequestor **aCallbacks); |
michael@0 | 90 | NS_IMETHOD GetLoadGroup(nsILoadGroup **aLoadGroup); |
michael@0 | 91 | NS_IMETHOD GetRequestMethod(nsACString& aMethod); |
michael@0 | 92 | |
michael@0 | 93 | nsHttpChannel(); |
michael@0 | 94 | virtual ~nsHttpChannel(); |
michael@0 | 95 | |
michael@0 | 96 | virtual nsresult Init(nsIURI *aURI, uint32_t aCaps, nsProxyInfo *aProxyInfo, |
michael@0 | 97 | uint32_t aProxyResolveFlags, |
michael@0 | 98 | nsIURI *aProxyURI); |
michael@0 | 99 | |
michael@0 | 100 | // Methods HttpBaseChannel didn't implement for us or that we override. |
michael@0 | 101 | // |
michael@0 | 102 | // nsIRequest |
michael@0 | 103 | NS_IMETHOD Cancel(nsresult status); |
michael@0 | 104 | NS_IMETHOD Suspend(); |
michael@0 | 105 | NS_IMETHOD Resume(); |
michael@0 | 106 | NS_IMETHOD IsPending(bool *aIsPending); |
michael@0 | 107 | // nsIChannel |
michael@0 | 108 | NS_IMETHOD GetSecurityInfo(nsISupports **aSecurityInfo); |
michael@0 | 109 | NS_IMETHOD AsyncOpen(nsIStreamListener *listener, nsISupports *aContext); |
michael@0 | 110 | // nsIHttpChannelInternal |
michael@0 | 111 | NS_IMETHOD SetupFallbackChannel(const char *aFallbackKey); |
michael@0 | 112 | // nsISupportsPriority |
michael@0 | 113 | NS_IMETHOD SetPriority(int32_t value); |
michael@0 | 114 | // nsIResumableChannel |
michael@0 | 115 | NS_IMETHOD ResumeAt(uint64_t startPos, const nsACString& entityID); |
michael@0 | 116 | |
michael@0 | 117 | NS_IMETHOD SetNotificationCallbacks(nsIInterfaceRequestor *aCallbacks); |
michael@0 | 118 | NS_IMETHOD SetLoadGroup(nsILoadGroup *aLoadGroup); |
michael@0 | 119 | // nsITimedChannel |
michael@0 | 120 | NS_IMETHOD GetDomainLookupStart(mozilla::TimeStamp *aDomainLookupStart); |
michael@0 | 121 | NS_IMETHOD GetDomainLookupEnd(mozilla::TimeStamp *aDomainLookupEnd); |
michael@0 | 122 | NS_IMETHOD GetConnectStart(mozilla::TimeStamp *aConnectStart); |
michael@0 | 123 | NS_IMETHOD GetConnectEnd(mozilla::TimeStamp *aConnectEnd); |
michael@0 | 124 | NS_IMETHOD GetRequestStart(mozilla::TimeStamp *aRequestStart); |
michael@0 | 125 | NS_IMETHOD GetResponseStart(mozilla::TimeStamp *aResponseStart); |
michael@0 | 126 | NS_IMETHOD GetResponseEnd(mozilla::TimeStamp *aResponseEnd); |
michael@0 | 127 | |
michael@0 | 128 | public: /* internal necko use only */ |
michael@0 | 129 | |
michael@0 | 130 | void InternalSetUploadStream(nsIInputStream *uploadStream) |
michael@0 | 131 | { mUploadStream = uploadStream; } |
michael@0 | 132 | void SetUploadStreamHasHeaders(bool hasHeaders) |
michael@0 | 133 | { mUploadStreamHasHeaders = hasHeaders; } |
michael@0 | 134 | |
michael@0 | 135 | nsresult SetReferrerInternal(nsIURI *referrer) { |
michael@0 | 136 | nsAutoCString spec; |
michael@0 | 137 | nsresult rv = referrer->GetAsciiSpec(spec); |
michael@0 | 138 | if (NS_FAILED(rv)) return rv; |
michael@0 | 139 | mReferrer = referrer; |
michael@0 | 140 | mRequestHead.SetHeader(nsHttp::Referer, spec); |
michael@0 | 141 | return NS_OK; |
michael@0 | 142 | } |
michael@0 | 143 | |
michael@0 | 144 | // This allows cache entry to be marked as foreign even after channel itself |
michael@0 | 145 | // is gone. Needed for e10s (see HttpChannelParent::RecvDocumentChannelCleanup) |
michael@0 | 146 | class OfflineCacheEntryAsForeignMarker { |
michael@0 | 147 | nsCOMPtr<nsIApplicationCache> mApplicationCache; |
michael@0 | 148 | nsCOMPtr<nsIURI> mCacheURI; |
michael@0 | 149 | public: |
michael@0 | 150 | OfflineCacheEntryAsForeignMarker(nsIApplicationCache* appCache, |
michael@0 | 151 | nsIURI* aURI) |
michael@0 | 152 | : mApplicationCache(appCache) |
michael@0 | 153 | , mCacheURI(aURI) |
michael@0 | 154 | {} |
michael@0 | 155 | |
michael@0 | 156 | nsresult MarkAsForeign(); |
michael@0 | 157 | }; |
michael@0 | 158 | |
michael@0 | 159 | OfflineCacheEntryAsForeignMarker* GetOfflineCacheEntryAsForeignMarker(); |
michael@0 | 160 | |
michael@0 | 161 | // Helper to keep cache callbacks wait flags consistent |
michael@0 | 162 | class AutoCacheWaitFlags |
michael@0 | 163 | { |
michael@0 | 164 | public: |
michael@0 | 165 | AutoCacheWaitFlags(nsHttpChannel* channel) |
michael@0 | 166 | : mChannel(channel) |
michael@0 | 167 | , mKeep(0) |
michael@0 | 168 | { |
michael@0 | 169 | // Flags must be set before entering any AsyncOpenCacheEntry call. |
michael@0 | 170 | mChannel->mCacheEntriesToWaitFor = |
michael@0 | 171 | nsHttpChannel::WAIT_FOR_CACHE_ENTRY | |
michael@0 | 172 | nsHttpChannel::WAIT_FOR_OFFLINE_CACHE_ENTRY; |
michael@0 | 173 | } |
michael@0 | 174 | |
michael@0 | 175 | void Keep(uint32_t flags) |
michael@0 | 176 | { |
michael@0 | 177 | // Called after successful call to appropriate AsyncOpenCacheEntry call. |
michael@0 | 178 | mKeep |= flags; |
michael@0 | 179 | } |
michael@0 | 180 | |
michael@0 | 181 | ~AutoCacheWaitFlags() |
michael@0 | 182 | { |
michael@0 | 183 | // Keep only flags those are left to be wait for. |
michael@0 | 184 | mChannel->mCacheEntriesToWaitFor &= mKeep; |
michael@0 | 185 | } |
michael@0 | 186 | |
michael@0 | 187 | private: |
michael@0 | 188 | nsHttpChannel* mChannel; |
michael@0 | 189 | uint32_t mKeep : 2; |
michael@0 | 190 | }; |
michael@0 | 191 | |
michael@0 | 192 | void ForcePending(bool aForcePending); |
michael@0 | 193 | |
michael@0 | 194 | private: |
michael@0 | 195 | typedef nsresult (nsHttpChannel::*nsContinueRedirectionFunc)(nsresult result); |
michael@0 | 196 | |
michael@0 | 197 | bool RequestIsConditional(); |
michael@0 | 198 | nsresult BeginConnect(); |
michael@0 | 199 | nsresult Connect(); |
michael@0 | 200 | nsresult ContinueConnect(); |
michael@0 | 201 | void SpeculativeConnect(); |
michael@0 | 202 | nsresult SetupTransaction(); |
michael@0 | 203 | void SetupTransactionLoadGroupInfo(); |
michael@0 | 204 | nsresult CallOnStartRequest(); |
michael@0 | 205 | nsresult ProcessResponse(); |
michael@0 | 206 | nsresult ContinueProcessResponse(nsresult); |
michael@0 | 207 | nsresult ProcessNormal(); |
michael@0 | 208 | nsresult ContinueProcessNormal(nsresult); |
michael@0 | 209 | nsresult ProcessNotModified(); |
michael@0 | 210 | nsresult AsyncProcessRedirection(uint32_t httpStatus); |
michael@0 | 211 | nsresult ContinueProcessRedirection(nsresult); |
michael@0 | 212 | nsresult ContinueProcessRedirectionAfterFallback(nsresult); |
michael@0 | 213 | nsresult ProcessFailedProxyConnect(uint32_t httpStatus); |
michael@0 | 214 | nsresult ProcessFallback(bool *waitingForRedirectCallback); |
michael@0 | 215 | nsresult ContinueProcessFallback(nsresult); |
michael@0 | 216 | void HandleAsyncAbort(); |
michael@0 | 217 | nsresult EnsureAssocReq(); |
michael@0 | 218 | void ProcessSSLInformation(); |
michael@0 | 219 | bool IsHTTPS(); |
michael@0 | 220 | void RetrieveSSLOptions(); |
michael@0 | 221 | |
michael@0 | 222 | nsresult ContinueOnStartRequest1(nsresult); |
michael@0 | 223 | nsresult ContinueOnStartRequest2(nsresult); |
michael@0 | 224 | nsresult ContinueOnStartRequest3(nsresult); |
michael@0 | 225 | |
michael@0 | 226 | // redirection specific methods |
michael@0 | 227 | void HandleAsyncRedirect(); |
michael@0 | 228 | void HandleAsyncAPIRedirect(); |
michael@0 | 229 | nsresult ContinueHandleAsyncRedirect(nsresult); |
michael@0 | 230 | void HandleAsyncNotModified(); |
michael@0 | 231 | void HandleAsyncFallback(); |
michael@0 | 232 | nsresult ContinueHandleAsyncFallback(nsresult); |
michael@0 | 233 | nsresult PromptTempRedirect(); |
michael@0 | 234 | nsresult StartRedirectChannelToURI(nsIURI *, uint32_t); |
michael@0 | 235 | virtual nsresult SetupReplacementChannel(nsIURI *, nsIChannel *, bool preserveMethod); |
michael@0 | 236 | |
michael@0 | 237 | // proxy specific methods |
michael@0 | 238 | nsresult ProxyFailover(); |
michael@0 | 239 | nsresult AsyncDoReplaceWithProxy(nsIProxyInfo *); |
michael@0 | 240 | nsresult ContinueDoReplaceWithProxy(nsresult); |
michael@0 | 241 | nsresult ResolveProxy(); |
michael@0 | 242 | |
michael@0 | 243 | // cache specific methods |
michael@0 | 244 | nsresult OpenCacheEntry(bool usingSSL); |
michael@0 | 245 | nsresult OnOfflineCacheEntryAvailable(nsICacheEntry *aEntry, |
michael@0 | 246 | bool aNew, |
michael@0 | 247 | nsIApplicationCache* aAppCache, |
michael@0 | 248 | nsresult aResult); |
michael@0 | 249 | nsresult OnNormalCacheEntryAvailable(nsICacheEntry *aEntry, |
michael@0 | 250 | bool aNew, |
michael@0 | 251 | nsresult aResult); |
michael@0 | 252 | nsresult OpenOfflineCacheEntryForWriting(); |
michael@0 | 253 | nsresult OnOfflineCacheEntryForWritingAvailable(nsICacheEntry *aEntry, |
michael@0 | 254 | nsIApplicationCache* aAppCache, |
michael@0 | 255 | nsresult aResult); |
michael@0 | 256 | nsresult OnCacheEntryAvailableInternal(nsICacheEntry *entry, |
michael@0 | 257 | bool aNew, |
michael@0 | 258 | nsIApplicationCache* aAppCache, |
michael@0 | 259 | nsresult status); |
michael@0 | 260 | nsresult GenerateCacheKey(uint32_t postID, nsACString &key); |
michael@0 | 261 | nsresult UpdateExpirationTime(); |
michael@0 | 262 | nsresult CheckPartial(nsICacheEntry* aEntry, int64_t *aSize, int64_t *aContentLength); |
michael@0 | 263 | bool ShouldUpdateOfflineCacheEntry(); |
michael@0 | 264 | nsresult ReadFromCache(bool alreadyMarkedValid); |
michael@0 | 265 | void CloseCacheEntry(bool doomOnFailure); |
michael@0 | 266 | void CloseOfflineCacheEntry(); |
michael@0 | 267 | nsresult InitCacheEntry(); |
michael@0 | 268 | void UpdateInhibitPersistentCachingFlag(); |
michael@0 | 269 | nsresult InitOfflineCacheEntry(); |
michael@0 | 270 | nsresult AddCacheEntryHeaders(nsICacheEntry *entry); |
michael@0 | 271 | nsresult StoreAuthorizationMetaData(nsICacheEntry *entry); |
michael@0 | 272 | nsresult FinalizeCacheEntry(); |
michael@0 | 273 | nsresult InstallCacheListener(int64_t offset = 0); |
michael@0 | 274 | nsresult InstallOfflineCacheListener(int64_t offset = 0); |
michael@0 | 275 | void MaybeInvalidateCacheEntryForSubsequentGet(); |
michael@0 | 276 | void AsyncOnExamineCachedResponse(); |
michael@0 | 277 | |
michael@0 | 278 | // Handle the bogus Content-Encoding Apache sometimes sends |
michael@0 | 279 | void ClearBogusContentEncodingIfNeeded(); |
michael@0 | 280 | |
michael@0 | 281 | // byte range request specific methods |
michael@0 | 282 | nsresult ProcessPartialContent(); |
michael@0 | 283 | nsresult OnDoneReadingPartialCacheEntry(bool *streamDone); |
michael@0 | 284 | |
michael@0 | 285 | nsresult DoAuthRetry(nsAHttpConnection *); |
michael@0 | 286 | |
michael@0 | 287 | void HandleAsyncRedirectChannelToHttps(); |
michael@0 | 288 | nsresult StartRedirectChannelToHttps(); |
michael@0 | 289 | nsresult ContinueAsyncRedirectChannelToURI(nsresult rv); |
michael@0 | 290 | nsresult OpenRedirectChannel(nsresult rv); |
michael@0 | 291 | |
michael@0 | 292 | /** |
michael@0 | 293 | * A function that takes care of reading STS headers and enforcing STS |
michael@0 | 294 | * load rules. After a secure channel is erected, STS requires the channel |
michael@0 | 295 | * to be trusted or any STS header data on the channel is ignored. |
michael@0 | 296 | * This is called from ProcessResponse. |
michael@0 | 297 | */ |
michael@0 | 298 | nsresult ProcessSTSHeader(); |
michael@0 | 299 | |
michael@0 | 300 | void InvalidateCacheEntryForLocation(const char *location); |
michael@0 | 301 | void AssembleCacheKey(const char *spec, uint32_t postID, nsACString &key); |
michael@0 | 302 | nsresult CreateNewURI(const char *loc, nsIURI **newURI); |
michael@0 | 303 | void DoInvalidateCacheEntry(nsIURI* aURI); |
michael@0 | 304 | |
michael@0 | 305 | // Ref RFC2616 13.10: "invalidation... MUST only be performed if |
michael@0 | 306 | // the host part is the same as in the Request-URI" |
michael@0 | 307 | inline bool HostPartIsTheSame(nsIURI *uri) { |
michael@0 | 308 | nsAutoCString tmpHost1, tmpHost2; |
michael@0 | 309 | return (NS_SUCCEEDED(mURI->GetAsciiHost(tmpHost1)) && |
michael@0 | 310 | NS_SUCCEEDED(uri->GetAsciiHost(tmpHost2)) && |
michael@0 | 311 | (tmpHost1 == tmpHost2)); |
michael@0 | 312 | } |
michael@0 | 313 | |
michael@0 | 314 | inline static bool DoNotRender3xxBody(nsresult rv) { |
michael@0 | 315 | return rv == NS_ERROR_REDIRECT_LOOP || |
michael@0 | 316 | rv == NS_ERROR_CORRUPTED_CONTENT || |
michael@0 | 317 | rv == NS_ERROR_UNKNOWN_PROTOCOL || |
michael@0 | 318 | rv == NS_ERROR_MALFORMED_URI; |
michael@0 | 319 | } |
michael@0 | 320 | |
michael@0 | 321 | // Create a aggregate set of the current notification callbacks |
michael@0 | 322 | // and ensure the transaction is updated to use it. |
michael@0 | 323 | void UpdateAggregateCallbacks(); |
michael@0 | 324 | |
michael@0 | 325 | static bool HasQueryString(nsHttpRequestHead::ParsedMethodType method, nsIURI * uri); |
michael@0 | 326 | bool ResponseWouldVary(nsICacheEntry* entry) const; |
michael@0 | 327 | bool MustValidateBasedOnQueryUrl() const; |
michael@0 | 328 | bool IsResumable(int64_t partialLen, int64_t contentLength, |
michael@0 | 329 | bool ignoreMissingPartialLen = false) const; |
michael@0 | 330 | nsresult MaybeSetupByteRangeRequest(int64_t partialLen, int64_t contentLength); |
michael@0 | 331 | nsresult SetupByteRangeRequest(int64_t partialLen); |
michael@0 | 332 | nsresult OpenCacheInputStream(nsICacheEntry* cacheEntry, bool startBuffering); |
michael@0 | 333 | |
michael@0 | 334 | private: |
michael@0 | 335 | nsCOMPtr<nsISupports> mSecurityInfo; |
michael@0 | 336 | nsCOMPtr<nsICancelable> mProxyRequest; |
michael@0 | 337 | |
michael@0 | 338 | nsRefPtr<nsInputStreamPump> mTransactionPump; |
michael@0 | 339 | nsRefPtr<nsHttpTransaction> mTransaction; |
michael@0 | 340 | |
michael@0 | 341 | uint64_t mLogicalOffset; |
michael@0 | 342 | |
michael@0 | 343 | // cache specific data |
michael@0 | 344 | nsCOMPtr<nsICacheEntry> mCacheEntry; |
michael@0 | 345 | // We must close mCacheInputStream explicitly to avoid leaks. |
michael@0 | 346 | AutoClose<nsIInputStream> mCacheInputStream; |
michael@0 | 347 | nsRefPtr<nsInputStreamPump> mCachePump; |
michael@0 | 348 | nsAutoPtr<nsHttpResponseHead> mCachedResponseHead; |
michael@0 | 349 | nsCOMPtr<nsISupports> mCachedSecurityInfo; |
michael@0 | 350 | uint32_t mPostID; |
michael@0 | 351 | uint32_t mRequestTime; |
michael@0 | 352 | |
michael@0 | 353 | nsCOMPtr<nsICacheEntry> mOfflineCacheEntry; |
michael@0 | 354 | uint32_t mOfflineCacheLastModifiedTime; |
michael@0 | 355 | nsCOMPtr<nsIApplicationCache> mApplicationCacheForWrite; |
michael@0 | 356 | nsCString mCacheDomain; |
michael@0 | 357 | |
michael@0 | 358 | // auth specific data |
michael@0 | 359 | nsCOMPtr<nsIHttpChannelAuthProvider> mAuthProvider; |
michael@0 | 360 | |
michael@0 | 361 | // If the channel is associated with a cache, and the URI matched |
michael@0 | 362 | // a fallback namespace, this will hold the key for the fallback |
michael@0 | 363 | // cache entry. |
michael@0 | 364 | nsCString mFallbackKey; |
michael@0 | 365 | |
michael@0 | 366 | friend class AutoRedirectVetoNotifier; |
michael@0 | 367 | friend class HttpAsyncAborter<nsHttpChannel>; |
michael@0 | 368 | |
michael@0 | 369 | nsCOMPtr<nsIURI> mRedirectURI; |
michael@0 | 370 | nsCOMPtr<nsIChannel> mRedirectChannel; |
michael@0 | 371 | uint32_t mRedirectType; |
michael@0 | 372 | |
michael@0 | 373 | static const uint32_t WAIT_FOR_CACHE_ENTRY = 1; |
michael@0 | 374 | static const uint32_t WAIT_FOR_OFFLINE_CACHE_ENTRY = 2; |
michael@0 | 375 | |
michael@0 | 376 | // state flags |
michael@0 | 377 | uint32_t mCachedContentIsValid : 1; |
michael@0 | 378 | uint32_t mCachedContentIsPartial : 1; |
michael@0 | 379 | uint32_t mTransactionReplaced : 1; |
michael@0 | 380 | uint32_t mAuthRetryPending : 1; |
michael@0 | 381 | uint32_t mProxyAuthPending : 1; |
michael@0 | 382 | uint32_t mResuming : 1; |
michael@0 | 383 | uint32_t mInitedCacheEntry : 1; |
michael@0 | 384 | // True if we are loading a fallback cache entry from the |
michael@0 | 385 | // application cache. |
michael@0 | 386 | uint32_t mFallbackChannel : 1; |
michael@0 | 387 | // True if consumer added its own If-None-Match or If-Modified-Since |
michael@0 | 388 | // headers. In such a case we must not override them in the cache code |
michael@0 | 389 | // and also we want to pass possible 304 code response through. |
michael@0 | 390 | uint32_t mCustomConditionalRequest : 1; |
michael@0 | 391 | uint32_t mFallingBack : 1; |
michael@0 | 392 | uint32_t mWaitingForRedirectCallback : 1; |
michael@0 | 393 | // True if mRequestTime has been set. In such a case it is safe to update |
michael@0 | 394 | // the cache entry's expiration time. Otherwise, it is not(see bug 567360). |
michael@0 | 395 | uint32_t mRequestTimeInitialized : 1; |
michael@0 | 396 | uint32_t mCacheEntryIsReadOnly : 1; |
michael@0 | 397 | uint32_t mCacheEntryIsWriteOnly : 1; |
michael@0 | 398 | // see WAIT_FOR_* constants above |
michael@0 | 399 | uint32_t mCacheEntriesToWaitFor : 2; |
michael@0 | 400 | uint32_t mHasQueryString : 1; |
michael@0 | 401 | // whether cache entry data write was in progress during cache entry check |
michael@0 | 402 | // when true, after we finish read from cache we must check all data |
michael@0 | 403 | // had been loaded from cache. If not, then an error has to be propagated |
michael@0 | 404 | // to the consumer. |
michael@0 | 405 | uint32_t mConcurentCacheAccess : 1; |
michael@0 | 406 | // whether the request is setup be byte-range |
michael@0 | 407 | uint32_t mIsPartialRequest : 1; |
michael@0 | 408 | // true iff there is AutoRedirectVetoNotifier on the stack |
michael@0 | 409 | uint32_t mHasAutoRedirectVetoNotifier : 1; |
michael@0 | 410 | |
michael@0 | 411 | nsTArray<nsContinueRedirectionFunc> mRedirectFuncStack; |
michael@0 | 412 | |
michael@0 | 413 | // Needed for accurate DNS timing |
michael@0 | 414 | nsRefPtr<nsDNSPrefetch> mDNSPrefetch; |
michael@0 | 415 | |
michael@0 | 416 | nsresult WaitForRedirectCallback(); |
michael@0 | 417 | void PushRedirectAsyncFunc(nsContinueRedirectionFunc func); |
michael@0 | 418 | void PopRedirectAsyncFunc(nsContinueRedirectionFunc func); |
michael@0 | 419 | |
michael@0 | 420 | protected: |
michael@0 | 421 | virtual void DoNotifyListenerCleanup(); |
michael@0 | 422 | nsPerformance* GetPerformance(); |
michael@0 | 423 | |
michael@0 | 424 | private: // cache telemetry |
michael@0 | 425 | bool mDidReval; |
michael@0 | 426 | |
michael@0 | 427 | private: |
michael@0 | 428 | nsIPrincipal *GetPrincipal(); |
michael@0 | 429 | nsCOMPtr<nsIPrincipal> mPrincipal; |
michael@0 | 430 | bool mForcePending; |
michael@0 | 431 | }; |
michael@0 | 432 | |
michael@0 | 433 | } } // namespace mozilla::net |
michael@0 | 434 | |
michael@0 | 435 | #endif // nsHttpChannel_h__ |