Bug 1310127 - Part 1: Use MOZ_MUST_USE in netwerk/protocol/http r=mcmanus

Add MOZ_MUST_USE attirbute to headers and idl files.

MozReview-Commit-ID: 7nZQlZoDrv2

--HG--
extra : rebase_source : e8d9469a3b24932d95bf533c54f43c324ffa8c53
This commit is contained in:
Wei-Cheng Pan 2016-12-27 15:22:07 +08:00
parent 4ebec065ab
commit 5143918e81
46 changed files with 878 additions and 772 deletions

View File

@ -21,8 +21,8 @@ public:
ASpdySession();
virtual ~ASpdySession();
virtual bool AddStream(nsAHttpTransaction *, int32_t,
bool, nsIInterfaceRequestor *) = 0;
virtual MOZ_MUST_USE bool
AddStream(nsAHttpTransaction *, int32_t, bool, nsIInterfaceRequestor *) = 0;
virtual bool CanReuse() = 0;
virtual bool RoomForMoreStreams() = 0;
virtual PRIntervalTime IdleTime() = 0;
@ -100,7 +100,7 @@ public:
// determine the index (0..kCount-1) of the spdy information that
// correlates to the npn string. NS_FAILED() if no match is found.
nsresult GetNPNIndex(const nsACString &npnString, uint32_t *result) const;
MOZ_MUST_USE nsresult GetNPNIndex(const nsACString &npnString, uint32_t *result) const;
// determine if a version of the protocol is enabled for index < kCount
bool ProtocolEnabled(uint32_t index) const;

View File

@ -17,16 +17,16 @@ class CacheControlParser final : Tokenizer
public:
explicit CacheControlParser(nsACString const &header);
bool MaxAge(uint32_t *seconds);
bool MaxStale(uint32_t *seconds);
bool MinFresh(uint32_t *seconds);
MOZ_MUST_USE bool MaxAge(uint32_t *seconds);
MOZ_MUST_USE bool MaxStale(uint32_t *seconds);
MOZ_MUST_USE bool MinFresh(uint32_t *seconds);
bool NoCache();
bool NoStore();
private:
void Directive();
void IgnoreDirective();
bool SecondsValue(uint32_t *seconds, uint32_t defaultVal = 0);
MOZ_MUST_USE bool SecondsValue(uint32_t *seconds, uint32_t defaultVal = 0);
bool mMaxAgeSet;
uint32_t mMaxAge;

View File

@ -107,8 +107,9 @@ public:
virtual ~Http2Decompressor() { } ;
// NS_OK: Produces the working set of HTTP/1 formatted headers
nsresult DecodeHeaderBlock(const uint8_t *data, uint32_t datalen,
nsACString &output, bool isPush);
MOZ_MUST_USE nsresult DecodeHeaderBlock(const uint8_t *data,
uint32_t datalen, nsACString &output,
bool isPush);
void GetStatus(nsACString &hdr) { hdr = mHeaderStatus; }
void GetHost(nsACString &hdr) { hdr = mHeaderHost; }
@ -117,25 +118,27 @@ public:
void GetMethod(nsACString &hdr) { hdr = mHeaderMethod; }
private:
nsresult DoIndexed();
nsresult DoLiteralWithoutIndex();
nsresult DoLiteralWithIncremental();
nsresult DoLiteralInternal(nsACString &, nsACString &, uint32_t);
nsresult DoLiteralNeverIndexed();
nsresult DoContextUpdate();
MOZ_MUST_USE nsresult DoIndexed();
MOZ_MUST_USE nsresult DoLiteralWithoutIndex();
MOZ_MUST_USE nsresult DoLiteralWithIncremental();
MOZ_MUST_USE nsresult DoLiteralInternal(nsACString &, nsACString &, uint32_t);
MOZ_MUST_USE nsresult DoLiteralNeverIndexed();
MOZ_MUST_USE nsresult DoContextUpdate();
nsresult DecodeInteger(uint32_t prefixLen, uint32_t &result);
nsresult OutputHeader(uint32_t index);
nsresult OutputHeader(const nsACString &name, const nsACString &value);
MOZ_MUST_USE nsresult DecodeInteger(uint32_t prefixLen, uint32_t &result);
MOZ_MUST_USE nsresult OutputHeader(uint32_t index);
MOZ_MUST_USE nsresult OutputHeader(const nsACString &name, const nsACString &value);
nsresult CopyHeaderString(uint32_t index, nsACString &name);
nsresult CopyStringFromInput(uint32_t index, nsACString &val);
MOZ_MUST_USE nsresult CopyHeaderString(uint32_t index, nsACString &name);
MOZ_MUST_USE nsresult CopyStringFromInput(uint32_t index, nsACString &val);
uint8_t ExtractByte(uint8_t bitsLeft, uint32_t &bytesConsumed);
nsresult CopyHuffmanStringFromInput(uint32_t index, nsACString &val);
nsresult DecodeHuffmanCharacter(const HuffmanIncomingTable *table, uint8_t &c,
uint32_t &bytesConsumed, uint8_t &bitsLeft);
nsresult DecodeFinalHuffmanCharacter(const HuffmanIncomingTable *table,
uint8_t &c, uint8_t &bitsLeft);
MOZ_MUST_USE nsresult CopyHuffmanStringFromInput(uint32_t index, nsACString &val);
MOZ_MUST_USE nsresult
DecodeHuffmanCharacter(const HuffmanIncomingTable *table, uint8_t &c,
uint32_t &bytesConsumed, uint8_t &bitsLeft);
MOZ_MUST_USE nsresult
DecodeFinalHuffmanCharacter(const HuffmanIncomingTable *table, uint8_t &c,
uint8_t &bitsLeft);
nsCString mHeaderStatus;
nsCString mHeaderHost;
@ -166,10 +169,13 @@ public:
// HTTP/1 formatted header block as input - HTTP/2 formatted
// header block as output
nsresult EncodeHeaderBlock(const nsCString &nvInput,
const nsACString &method, const nsACString &path,
const nsACString &host, const nsACString &scheme,
bool connectForm, nsACString &output);
MOZ_MUST_USE nsresult EncodeHeaderBlock(const nsCString &nvInput,
const nsACString &method,
const nsACString &path,
const nsACString &host,
const nsACString &scheme,
bool connectForm,
nsACString &output);
int64_t GetParsedContentLength() { return mParsedContentLength; } // -1 on not found

View File

@ -41,18 +41,20 @@ public:
virtual Http2Stream *GetConsumerStream() override { return mConsumerStream; };
void SetConsumerStream(Http2Stream *aStream);
bool GetHashKey(nsCString &key);
MOZ_MUST_USE bool GetHashKey(nsCString &key);
// override of Http2Stream
nsresult ReadSegments(nsAHttpSegmentReader *, uint32_t, uint32_t *) override;
nsresult WriteSegments(nsAHttpSegmentWriter *, uint32_t, uint32_t *) override;
MOZ_MUST_USE nsresult ReadSegments(nsAHttpSegmentReader *,
uint32_t, uint32_t *) override;
MOZ_MUST_USE nsresult WriteSegments(nsAHttpSegmentWriter *,
uint32_t, uint32_t *) override;
void AdjustInitialWindow() override;
nsIRequestContext *RequestContext() override { return mRequestContext; };
void ConnectPushedStream(Http2Stream *consumer);
bool TryOnPush();
static bool TestOnPush(Http2Stream *consumer);
MOZ_MUST_USE bool TryOnPush();
static MOZ_MUST_USE bool TestOnPush(Http2Stream *consumer);
virtual bool DeferCleanup(nsresult status) override;
void SetDeferCleanupOnSuccess(bool val) { mDeferCleanupOnSuccess = val; }
@ -60,7 +62,8 @@ public:
bool IsOrphaned(TimeStamp now);
void OnPushFailed() { mDeferCleanupOnPush = false; mOnPushFailed = true; }
nsresult GetBufferedData(char *buf, uint32_t count, uint32_t *countWritten);
MOZ_MUST_USE nsresult GetBufferedData(char *buf, uint32_t count,
uint32_t *countWritten);
// overload of Http2Stream
virtual bool HasSink() override { return !!mConsumerStream; }
@ -104,7 +107,8 @@ public:
Http2PushTransactionBuffer();
nsresult GetBufferedData(char *buf, uint32_t count, uint32_t *countWritten);
MOZ_MUST_USE nsresult GetBufferedData(char *buf, uint32_t count,
uint32_t *countWritten);
void SetPushStream(Http2PushedStream *stream) { mPushStream = stream; }
private:

View File

@ -45,8 +45,8 @@ public:
Http2Session(nsISocketTransport *, uint32_t version, bool attemptingEarlyData);
bool AddStream(nsAHttpTransaction *, int32_t,
bool, nsIInterfaceRequestor *) override;
MOZ_MUST_USE bool AddStream(nsAHttpTransaction *, int32_t,
bool, nsIInterfaceRequestor *) override;
bool CanReuse() override { return !mShouldGoAway && !mClosed; }
bool RoomForMoreStreams() override;
uint32_t SpdyVersion() override;
@ -202,19 +202,20 @@ public:
void TransactionHasDataToWrite(Http2Stream *);
// an overload of nsAHttpSegementReader
virtual nsresult CommitToSegmentSize(uint32_t size, bool forceCommitment) override;
nsresult BufferOutput(const char *, uint32_t, uint32_t *);
virtual MOZ_MUST_USE nsresult CommitToSegmentSize(uint32_t size,
bool forceCommitment) override;
MOZ_MUST_USE nsresult BufferOutput(const char *, uint32_t, uint32_t *);
void FlushOutputQueue();
uint32_t AmountOfOutputBuffered() { return mOutputQueueUsed - mOutputQueueSent; }
uint32_t GetServerInitialStreamWindow() { return mServerInitialStreamWindow; }
bool TryToActivate(Http2Stream *stream);
MOZ_MUST_USE bool TryToActivate(Http2Stream *stream);
void ConnectPushedStream(Http2Stream *stream);
void ConnectSlowConsumer(Http2Stream *stream);
nsresult ConfirmTLSProfile();
static bool ALPNCallback(nsISupports *securityInfo);
MOZ_MUST_USE nsresult ConfirmTLSProfile();
static MOZ_MUST_USE bool ALPNCallback(nsISupports *securityInfo);
uint64_t Serial() { return mSerial; }
@ -230,14 +231,14 @@ public:
uint32_t InitialRwin() { return mInitialRwin; }
void SendPing() override;
bool MaybeReTunnel(nsAHttpTransaction *) override;
MOZ_MUST_USE bool MaybeReTunnel(nsAHttpTransaction *) override;
bool UseH2Deps() { return mUseH2Deps; }
// overload of nsAHttpTransaction
nsresult ReadSegmentsAgain(nsAHttpSegmentReader *, uint32_t, uint32_t *, bool *) override final;
nsresult WriteSegmentsAgain(nsAHttpSegmentWriter *, uint32_t , uint32_t *, bool *) override final;
bool Do0RTT() override final { return true; }
nsresult Finish0RTT(bool aRestart, bool aAlpnChanged) override final;
MOZ_MUST_USE nsresult ReadSegmentsAgain(nsAHttpSegmentReader *, uint32_t, uint32_t *, bool *) override final;
MOZ_MUST_USE nsresult WriteSegmentsAgain(nsAHttpSegmentWriter *, uint32_t , uint32_t *, bool *) override final;
MOZ_MUST_USE bool Do0RTT() override final { return true; }
MOZ_MUST_USE nsresult Finish0RTT(bool aRestart, bool aAlpnChanged) override final;
private:
@ -257,12 +258,12 @@ private:
static const uint8_t kMagicHello[24];
nsresult ResponseHeadersComplete();
MOZ_MUST_USE nsresult ResponseHeadersComplete();
uint32_t GetWriteQueueSize();
void ChangeDownstreamState(enum internalStateType);
void ResetDownstreamState();
nsresult ReadyToProcessDataFrame(enum internalStateType);
nsresult UncompressAndDiscard(bool);
MOZ_MUST_USE nsresult ReadyToProcessDataFrame(enum internalStateType);
MOZ_MUST_USE nsresult UncompressAndDiscard(bool);
void GeneratePing(bool);
void GenerateSettingsAck();
void GeneratePriority(uint32_t, uint8_t);
@ -273,18 +274,20 @@ private:
void CloseStream(Http2Stream *, nsresult);
void SendHello();
void RemoveStreamFromQueues(Http2Stream *);
nsresult ParsePadding(uint8_t &, uint16_t &);
MOZ_MUST_USE nsresult ParsePadding(uint8_t &, uint16_t &);
void SetWriteCallbacks();
void RealignOutputQueue();
void ProcessPending();
nsresult ProcessConnectedPush(Http2Stream *, nsAHttpSegmentWriter *,
uint32_t, uint32_t *);
nsresult ProcessSlowConsumer(Http2Stream *, nsAHttpSegmentWriter *,
uint32_t, uint32_t *);
MOZ_MUST_USE nsresult ProcessConnectedPush(Http2Stream *,
nsAHttpSegmentWriter *,
uint32_t, uint32_t *);
MOZ_MUST_USE nsresult ProcessSlowConsumer(Http2Stream *,
nsAHttpSegmentWriter *,
uint32_t, uint32_t *);
nsresult SetInputFrameDataStream(uint32_t);
MOZ_MUST_USE nsresult SetInputFrameDataStream(uint32_t);
void CreatePriorityNode(uint32_t, uint32_t, uint8_t, const char *);
bool VerifyStream(Http2Stream *, uint32_t);
void SetNeedsCleanup();
@ -300,7 +303,7 @@ private:
// a wrapper for all calls to the nshttpconnection level segment writer. Used
// to track network I/O for timeout purposes
nsresult NetworkRead(nsAHttpSegmentWriter *, char *, uint32_t, uint32_t *);
MOZ_MUST_USE nsresult NetworkRead(nsAHttpSegmentWriter *, char *, uint32_t, uint32_t *);
void Shutdown();

View File

@ -54,8 +54,10 @@ public:
stateType HTTPState() { return mState; }
void SetHTTPState(stateType val) { mState = val; }
virtual nsresult ReadSegments(nsAHttpSegmentReader *, uint32_t, uint32_t *);
virtual nsresult WriteSegments(nsAHttpSegmentWriter *, uint32_t, uint32_t *);
virtual MOZ_MUST_USE nsresult ReadSegments(nsAHttpSegmentReader *,
uint32_t, uint32_t *);
virtual MOZ_MUST_USE nsresult WriteSegments(nsAHttpSegmentWriter *,
uint32_t, uint32_t *);
virtual bool DeferCleanup(nsresult status);
// The consumer stream is the synthetic pull stream hooked up to this stream
@ -111,9 +113,11 @@ public:
void UpdateTransportReadEvents(uint32_t count);
// NS_ERROR_ABORT terminates stream, other failure terminates session
nsresult ConvertResponseHeaders(Http2Decompressor *, nsACString &,
nsACString &, int32_t &);
nsresult ConvertPushHeaders(Http2Decompressor *, nsACString &, nsACString &);
MOZ_MUST_USE nsresult ConvertResponseHeaders(Http2Decompressor *,
nsACString &,
nsACString &, int32_t &);
MOZ_MUST_USE nsresult ConvertPushHeaders(Http2Decompressor *, nsACString &,
nsACString &);
bool AllowFlowControlledWrite();
void UpdateServerReceiveWindow(int32_t delta);
@ -147,12 +151,12 @@ public:
Http2Session *Session() { return mSession; }
static nsresult MakeOriginURL(const nsACString &origin,
RefPtr<nsStandardURL> &url);
static MOZ_MUST_USE nsresult MakeOriginURL(const nsACString &origin,
RefPtr<nsStandardURL> &url);
static nsresult MakeOriginURL(const nsACString &scheme,
const nsACString &origin,
RefPtr<nsStandardURL> &url);
static MOZ_MUST_USE nsresult MakeOriginURL(const nsACString &scheme,
const nsACString &origin,
RefPtr<nsStandardURL> &url);
// Mirrors nsAHttpTransaction
bool Do0RTT();
@ -215,18 +219,18 @@ protected:
void ChangeState(enum upstreamStateType);
virtual void AdjustInitialWindow();
nsresult TransmitFrame(const char *, uint32_t *, bool forceCommitment);
MOZ_MUST_USE nsresult TransmitFrame(const char *, uint32_t *, bool forceCommitment);
private:
friend class nsAutoPtr<Http2Stream>;
nsresult ParseHttpRequestHeaders(const char *, uint32_t, uint32_t *);
nsresult GenerateOpen();
MOZ_MUST_USE nsresult ParseHttpRequestHeaders(const char *, uint32_t, uint32_t *);
MOZ_MUST_USE nsresult GenerateOpen();
void AdjustPushedPriority();
void GenerateDataFrameHeader(uint32_t, bool);
nsresult BufferInput(uint32_t , uint32_t *);
MOZ_MUST_USE nsresult BufferInput(uint32_t , uint32_t *);
// The underlying HTTP transaction. This pointer is used as the key
// in the Http2Session mStreamTransactionHash so it is important to

View File

@ -110,10 +110,11 @@ public:
HttpBaseChannel();
virtual nsresult Init(nsIURI *aURI, uint32_t aCaps, nsProxyInfo *aProxyInfo,
uint32_t aProxyResolveFlags,
nsIURI *aProxyURI,
const nsID& aChannelId);
virtual MOZ_MUST_USE nsresult Init(nsIURI *aURI, uint32_t aCaps,
nsProxyInfo *aProxyInfo,
uint32_t aProxyResolveFlags,
nsIURI *aProxyURI,
const nsID& aChannelId);
// nsIRequest
NS_IMETHOD GetName(nsACString& aName) override;
@ -231,7 +232,7 @@ public:
NS_IMETHOD GetBeConservative(bool *aBeConservative) override;
NS_IMETHOD SetBeConservative(bool aBeConservative) override;
NS_IMETHOD GetApiRedirectToURI(nsIURI * *aApiRedirectToURI) override;
virtual nsresult AddSecurityMessage(const nsAString &aMessageTag, const nsAString &aMessageCategory);
virtual MOZ_MUST_USE nsresult AddSecurityMessage(const nsAString &aMessageTag, const nsAString &aMessageCategory);
NS_IMETHOD TakeAllSecurityMessages(nsCOMArray<nsISecurityConsoleMessage> &aMessages) override;
NS_IMETHOD GetResponseTimeoutEnabled(bool *aEnable) override;
NS_IMETHOD SetResponseTimeoutEnabled(bool aEnable) override;
@ -312,7 +313,7 @@ public:
private:
virtual ~nsContentEncodings();
nsresult PrepareForNext(void);
MOZ_MUST_USE nsresult PrepareForNext(void);
// We do not own the buffer. The channel owns it.
const char* mEncodingHeader;
@ -332,7 +333,7 @@ public:
const NetAddr& GetSelfAddr() { return mSelfAddr; }
const NetAddr& GetPeerAddr() { return mPeerAddr; }
nsresult OverrideSecurityInfo(nsISupports* aSecurityInfo);
MOZ_MUST_USE nsresult OverrideSecurityInfo(nsISupports* aSecurityInfo);
public: /* Necko internal use only... */
bool IsNavigation();
@ -344,8 +345,9 @@ public: /* Necko internal use only... */
// Like nsIEncodedChannel::DoApplyConversions except context is set to
// mListenerContext.
nsresult DoApplyContentConversions(nsIStreamListener *aNextListener,
nsIStreamListener **aNewNextListener);
MOZ_MUST_USE nsresult
DoApplyContentConversions(nsIStreamListener *aNextListener,
nsIStreamListener **aNewNextListener);
// Callback on main thread when NS_AsyncCopy() is finished populating
// the new mUploadStream.
@ -375,10 +377,9 @@ protected:
nsPIDOMWindowInner* GetInnerDOMWindow();
void AddCookiesToRequest();
virtual nsresult SetupReplacementChannel(nsIURI *,
nsIChannel *,
bool preserveMethod,
uint32_t redirectFlags);
virtual MOZ_MUST_USE nsresult
SetupReplacementChannel(nsIURI *, nsIChannel *, bool preserveMethod,
uint32_t redirectFlags);
// bundle calling OMR observers and marking flag into one function
inline void CallOnModifyRequestObservers() {
@ -402,7 +403,7 @@ protected:
// GetPrincipal Returns the channel's URI principal.
nsIPrincipal *GetURIPrincipal();
bool BypassServiceWorker() const;
MOZ_MUST_USE bool BypassServiceWorker() const;
// Returns true if this channel should intercept the network request and prepare
// for a possible synthesized response instead.
@ -626,7 +627,7 @@ public:
// Aborts channel: calls OnStart/Stop with provided status, removes channel
// from loadGroup.
nsresult AsyncAbort(nsresult status);
MOZ_MUST_USE nsresult AsyncAbort(nsresult status);
// Does most the actual work.
void HandleAsyncAbort();
@ -634,8 +635,8 @@ public:
// AsyncCall calls a member function asynchronously (via an event).
// retval isn't refcounted and is set only when event was successfully
// posted, the event is returned for the purpose of cancelling when needed
nsresult AsyncCall(void (T::*funcPtr)(),
nsRunnableMethod<T> **retval = nullptr);
MOZ_MUST_USE nsresult AsyncCall(void (T::*funcPtr)(),
nsRunnableMethod<T> **retval = nullptr);
private:
T *mThis;
@ -645,7 +646,7 @@ protected:
};
template <class T>
nsresult HttpAsyncAborter<T>::AsyncAbort(nsresult status)
MOZ_MUST_USE nsresult HttpAsyncAborter<T>::AsyncAbort(nsresult status)
{
MOZ_LOG(gHttpLog, LogLevel::Debug,
("HttpAsyncAborter::AsyncAbort [this=%p status=%" PRIx32 "]\n",

View File

@ -103,7 +103,7 @@ public:
void AddIPDLReference();
void ReleaseIPDLReference();
bool IsSuspended();
MOZ_MUST_USE bool IsSuspended();
mozilla::ipc::IPCResult RecvNotifyTrackingProtectionDisabled() override;
mozilla::ipc::IPCResult RecvNotifyTrackingResource() override;
@ -156,7 +156,8 @@ protected:
mozilla::ipc::IPCResult RecvSetPriority(const int16_t& aPriority) override;
bool GetAssociatedContentSecurity(nsIAssociatedContentSecurity** res = nullptr);
MOZ_MUST_USE bool
GetAssociatedContentSecurity(nsIAssociatedContentSecurity** res = nullptr);
virtual void DoNotifyListenerCleanup() override;
NS_IMETHOD GetResponseSynthesized(bool* aSynthesized) override;
@ -187,7 +188,7 @@ private:
// before the constructor message is sent to the parent.
void SetEventTarget();
nsresult ContinueAsyncOpen();
MOZ_MUST_USE nsresult ContinueAsyncOpen();
void DoOnStartRequest(nsIRequest* aRequest, nsISupports* aContext);
void DoOnStatus(nsIRequest* aRequest, nsresult status);
@ -328,10 +329,10 @@ private:
// Create a a new channel to be used in a redirection, based on the provided
// response headers.
nsresult SetupRedirect(nsIURI* uri,
const nsHttpResponseHead* responseHead,
const uint32_t& redirectFlags,
nsIChannel** outChannel);
MOZ_MUST_USE nsresult SetupRedirect(nsIURI* uri,
const nsHttpResponseHead* responseHead,
const uint32_t& redirectFlags,
nsIChannel** outChannel);
// Perform a redirection without communicating with the parent process at all.
void BeginNonIPCRedirect(nsIURI* responseURI,

View File

@ -72,13 +72,13 @@ public:
nsILoadContext* aLoadContext,
PBOverrideStatus aStatus);
bool Init(const HttpChannelCreationArgs& aOpenArgs);
MOZ_MUST_USE bool Init(const HttpChannelCreationArgs& aOpenArgs);
// ADivertableParentChannel functions.
void DivertTo(nsIStreamListener *aListener) override;
nsresult SuspendForDiversion() override;
nsresult SuspendMessageDiversion() override;
nsresult ResumeMessageDiversion() override;
MOZ_MUST_USE nsresult SuspendForDiversion() override;
MOZ_MUST_USE nsresult SuspendMessageDiversion() override;
MOZ_MUST_USE nsresult ResumeMessageDiversion() override;
// Calls OnStartRequest for "DivertTo" listener, then notifies child channel
// that it should divert OnDataAvailable and OnStopRequest calls to this
@ -96,7 +96,8 @@ public:
}
}
nsresult OpenAlternativeOutputStream(const nsACString & type, nsIOutputStream * *_retval);
MOZ_MUST_USE nsresult OpenAlternativeOutputStream(const nsACString & type,
nsIOutputStream * *_retval);
void InvokeAsyncOpen(nsresult rv);
@ -105,47 +106,49 @@ public:
protected:
// used to connect redirected-to channel in parent with just created
// ChildChannel. Used during redirects.
bool ConnectChannel(const uint32_t& channelId, const bool& shouldIntercept);
MOZ_MUST_USE bool ConnectChannel(const uint32_t& channelId,
const bool& shouldIntercept);
bool DoAsyncOpen(const URIParams& uri,
const OptionalURIParams& originalUri,
const OptionalURIParams& docUri,
const OptionalURIParams& referrerUri,
const uint32_t& referrerPolicy,
const OptionalURIParams& internalRedirectUri,
const OptionalURIParams& topWindowUri,
const uint32_t& loadFlags,
const RequestHeaderTuples& requestHeaders,
const nsCString& requestMethod,
const OptionalIPCStream& uploadStream,
const bool& uploadStreamHasHeaders,
const int16_t& priority,
const uint32_t& classOfService,
const uint8_t& redirectionLimit,
const bool& allowSTS,
const uint32_t& thirdPartyFlags,
const bool& doResumeAt,
const uint64_t& startPos,
const nsCString& entityID,
const bool& chooseApplicationCache,
const nsCString& appCacheClientID,
const bool& allowSpdy,
const bool& allowAltSvc,
const bool& beConservative,
const OptionalLoadInfoArgs& aLoadInfoArgs,
const OptionalHttpResponseHead& aSynthesizedResponseHead,
const nsCString& aSecurityInfoSerialization,
const uint32_t& aCacheKey,
const nsCString& aRequestContextID,
const OptionalCorsPreflightArgs& aCorsPreflightArgs,
const uint32_t& aInitialRwin,
const bool& aBlockAuthPrompt,
const bool& aSuspendAfterSynthesizeResponse,
const bool& aAllowStaleCacheContent,
const nsCString& aContentTypeHint,
const nsCString& aChannelId,
const uint64_t& aContentWindowId,
const nsCString& aPreferredAlternativeType);
MOZ_MUST_USE bool
DoAsyncOpen(const URIParams& uri,
const OptionalURIParams& originalUri,
const OptionalURIParams& docUri,
const OptionalURIParams& referrerUri,
const uint32_t& referrerPolicy,
const OptionalURIParams& internalRedirectUri,
const OptionalURIParams& topWindowUri,
const uint32_t& loadFlags,
const RequestHeaderTuples& requestHeaders,
const nsCString& requestMethod,
const OptionalIPCStream& uploadStream,
const bool& uploadStreamHasHeaders,
const int16_t& priority,
const uint32_t& classOfService,
const uint8_t& redirectionLimit,
const bool& allowSTS,
const uint32_t& thirdPartyFlags,
const bool& doResumeAt,
const uint64_t& startPos,
const nsCString& entityID,
const bool& chooseApplicationCache,
const nsCString& appCacheClientID,
const bool& allowSpdy,
const bool& allowAltSvc,
const bool& beConservative,
const OptionalLoadInfoArgs& aLoadInfoArgs,
const OptionalHttpResponseHead& aSynthesizedResponseHead,
const nsCString& aSecurityInfoSerialization,
const uint32_t& aCacheKey,
const nsCString& aRequestContextID,
const OptionalCorsPreflightArgs& aCorsPreflightArgs,
const uint32_t& aInitialRwin,
const bool& aBlockAuthPrompt,
const bool& aSuspendAfterSynthesizeResponse,
const bool& aAllowStaleCacheContent,
const nsCString& aContentTypeHint,
const nsCString& aChannelId,
const uint64_t& aContentWindowId,
const nsCString& aPreferredAlternativeType);
virtual mozilla::ipc::IPCResult RecvSetPriority(const int16_t& priority) override;
virtual mozilla::ipc::IPCResult RecvSetClassOfService(const uint32_t& cos) override;
@ -177,7 +180,7 @@ protected:
virtual void ActorDestroy(ActorDestroyReason why) override;
// Supporting function for ADivertableParentChannel.
nsresult ResumeForDiversion();
MOZ_MUST_USE nsresult ResumeForDiversion();
// Asynchronously calls NotifyDiversionFailed.
void FailDiversion(nsresult aErrorCode, bool aSkipResume = true);
@ -185,12 +188,13 @@ protected:
friend class HttpChannelParentListener;
RefPtr<mozilla::dom::TabParent> mTabParent;
nsresult ReportSecurityMessage(const nsAString& aMessageTag,
const nsAString& aMessageCategory) override;
MOZ_MUST_USE nsresult
ReportSecurityMessage(const nsAString& aMessageTag,
const nsAString& aMessageCategory) override;
// Calls SendDeleteSelf and sets mIPCClosed to true because we should not
// send any more messages after that. Bug 1274886
bool DoSendDeleteSelf();
MOZ_MUST_USE bool DoSendDeleteSelf();
// Called to notify the parent channel to not send any more IPC messages.
virtual mozilla::ipc::IPCResult RecvDeletingChannel() override;
virtual mozilla::ipc::IPCResult RecvFinishInterceptedRedirect() override;

View File

@ -47,8 +47,8 @@ public:
explicit HttpChannelParentListener(HttpChannelParent* aInitialChannel);
// For channel diversion from child to parent.
nsresult DivertTo(nsIStreamListener *aListener);
nsresult SuspendForDiversion();
MOZ_MUST_USE nsresult DivertTo(nsIStreamListener *aListener);
MOZ_MUST_USE nsresult SuspendForDiversion();
void SetupInterception(const nsHttpResponseHead& aResponseHead);
void SetupInterceptionAfterRedirect(bool aShouldIntercept);
@ -58,7 +58,7 @@ private:
virtual ~HttpChannelParentListener();
// Private partner function to SuspendForDiversion.
nsresult ResumeForDiversion();
MOZ_MUST_USE nsresult ResumeForDiversion();
// Can be the original HttpChannelParent that created this object (normal
// case), a different {HTTP|FTP}ChannelParent that we've been redirected to,

View File

@ -43,8 +43,10 @@ protected:
void EnsureSynthesizedResponse();
void DoNotifyController();
nsresult DoSynthesizeStatus(uint16_t aStatus, const nsACString& aReason);
nsresult DoSynthesizeHeader(const nsACString& aName, const nsACString& aValue);
MOZ_MUST_USE nsresult DoSynthesizeStatus(uint16_t aStatus,
const nsACString& aReason);
MOZ_MUST_USE nsresult DoSynthesizeHeader(const nsACString& aName,
const nsACString& aValue);
virtual ~InterceptedChannelBase();
public:

View File

@ -38,9 +38,9 @@ class NullHttpChannel final
explicit NullHttpChannel(nsIHttpChannel * chan);
// Same signature as nsHttpChannel::Init
nsresult Init(nsIURI *aURI, uint32_t aCaps, nsProxyInfo *aProxyInfo,
uint32_t aProxyResolveFlags,
nsIURI *aProxyURI);
MOZ_MUST_USE nsresult Init(nsIURI *aURI, uint32_t aCaps,
nsProxyInfo *aProxyInfo,
uint32_t aProxyResolveFlags, nsIURI *aProxyURI);
private:
~NullHttpChannel() { }

View File

@ -38,7 +38,7 @@ public:
nsIInterfaceRequestor *callbacks,
uint32_t caps);
bool Claim();
MOZ_MUST_USE bool Claim();
// Overload of nsAHttpTransaction methods
bool IsNullTransaction() override final { return true; }

View File

@ -43,7 +43,7 @@ public:
// The cache holds only weak pointers - no references
SpdyPushCache();
virtual ~SpdyPushCache();
bool RegisterPushedStreamHttp2(const nsCString& key,
MOZ_MUST_USE bool RegisterPushedStreamHttp2(const nsCString& key,
Http2PushedStream *stream);
Http2PushedStream *RemovePushedStreamHttp2(const nsCString& key);
private:

View File

@ -118,10 +118,11 @@ public:
nsAHttpSegmentWriter *writer);
const nsAHttpTransaction *Transaction() const { return mTransaction.get(); }
nsresult CommitToSegmentSize(uint32_t size, bool forceCommitment) override;
nsresult GetTransactionSecurityInfo(nsISupports **) override;
nsresult NudgeTunnel(NudgeTunnelCallback *callback);
nsresult SetProxiedTransaction(nsAHttpTransaction *aTrans);
MOZ_MUST_USE nsresult CommitToSegmentSize(uint32_t size,
bool forceCommitment) override;
MOZ_MUST_USE nsresult GetTransactionSecurityInfo(nsISupports **) override;
MOZ_MUST_USE nsresult NudgeTunnel(NudgeTunnelCallback *callback);
MOZ_MUST_USE nsresult SetProxiedTransaction(nsAHttpTransaction *aTrans);
void newIODriver(nsIAsyncInputStream *aSocketIn,
nsIAsyncOutputStream *aSocketOut,
nsIAsyncInputStream **outSocketIn,
@ -134,7 +135,7 @@ public:
SpdyConnectTransaction *QuerySpdyConnectTransaction() override;
private:
nsresult StartTimerCallback();
MOZ_MUST_USE nsresult StartTimerCallback();
void Cleanup();
int32_t FilterOutput(const char *aBuf, int32_t aAmount);
int32_t FilterInput(char *aBuf, int32_t aAmount);
@ -194,10 +195,12 @@ public:
void MapStreamToHttpConnection(nsISocketTransport *aTransport,
nsHttpConnectionInfo *aConnInfo);
nsresult ReadSegments(nsAHttpSegmentReader *reader,
uint32_t count, uint32_t *countRead) override final;
nsresult WriteSegments(nsAHttpSegmentWriter *writer,
uint32_t count, uint32_t *countWritten) override final;
MOZ_MUST_USE nsresult ReadSegments(nsAHttpSegmentReader *reader,
uint32_t count,
uint32_t *countRead) override final;
MOZ_MUST_USE nsresult WriteSegments(nsAHttpSegmentWriter *writer,
uint32_t count,
uint32_t *countWritten) override final;
nsHttpRequestHead *RequestHead() override final;
void Close(nsresult reason) override final;
@ -209,7 +212,7 @@ private:
friend class InputStreamShim;
friend class OutputStreamShim;
nsresult Flush(uint32_t count, uint32_t *countRead);
MOZ_MUST_USE nsresult Flush(uint32_t count, uint32_t *countRead);
void CreateShimError(nsresult code);
nsCString mConnectString;

View File

@ -41,23 +41,23 @@ public:
//
// @return failure code to close the transaction.
//
virtual nsresult OnHeadersAvailable(nsAHttpTransaction *,
nsHttpRequestHead *,
nsHttpResponseHead *,
bool *reset) = 0;
virtual MOZ_MUST_USE nsresult OnHeadersAvailable(nsAHttpTransaction *,
nsHttpRequestHead *,
nsHttpResponseHead *,
bool *reset) = 0;
//
// called by a transaction to resume either sending or receiving data
// after a transaction returned NS_BASE_STREAM_WOULD_BLOCK from its
// ReadSegments/WriteSegments methods.
//
virtual nsresult ResumeSend() = 0;
virtual nsresult ResumeRecv() = 0;
virtual MOZ_MUST_USE nsresult ResumeSend() = 0;
virtual MOZ_MUST_USE nsresult ResumeRecv() = 0;
// called by a transaction to force a "send/recv from network" iteration
// even if not scheduled by socket associated with connection
virtual nsresult ForceSend() = 0;
virtual nsresult ForceRecv() = 0;
virtual MOZ_MUST_USE nsresult ForceSend() = 0;
virtual MOZ_MUST_USE nsresult ForceRecv() = 0;
// After a connection has had ResumeSend() called by a transaction,
// and it is ready to write to the network it may need to know the
@ -96,9 +96,9 @@ public:
// get the transport level information for this connection. This may fail
// if it is in use.
virtual nsresult TakeTransport(nsISocketTransport **,
nsIAsyncInputStream **,
nsIAsyncOutputStream **) = 0;
virtual MOZ_MUST_USE nsresult TakeTransport(nsISocketTransport **,
nsIAsyncInputStream **,
nsIAsyncOutputStream **) = 0;
// called by a transaction to get the security info from the socket.
virtual void GetSecurityInfo(nsISupports **) = 0;
@ -113,7 +113,7 @@ public:
// called by a transaction when the transaction reads more from the socket
// than it should have (eg. containing part of the next response).
virtual nsresult PushBack(const char *data, uint32_t length) = 0;
virtual MOZ_MUST_USE nsresult PushBack(const char *data, uint32_t length) = 0;
// Used to determine if the connection wants read events even though
// it has not written out a transaction. Used when a connection has issued
@ -148,15 +148,18 @@ public:
NS_DEFINE_STATIC_IID_ACCESSOR(nsAHttpConnection, NS_AHTTPCONNECTION_IID)
#define NS_DECL_NSAHTTPCONNECTION(fwdObject) \
nsresult OnHeadersAvailable(nsAHttpTransaction *, nsHttpRequestHead *, nsHttpResponseHead *, bool *reset) override; \
MOZ_MUST_USE nsresult OnHeadersAvailable(nsAHttpTransaction *, \
nsHttpRequestHead *, \
nsHttpResponseHead *, \
bool *reset) override; \
void CloseTransaction(nsAHttpTransaction *, nsresult) override; \
nsresult TakeTransport(nsISocketTransport **, \
nsIAsyncInputStream **, \
nsIAsyncOutputStream **) override; \
MOZ_MUST_USE nsresult TakeTransport(nsISocketTransport **, \
nsIAsyncInputStream **, \
nsIAsyncOutputStream **) override; \
bool IsPersistent() override; \
bool IsReused() override; \
void DontReuse() override; \
nsresult PushBack(const char *, uint32_t) override; \
MOZ_MUST_USE nsresult PushBack(const char *, uint32_t) override; \
already_AddRefed<nsHttpConnection> TakeHttpConnection() override; \
/* \
Thes methods below have automatic definitions that just forward the \
@ -179,25 +182,25 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsAHttpConnection, NS_AHTTPCONNECTION_IID)
} \
return (fwdObject)->GetSecurityInfo(result); \
} \
nsresult ResumeSend() override \
MOZ_MUST_USE nsresult ResumeSend() override \
{ \
if (!(fwdObject)) \
return NS_ERROR_FAILURE; \
return (fwdObject)->ResumeSend(); \
} \
nsresult ResumeRecv() override \
MOZ_MUST_USE nsresult ResumeRecv() override \
{ \
if (!(fwdObject)) \
return NS_ERROR_FAILURE; \
return (fwdObject)->ResumeRecv(); \
} \
nsresult ForceSend() override \
MOZ_MUST_USE nsresult ForceSend() override \
{ \
if (!(fwdObject)) \
return NS_ERROR_FAILURE; \
return (fwdObject)->ForceSend(); \
} \
nsresult ForceRecv() override \
MOZ_MUST_USE nsresult ForceRecv() override \
{ \
if (!(fwdObject)) \
return NS_ERROR_FAILURE; \

View File

@ -68,23 +68,27 @@ public:
virtual uint64_t Available() = 0;
// called to read request data from the transaction.
virtual nsresult ReadSegments(nsAHttpSegmentReader *reader,
uint32_t count, uint32_t *countRead) = 0;
virtual MOZ_MUST_USE nsresult ReadSegments(nsAHttpSegmentReader *reader,
uint32_t count,
uint32_t *countRead) = 0;
// called to write response data to the transaction.
virtual nsresult WriteSegments(nsAHttpSegmentWriter *writer,
uint32_t count, uint32_t *countWritten) = 0;
virtual MOZ_MUST_USE nsresult WriteSegments(nsAHttpSegmentWriter *writer,
uint32_t count,
uint32_t *countWritten) = 0;
// These versions of the functions allow the overloader to specify whether or
// not it is safe to call *Segments() in a loop while they return OK.
// The callee should turn again to false if it is not, otherwise leave untouched
virtual nsresult ReadSegmentsAgain(nsAHttpSegmentReader *reader,
uint32_t count, uint32_t *countRead, bool *again)
virtual MOZ_MUST_USE nsresult
ReadSegmentsAgain(nsAHttpSegmentReader *reader, uint32_t count,
uint32_t *countRead, bool *again)
{
return ReadSegments(reader, count, countRead);
}
virtual nsresult WriteSegmentsAgain(nsAHttpSegmentWriter *writer,
uint32_t count, uint32_t *countWritten, bool *again)
virtual MOZ_MUST_USE nsresult
WriteSegmentsAgain(nsAHttpSegmentWriter *writer, uint32_t count,
uint32_t *countWritten, bool *again)
{
return WriteSegments(writer, count, countWritten);
}
@ -112,7 +116,7 @@ public:
// Returns NS_ERROR_ALREADY_OPENED if the subtransactions have been
// at least partially written and cannot be moved.
//
virtual nsresult TakeSubTransactions(
virtual MOZ_MUST_USE nsresult TakeSubTransactions(
nsTArray<RefPtr<nsAHttpTransaction> > &outTransactions) = 0;
// Occasionally the abstract interface has to give way to base implementations
@ -153,7 +157,7 @@ public:
// the connection due to multiplexing. This interface represents such an
// overload. If it returns NS_FAILURE the connection should be considered
// authoritative.
virtual nsresult GetTransactionSecurityInfo(nsISupports **)
virtual MOZ_MUST_USE nsresult GetTransactionSecurityInfo(nsISupports **)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
@ -162,7 +166,7 @@ public:
virtual void ReuseConnectionOnRestartOK(bool) { }
// Returns true if early-data is possible.
virtual bool Do0RTT() {
virtual MOZ_MUST_USE bool Do0RTT() {
return false;
}
// This function will be called when a tls handshake has been finished and
@ -176,7 +180,7 @@ public:
// the transactions out of the session, rewind them all, and start them back
// over as http/1 transactions
// The function will return success or failure of the transaction restart.
virtual nsresult Finish0RTT(bool aRestart, bool aAlpnChanged) {
virtual MOZ_MUST_USE nsresult Finish0RTT(bool aRestart, bool aAlpnChanged) {
return NS_ERROR_NOT_IMPLEMENTED;
}
};
@ -194,14 +198,14 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsAHttpTransaction, NS_AHTTPTRANSACTION_IID)
uint32_t Caps() override; \
void SetDNSWasRefreshed() override; \
uint64_t Available() override; \
virtual nsresult ReadSegments(nsAHttpSegmentReader *, uint32_t, uint32_t *) override; \
virtual nsresult WriteSegments(nsAHttpSegmentWriter *, uint32_t, uint32_t *) override; \
virtual MOZ_MUST_USE nsresult ReadSegments(nsAHttpSegmentReader *, uint32_t, uint32_t *) override; \
virtual MOZ_MUST_USE nsresult WriteSegments(nsAHttpSegmentWriter *, uint32_t, uint32_t *) override; \
virtual void Close(nsresult reason) override; \
nsHttpConnectionInfo *ConnectionInfo() override; \
void SetProxyConnectFailed() override; \
virtual nsHttpRequestHead *RequestHead() override; \
uint32_t Http1xTransactionCount() override; \
nsresult TakeSubTransactions(nsTArray<RefPtr<nsAHttpTransaction> > &outTransactions) override;
MOZ_MUST_USE nsresult TakeSubTransactions(nsTArray<RefPtr<nsAHttpTransaction> > &outTransactions) override;
//-----------------------------------------------------------------------------
// nsAHttpSegmentReader
@ -211,9 +215,9 @@ class nsAHttpSegmentReader
{
public:
// any returned failure code stops segment iteration
virtual nsresult OnReadSegment(const char *segment,
uint32_t count,
uint32_t *countRead) = 0;
virtual MOZ_MUST_USE nsresult OnReadSegment(const char *segment,
uint32_t count,
uint32_t *countRead) = 0;
// Ask the segment reader to commit to accepting size bytes of
// data from subsequent OnReadSegment() calls or throw hard
@ -225,14 +229,15 @@ public:
// (forceCommitment requires a hard failure or OK at this moment.)
//
// SpdySession uses this to make sure frames are atomic.
virtual nsresult CommitToSegmentSize(uint32_t size, bool forceCommitment)
virtual MOZ_MUST_USE nsresult CommitToSegmentSize(uint32_t size,
bool forceCommitment)
{
return NS_ERROR_FAILURE;
}
};
#define NS_DECL_NSAHTTPSEGMENTREADER \
nsresult OnReadSegment(const char *, uint32_t, uint32_t *) override;
MOZ_MUST_USE nsresult OnReadSegment(const char *, uint32_t, uint32_t *) override;
//-----------------------------------------------------------------------------
// nsAHttpSegmentWriter
@ -242,13 +247,13 @@ class nsAHttpSegmentWriter
{
public:
// any returned failure code stops segment iteration
virtual nsresult OnWriteSegment(char *segment,
uint32_t count,
uint32_t *countWritten) = 0;
virtual MOZ_MUST_USE nsresult OnWriteSegment(char *segment,
uint32_t count,
uint32_t *countWritten) = 0;
};
#define NS_DECL_NSAHTTPSEGMENTWRITER \
nsresult OnWriteSegment(char *, uint32_t, uint32_t *) override;
MOZ_MUST_USE nsresult OnWriteSegment(char *, uint32_t, uint32_t *) override;
} // namespace net
} // namespace mozilla

View File

@ -65,7 +65,8 @@ public:
static void Shutdown();
nsresult Init(nsIChannel* aChannel, DataURIHandling aAllowDataURI);
MOZ_MUST_USE nsresult Init(nsIChannel* aChannel,
DataURIHandling aAllowDataURI);
void SetInterceptController(nsINetworkInterceptController* aInterceptController);
@ -77,17 +78,20 @@ private:
static void RemoveFromCorsPreflightCache(nsIURI* aURI,
nsIPrincipal* aRequestingPrincipal);
static nsresult StartCORSPreflight(nsIChannel* aRequestChannel,
nsICorsPreflightCallback* aCallback,
nsTArray<nsCString>& aACUnsafeHeaders,
nsIChannel** aPreflightChannel);
static MOZ_MUST_USE nsresult
StartCORSPreflight(nsIChannel* aRequestChannel,
nsICorsPreflightCallback* aCallback,
nsTArray<nsCString>& aACUnsafeHeaders,
nsIChannel** aPreflightChannel);
~nsCORSListenerProxy();
nsresult UpdateChannel(nsIChannel* aChannel, DataURIHandling aAllowDataURI,
UpdateType aUpdateType);
nsresult CheckRequestApproved(nsIRequest* aRequest);
nsresult CheckPreflightNeeded(nsIChannel* aChannel, UpdateType aUpdateType);
MOZ_MUST_USE nsresult UpdateChannel(nsIChannel* aChannel,
DataURIHandling aAllowDataURI,
UpdateType aUpdateType);
MOZ_MUST_USE nsresult CheckRequestApproved(nsIRequest* aRequest);
MOZ_MUST_USE nsresult CheckPreflightNeeded(nsIChannel* aChannel,
UpdateType aUpdateType);
nsCOMPtr<nsIStreamListener> mOuterListener;
// The principal that originally kicked off the request

View File

@ -120,7 +120,7 @@ struct nsHttpAtom
struct nsHttp
{
static nsresult CreateAtomTable();
static MOZ_MUST_USE nsresult CreateAtomTable();
static void DestroyAtomTable();
// The mutex is valid any time the Atom Table is valid
@ -164,12 +164,13 @@ struct nsHttp
//
// TODO(darin): Replace this with something generic.
//
static bool ParseInt64(const char *input, const char **next,
int64_t *result);
static MOZ_MUST_USE bool ParseInt64(const char *input, const char **next,
int64_t *result);
// Variant on ParseInt64 that expects the input string to contain nothing
// more than the value being parsed.
static inline bool ParseInt64(const char *input, int64_t *result) {
static inline MOZ_MUST_USE bool ParseInt64(const char *input,
int64_t *result) {
const char *next;
return ParseInt64(input, &next, result) && *next == '\0';
}

View File

@ -44,7 +44,8 @@ public:
const char16_t *password)
: mUser(nullptr)
{
Set(domain, user, password);
DebugOnly<nsresult> rv = Set(domain, user, password);
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
~nsHttpAuthIdentity()
{
@ -55,10 +56,13 @@ public:
const char16_t *User() const { return mUser; }
const char16_t *Password() const { return mPass; }
nsresult Set(const char16_t *domain,
const char16_t *user,
const char16_t *password);
nsresult Set(const nsHttpAuthIdentity &other) { return Set(other.mDomain, other.mUser, other.mPass); }
MOZ_MUST_USE nsresult Set(const char16_t *domain,
const char16_t *user,
const char16_t *password);
MOZ_MUST_USE nsresult Set(const nsHttpAuthIdentity &other)
{
return Set(other.mDomain, other.mUser, other.mPass);
}
void Clear();
bool Equals(const nsHttpAuthIdentity &other) const;
@ -88,7 +92,7 @@ public:
const nsHttpAuthIdentity &Identity() const { return mIdent; }
nsresult AddPath(const char *aPath);
MOZ_MUST_USE nsresult AddPath(const char *aPath);
nsCOMPtr<nsISupports> mMetaData;
@ -103,16 +107,17 @@ private:
, mTail(nullptr)
, mRealm(nullptr)
{
Set(path, realm, creds, challenge, ident, metadata);
DebugOnly<nsresult> rv = Set(path, realm, creds, challenge, ident, metadata);
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
~nsHttpAuthEntry();
nsresult Set(const char *path,
const char *realm,
const char *creds,
const char *challenge,
const nsHttpAuthIdentity *ident,
nsISupports *metadata);
MOZ_MUST_USE nsresult Set(const char *path,
const char *realm,
const char *creds,
const char *challenge,
const nsHttpAuthIdentity *ident,
nsISupports *metadata);
nsHttpAuthIdentity mIdent;
@ -147,12 +152,12 @@ private:
nsHttpAuthEntry *LookupEntryByRealm(const char *realm);
// if a matching entry is found, then credentials will be changed.
nsresult SetAuthEntry(const char *path,
const char *realm,
const char *credentials,
const char *challenge,
const nsHttpAuthIdentity *ident,
nsISupports *metadata);
MOZ_MUST_USE nsresult SetAuthEntry(const char *path,
const char *realm,
const char *credentials,
const char *challenge,
const nsHttpAuthIdentity *ident,
nsISupports *metadata);
void ClearAuthEntry(const char *realm);
@ -175,43 +180,43 @@ public:
nsHttpAuthCache();
~nsHttpAuthCache();
nsresult Init();
MOZ_MUST_USE nsresult Init();
// |scheme|, |host|, and |port| are required
// |path| can be null
// |entry| is either null or a weak reference
nsresult GetAuthEntryForPath(const char *scheme,
const char *host,
int32_t port,
const char *path,
nsACString const &originSuffix,
nsHttpAuthEntry **entry);
MOZ_MUST_USE nsresult GetAuthEntryForPath(const char *scheme,
const char *host,
int32_t port,
const char *path,
nsACString const &originSuffix,
nsHttpAuthEntry **entry);
// |scheme|, |host|, and |port| are required
// |realm| must not be null
// |entry| is either null or a weak reference
nsresult GetAuthEntryForDomain(const char *scheme,
const char *host,
int32_t port,
const char *realm,
nsACString const &originSuffix,
nsHttpAuthEntry **entry);
MOZ_MUST_USE nsresult GetAuthEntryForDomain(const char *scheme,
const char *host,
int32_t port,
const char *realm,
nsACString const &originSuffix,
nsHttpAuthEntry **entry);
// |scheme|, |host|, and |port| are required
// |path| can be null
// |realm| must not be null
// if |credentials|, |user|, |pass|, and |challenge| are each
// null, then the entry is deleted.
nsresult SetAuthEntry(const char *scheme,
const char *host,
int32_t port,
const char *directory,
const char *realm,
const char *credentials,
const char *challenge,
nsACString const &originSuffix,
const nsHttpAuthIdentity *ident,
nsISupports *metadata);
MOZ_MUST_USE nsresult SetAuthEntry(const char *scheme,
const char *host,
int32_t port,
const char *directory,
const char *realm,
const char *credentials,
const char *challenge,
nsACString const &originSuffix,
const nsHttpAuthIdentity *ident,
nsISupports *metadata);
void ClearAuthEntry(const char *scheme,
const char *host,
@ -220,7 +225,7 @@ public:
nsACString const &originSuffix);
// expire all existing auth list entries including proxy auths.
nsresult ClearAll();
MOZ_MUST_USE nsresult ClearAll();
private:
nsHttpAuthNode *LookupAuthNode(const char *scheme,

View File

@ -20,7 +20,7 @@ public:
NS_DECL_NSIHTTPAUTHMANAGER
nsHttpAuthManager();
nsresult Init();
MOZ_MUST_USE nsresult Init();
protected:
virtual ~nsHttpAuthManager();

View File

@ -44,8 +44,9 @@ class Http2PushedStream;
class HttpChannelSecurityWarningReporter
{
public:
virtual nsresult ReportSecurityMessage(const nsAString& aMessageTag,
const nsAString& aMessageCategory) = 0;
virtual MOZ_MUST_USE nsresult
ReportSecurityMessage(const nsAString& aMessageTag,
const nsAString& aMessageCategory) = 0;
};
//-----------------------------------------------------------------------------
@ -127,12 +128,14 @@ public:
nsHttpChannel();
virtual nsresult Init(nsIURI *aURI, uint32_t aCaps, nsProxyInfo *aProxyInfo,
uint32_t aProxyResolveFlags,
nsIURI *aProxyURI,
const nsID& aChannelId) override;
virtual MOZ_MUST_USE nsresult Init(nsIURI *aURI, uint32_t aCaps,
nsProxyInfo *aProxyInfo,
uint32_t aProxyResolveFlags,
nsIURI *aProxyURI,
const nsID& aChannelId) override;
nsresult OnPush(const nsACString &uri, Http2PushedStream *pushedStream);
MOZ_MUST_USE nsresult OnPush(const nsACString &uri,
Http2PushedStream *pushedStream);
static bool IsRedirectStatus(uint32_t status);
@ -176,8 +179,9 @@ public:
NS_IMETHOD OnPreflightSucceeded() override;
NS_IMETHOD OnPreflightFailed(nsresult aError) override;
nsresult AddSecurityMessage(const nsAString& aMessageTag,
const nsAString& aMessageCategory) override;
MOZ_MUST_USE nsresult
AddSecurityMessage(const nsAString& aMessageTag,
const nsAString& aMessageCategory) override;
void SetWarningReporter(HttpChannelSecurityWarningReporter* aReporter)
{ mWarningReporter = aReporter; }
@ -189,18 +193,18 @@ public: /* internal necko use only */
void SetUploadStreamHasHeaders(bool hasHeaders)
{ mUploadStreamHasHeaders = hasHeaders; }
nsresult SetReferrerWithPolicyInternal(nsIURI *referrer,
uint32_t referrerPolicy) {
MOZ_MUST_USE nsresult
SetReferrerWithPolicyInternal(nsIURI *referrer, uint32_t referrerPolicy) {
nsAutoCString spec;
nsresult rv = referrer->GetAsciiSpec(spec);
if (NS_FAILED(rv)) return rv;
mReferrer = referrer;
mReferrerPolicy = referrerPolicy;
mRequestHead.SetHeader(nsHttp::Referer, spec);
return NS_OK;
rv = mRequestHead.SetHeader(nsHttp::Referer, spec);
return rv;
}
nsresult SetTopWindowURI(nsIURI* aTopWindowURI) {
MOZ_MUST_USE nsresult SetTopWindowURI(nsIURI* aTopWindowURI) {
mTopWindowURI = aTopWindowURI;
return NS_OK;
}
@ -210,13 +214,13 @@ public: /* internal necko use only */
return mRequestTime;
}
nsresult OpenCacheEntry(bool usingSSL);
nsresult ContinueConnect();
MOZ_MUST_USE nsresult OpenCacheEntry(bool usingSSL);
MOZ_MUST_USE nsresult ContinueConnect();
// If the load is mixed-content, build and send an HSTS priming request.
nsresult TryHSTSPriming();
MOZ_MUST_USE nsresult TryHSTSPriming();
nsresult StartRedirectChannelToURI(nsIURI *, uint32_t);
MOZ_MUST_USE nsresult StartRedirectChannelToURI(nsIURI *, uint32_t);
// This allows cache entry to be marked as foreign even after channel itself
// is gone. Needed for e10s (see HttpChannelParent::RecvDocumentChannelCleanup)
@ -289,87 +293,88 @@ private:
typedef nsresult (nsHttpChannel::*nsContinueRedirectionFunc)(nsresult result);
bool RequestIsConditional();
nsresult BeginConnect();
nsresult ContinueBeginConnectWithResult();
MOZ_MUST_USE nsresult BeginConnect();
MOZ_MUST_USE nsresult ContinueBeginConnectWithResult();
void ContinueBeginConnect();
nsresult Connect();
MOZ_MUST_USE nsresult Connect();
void SpeculativeConnect();
nsresult SetupTransaction();
MOZ_MUST_USE nsresult SetupTransaction();
void SetupTransactionRequestContext();
nsresult CallOnStartRequest();
nsresult ProcessResponse();
void AsyncContinueProcessResponse();
nsresult ContinueProcessResponse1();
nsresult ContinueProcessResponse2(nsresult);
nsresult ContinueProcessResponse3(nsresult);
nsresult ProcessNormal();
nsresult ContinueProcessNormal(nsresult);
MOZ_MUST_USE nsresult CallOnStartRequest();
MOZ_MUST_USE nsresult ProcessResponse();
void AsyncContinueProcessResponse();
MOZ_MUST_USE nsresult ContinueProcessResponse1();
MOZ_MUST_USE nsresult ContinueProcessResponse2(nsresult);
MOZ_MUST_USE nsresult ContinueProcessResponse3(nsresult);
MOZ_MUST_USE nsresult ProcessNormal();
MOZ_MUST_USE nsresult ContinueProcessNormal(nsresult);
void ProcessAltService();
bool ShouldBypassProcessNotModified();
nsresult ProcessNotModified();
nsresult AsyncProcessRedirection(uint32_t httpStatus);
nsresult ContinueProcessRedirection(nsresult);
nsresult ContinueProcessRedirectionAfterFallback(nsresult);
nsresult ProcessFailedProxyConnect(uint32_t httpStatus);
nsresult ProcessFallback(bool *waitingForRedirectCallback);
nsresult ContinueProcessFallback(nsresult);
MOZ_MUST_USE nsresult ProcessNotModified();
MOZ_MUST_USE nsresult AsyncProcessRedirection(uint32_t httpStatus);
MOZ_MUST_USE nsresult ContinueProcessRedirection(nsresult);
MOZ_MUST_USE nsresult ContinueProcessRedirectionAfterFallback(nsresult);
MOZ_MUST_USE nsresult ProcessFailedProxyConnect(uint32_t httpStatus);
MOZ_MUST_USE nsresult ProcessFallback(bool *waitingForRedirectCallback);
MOZ_MUST_USE nsresult ContinueProcessFallback(nsresult);
void HandleAsyncAbort();
nsresult EnsureAssocReq();
MOZ_MUST_USE nsresult EnsureAssocReq();
void ProcessSSLInformation();
bool IsHTTPS();
nsresult ContinueOnStartRequest1(nsresult);
nsresult ContinueOnStartRequest2(nsresult);
nsresult ContinueOnStartRequest3(nsresult);
MOZ_MUST_USE nsresult ContinueOnStartRequest1(nsresult);
MOZ_MUST_USE nsresult ContinueOnStartRequest2(nsresult);
MOZ_MUST_USE nsresult ContinueOnStartRequest3(nsresult);
// redirection specific methods
void HandleAsyncRedirect();
void HandleAsyncAPIRedirect();
nsresult ContinueHandleAsyncRedirect(nsresult);
MOZ_MUST_USE nsresult ContinueHandleAsyncRedirect(nsresult);
void HandleAsyncNotModified();
void HandleAsyncFallback();
nsresult ContinueHandleAsyncFallback(nsresult);
nsresult PromptTempRedirect();
virtual nsresult SetupReplacementChannel(nsIURI *, nsIChannel *,
bool preserveMethod,
uint32_t redirectFlags) override;
MOZ_MUST_USE nsresult ContinueHandleAsyncFallback(nsresult);
MOZ_MUST_USE nsresult PromptTempRedirect();
virtual MOZ_MUST_USE nsresult
SetupReplacementChannel(nsIURI *, nsIChannel *, bool preserveMethod,
uint32_t redirectFlags) override;
// proxy specific methods
nsresult ProxyFailover();
nsresult AsyncDoReplaceWithProxy(nsIProxyInfo *);
nsresult ContinueDoReplaceWithProxy(nsresult);
nsresult ResolveProxy();
MOZ_MUST_USE nsresult ProxyFailover();
MOZ_MUST_USE nsresult AsyncDoReplaceWithProxy(nsIProxyInfo *);
MOZ_MUST_USE nsresult ContinueDoReplaceWithProxy(nsresult);
MOZ_MUST_USE nsresult ResolveProxy();
// cache specific methods
nsresult OnOfflineCacheEntryAvailable(nsICacheEntry *aEntry,
bool aNew,
nsIApplicationCache* aAppCache,
nsresult aResult);
nsresult OnNormalCacheEntryAvailable(nsICacheEntry *aEntry,
bool aNew,
nsresult aResult);
nsresult OpenOfflineCacheEntryForWriting();
nsresult OnOfflineCacheEntryForWritingAvailable(nsICacheEntry *aEntry,
nsIApplicationCache* aAppCache,
nsresult aResult);
nsresult OnCacheEntryAvailableInternal(nsICacheEntry *entry,
bool aNew,
nsIApplicationCache* aAppCache,
nsresult status);
nsresult GenerateCacheKey(uint32_t postID, nsACString &key);
nsresult UpdateExpirationTime();
nsresult CheckPartial(nsICacheEntry* aEntry, int64_t *aSize, int64_t *aContentLength);
MOZ_MUST_USE nsresult
OnOfflineCacheEntryAvailable(nsICacheEntry *aEntry, bool aNew,
nsIApplicationCache* aAppCache,
nsresult aResult);
MOZ_MUST_USE nsresult OnNormalCacheEntryAvailable(nsICacheEntry *aEntry,
bool aNew,
nsresult aResult);
MOZ_MUST_USE nsresult OpenOfflineCacheEntryForWriting();
MOZ_MUST_USE nsresult
OnOfflineCacheEntryForWritingAvailable(nsICacheEntry *aEntry,
nsIApplicationCache* aAppCache,
nsresult aResult);
MOZ_MUST_USE nsresult
OnCacheEntryAvailableInternal(nsICacheEntry *entry, bool aNew,
nsIApplicationCache* aAppCache,
nsresult status);
MOZ_MUST_USE nsresult GenerateCacheKey(uint32_t postID, nsACString &key);
MOZ_MUST_USE nsresult UpdateExpirationTime();
MOZ_MUST_USE nsresult CheckPartial(nsICacheEntry* aEntry, int64_t *aSize, int64_t *aContentLength);
bool ShouldUpdateOfflineCacheEntry();
nsresult ReadFromCache(bool alreadyMarkedValid);
MOZ_MUST_USE nsresult ReadFromCache(bool alreadyMarkedValid);
void CloseCacheEntry(bool doomOnFailure);
void CloseOfflineCacheEntry();
nsresult InitCacheEntry();
MOZ_MUST_USE nsresult InitCacheEntry();
void UpdateInhibitPersistentCachingFlag();
nsresult InitOfflineCacheEntry();
nsresult AddCacheEntryHeaders(nsICacheEntry *entry);
nsresult FinalizeCacheEntry();
nsresult InstallCacheListener(int64_t offset = 0);
nsresult InstallOfflineCacheListener(int64_t offset = 0);
MOZ_MUST_USE nsresult InitOfflineCacheEntry();
MOZ_MUST_USE nsresult AddCacheEntryHeaders(nsICacheEntry *entry);
MOZ_MUST_USE nsresult FinalizeCacheEntry();
MOZ_MUST_USE nsresult InstallCacheListener(int64_t offset = 0);
MOZ_MUST_USE nsresult InstallOfflineCacheListener(int64_t offset = 0);
void MaybeInvalidateCacheEntryForSubsequentGet();
void AsyncOnExamineCachedResponse();
@ -377,15 +382,15 @@ private:
void ClearBogusContentEncodingIfNeeded();
// byte range request specific methods
nsresult ProcessPartialContent();
nsresult OnDoneReadingPartialCacheEntry(bool *streamDone);
MOZ_MUST_USE nsresult ProcessPartialContent();
MOZ_MUST_USE nsresult OnDoneReadingPartialCacheEntry(bool *streamDone);
nsresult DoAuthRetry(nsAHttpConnection *);
MOZ_MUST_USE nsresult DoAuthRetry(nsAHttpConnection *);
void HandleAsyncRedirectChannelToHttps();
nsresult StartRedirectChannelToHttps();
nsresult ContinueAsyncRedirectChannelToURI(nsresult rv);
nsresult OpenRedirectChannel(nsresult rv);
MOZ_MUST_USE nsresult StartRedirectChannelToHttps();
MOZ_MUST_USE nsresult ContinueAsyncRedirectChannelToURI(nsresult rv);
MOZ_MUST_USE nsresult OpenRedirectChannel(nsresult rv);
/**
* A function that takes care of reading STS and PKP headers and enforcing
@ -393,7 +398,7 @@ private:
* requires the channel to be trusted or any STS or PKP header data on
* the channel is ignored. This is called from ProcessResponse.
*/
nsresult ProcessSecurityHeaders();
MOZ_MUST_USE nsresult ProcessSecurityHeaders();
/**
* Taking care of the Content-Signature header and fail the channel if
@ -404,7 +409,8 @@ private:
* successful, the load proceeds as usual. If the verification fails, a
* NS_ERROR_INVALID_SIGNATURE is thrown and a fallback loaded in nsDocShell
*/
nsresult ProcessContentSignatureHeader(nsHttpResponseHead *aResponseHead);
MOZ_MUST_USE nsresult
ProcessContentSignatureHeader(nsHttpResponseHead *aResponseHead);
/**
* A function that will, if the feature is enabled, send security reports.
@ -416,13 +422,13 @@ private:
* some basic sanity checks have been applied to the channel. Called
* from ProcessSecurityHeaders.
*/
nsresult ProcessSingleSecurityHeader(uint32_t aType,
nsISSLStatus *aSSLStatus,
uint32_t aFlags);
MOZ_MUST_USE nsresult ProcessSingleSecurityHeader(uint32_t aType,
nsISSLStatus *aSSLStatus,
uint32_t aFlags);
void InvalidateCacheEntryForLocation(const char *location);
void AssembleCacheKey(const char *spec, uint32_t postID, nsACString &key);
nsresult CreateNewURI(const char *loc, nsIURI **newURI);
MOZ_MUST_USE nsresult CreateNewURI(const char *loc, nsIURI **newURI);
void DoInvalidateCacheEntry(nsIURI* aURI);
// Ref RFC2616 13.10: "invalidation... MUST only be performed if
@ -453,13 +459,15 @@ private:
bool ResponseWouldVary(nsICacheEntry* entry);
bool IsResumable(int64_t partialLen, int64_t contentLength,
bool ignoreMissingPartialLen = false) const;
nsresult MaybeSetupByteRangeRequest(int64_t partialLen, int64_t contentLength,
bool ignoreMissingPartialLen = false);
nsresult SetupByteRangeRequest(int64_t partialLen);
MOZ_MUST_USE nsresult
MaybeSetupByteRangeRequest(int64_t partialLen, int64_t contentLength,
bool ignoreMissingPartialLen = false);
MOZ_MUST_USE nsresult SetupByteRangeRequest(int64_t partialLen);
void UntieByteRangeRequest();
void UntieValidationRequest();
nsresult OpenCacheInputStream(nsICacheEntry* cacheEntry, bool startBuffering,
bool checkingAppCacheEntry);
MOZ_MUST_USE nsresult OpenCacheInputStream(nsICacheEntry* cacheEntry,
bool startBuffering,
bool checkingAppCacheEntry);
void SetPushedStream(Http2PushedStream *stream);
@ -604,7 +612,7 @@ private:
// tracking (if tracking protection is enabled) blocklist
bool mLocalBlocklist;
nsresult WaitForRedirectCallback();
MOZ_MUST_USE nsresult WaitForRedirectCallback();
void PushRedirectAsyncFunc(nsContinueRedirectionFunc func);
void PopRedirectAsyncFunc(nsContinueRedirectionFunc func);

View File

@ -54,15 +54,16 @@ private:
bool UsingHttpProxy() const
{ return mProxyInfo && (mProxyInfo->IsHTTP() || mProxyInfo->IsHTTPS()); }
nsresult PrepareForAuthentication(bool proxyAuth);
nsresult GenCredsAndSetEntry(nsIHttpAuthenticator *, bool proxyAuth,
const char *scheme, const char *host,
int32_t port, const char *dir,
const char *realm, const char *challenge,
const nsHttpAuthIdentity &ident,
nsCOMPtr<nsISupports> &session, char **result);
nsresult GetAuthenticator(const char *challenge, nsCString &scheme,
nsIHttpAuthenticator **auth);
MOZ_MUST_USE nsresult PrepareForAuthentication(bool proxyAuth);
MOZ_MUST_USE nsresult
GenCredsAndSetEntry(nsIHttpAuthenticator *, bool proxyAuth,
const char *scheme, const char *host, int32_t port,
const char *dir, const char *realm,
const char *challenge, const nsHttpAuthIdentity &ident,
nsCOMPtr<nsISupports> &session, char **result);
MOZ_MUST_USE nsresult GetAuthenticator(const char *challenge,
nsCString &scheme,
nsIHttpAuthenticator **auth);
void ParseRealm(const char *challenge, nsACString &realm);
void GetIdentityFromURI(uint32_t authFlags, nsHttpAuthIdentity&);
@ -72,40 +73,42 @@ private:
* the user's decision will be gathered in a callback and is not an actual
* error.
*/
nsresult GetCredentials(const char *challenges, bool proxyAuth,
nsAFlatCString &creds);
nsresult GetCredentialsForChallenge(const char *challenge,
const char *scheme, bool proxyAuth,
nsIHttpAuthenticator *auth,
nsAFlatCString &creds);
nsresult PromptForIdentity(uint32_t level, bool proxyAuth,
const char *realm, const char *authType,
uint32_t authFlags, nsHttpAuthIdentity &);
MOZ_MUST_USE nsresult GetCredentials(const char *challenges, bool proxyAuth,
nsAFlatCString &creds);
MOZ_MUST_USE nsresult
GetCredentialsForChallenge(const char *challenge, const char *scheme,
bool proxyAuth, nsIHttpAuthenticator *auth,
nsAFlatCString &creds);
MOZ_MUST_USE nsresult PromptForIdentity(uint32_t level, bool proxyAuth,
const char *realm,
const char *authType,
uint32_t authFlags,
nsHttpAuthIdentity &);
bool ConfirmAuth(const nsString &bundleKey, bool doYesNoPrompt);
void SetAuthorizationHeader(nsHttpAuthCache *, nsHttpAtom header,
const char *scheme, const char *host,
int32_t port, const char *path,
nsHttpAuthIdentity &ident);
nsresult GetCurrentPath(nsACString &);
MOZ_MUST_USE nsresult GetCurrentPath(nsACString &);
/**
* Return all information needed to build authorization information,
* all parameters except proxyAuth are out parameters. proxyAuth specifies
* with what authorization we work (WWW or proxy).
*/
nsresult GetAuthorizationMembers(bool proxyAuth, nsCSubstring& scheme,
const char*& host, int32_t& port,
nsCSubstring& path,
nsHttpAuthIdentity*& ident,
nsISupports**& continuationState);
MOZ_MUST_USE nsresult
GetAuthorizationMembers(bool proxyAuth, nsCSubstring& scheme,
const char*& host, int32_t& port,
nsCSubstring& path, nsHttpAuthIdentity*& ident,
nsISupports**& continuationState);
/**
* Method called to resume suspended transaction after we got credentials
* from the user. Called from OnAuthAvailable callback or OnAuthCancelled
* when credentials for next challenge were obtained synchronously.
*/
nsresult ContinueOnAuthAvailable(const nsCSubstring& creds);
MOZ_MUST_USE nsresult ContinueOnAuthAvailable(const nsCSubstring& creds);
nsresult DoRedirectChannelToHttps();
MOZ_MUST_USE nsresult DoRedirectChannelToHttps();
/**
* A function that takes care of reading STS headers and enforcing STS
@ -113,7 +116,7 @@ private:
* to be trusted or any STS header data on the channel is ignored.
* This is called from ProcessResponse.
*/
nsresult ProcessSTSHeader();
MOZ_MUST_USE nsresult ProcessSTSHeader();
// Depending on the pref setting, the authentication dialog may be blocked
// for all sub-resources, blocked for cross-origin sub-resources, or
@ -122,17 +125,17 @@ private:
bool BlockPrompt();
// Store credentials to the cache when appropriate aFlags are set.
nsresult UpdateCache(nsIHttpAuthenticator *aAuth,
const char *aScheme,
const char *aHost,
int32_t aPort,
const char *aDirectory,
const char *aRealm,
const char *aChallenge,
const nsHttpAuthIdentity &aIdent,
const char *aCreds,
uint32_t aGenerateFlags,
nsISupports *aSessionState);
MOZ_MUST_USE nsresult UpdateCache(nsIHttpAuthenticator *aAuth,
const char *aScheme,
const char *aHost,
int32_t aPort,
const char *aDirectory,
const char *aRealm,
const char *aChallenge,
const nsHttpAuthIdentity &aIdent,
const char *aCreds,
uint32_t aGenerateFlags,
nsISupports *aSessionState);
private:
nsIHttpAuthenticableChannel *mAuthChannel; // weak ref

View File

@ -24,10 +24,10 @@ public:
bool ReachedEOF() { return mReachedEOF; }
// called by the transaction to handle chunked content.
nsresult HandleChunkedContent(char *buf,
uint32_t count,
uint32_t *contentRead,
uint32_t *contentRemaining);
MOZ_MUST_USE nsresult HandleChunkedContent(char *buf,
uint32_t count,
uint32_t *contentRead,
uint32_t *contentRemaining);
nsHttpHeaderArray *Trailers() { return mTrailers; }
@ -38,9 +38,9 @@ public:
uint32_t GetChunkRemaining() { return mChunkRemaining; }
private:
nsresult ParseChunkRemaining(char *buf,
uint32_t count,
uint32_t *countRead);
MOZ_MUST_USE nsresult ParseChunkRemaining(char *buf,
uint32_t count,
uint32_t *countRead);
private:
nsHttpHeaderArray *mTrailers;

View File

@ -66,15 +66,16 @@ public:
// maxHangTime - limits the amount of time this connection can spend on a
// single transaction before it should no longer be kept
// alive. a value of 0xffff indicates no limit.
nsresult Init(nsHttpConnectionInfo *info, uint16_t maxHangTime,
nsISocketTransport *, nsIAsyncInputStream *,
nsIAsyncOutputStream *, bool connectedTransport,
nsIInterfaceRequestor *, PRIntervalTime);
MOZ_MUST_USE nsresult Init(nsHttpConnectionInfo *info, uint16_t maxHangTime,
nsISocketTransport *, nsIAsyncInputStream *,
nsIAsyncOutputStream *, bool connectedTransport,
nsIInterfaceRequestor *, PRIntervalTime);
// Activate causes the given transaction to be processed on this
// connection. It fails if there is already an existing transaction unless
// a multiplexing protocol such as SPDY is being used
nsresult Activate(nsAHttpTransaction *, uint32_t caps, int32_t pri);
MOZ_MUST_USE nsresult Activate(nsAHttpTransaction *, uint32_t caps,
int32_t pri);
// Close the underlying socket transport.
void Close(nsresult reason, bool aIsShutdown = false);
@ -126,28 +127,32 @@ public:
nsHttpConnectionInfo *ConnectionInfo() { return mConnInfo; }
// nsAHttpConnection compatible methods (non-virtual):
nsresult OnHeadersAvailable(nsAHttpTransaction *, nsHttpRequestHead *, nsHttpResponseHead *, bool *reset);
void CloseTransaction(nsAHttpTransaction *, nsresult reason, bool aIsShutdown = false);
MOZ_MUST_USE nsresult OnHeadersAvailable(nsAHttpTransaction *,
nsHttpRequestHead *,
nsHttpResponseHead *, bool *reset);
void CloseTransaction(nsAHttpTransaction *, nsresult reason,
bool aIsShutdown = false);
void GetConnectionInfo(nsHttpConnectionInfo **ci) { NS_IF_ADDREF(*ci = mConnInfo); }
nsresult TakeTransport(nsISocketTransport **,
nsIAsyncInputStream **,
nsIAsyncOutputStream **);
MOZ_MUST_USE nsresult TakeTransport(nsISocketTransport **,
nsIAsyncInputStream **,
nsIAsyncOutputStream **);
void GetSecurityInfo(nsISupports **);
bool IsPersistent() { return IsKeepAlive() && !mDontReuse; }
bool IsReused();
void SetIsReusedAfter(uint32_t afterMilliseconds);
nsresult PushBack(const char *data, uint32_t length);
nsresult ResumeSend();
nsresult ResumeRecv();
MOZ_MUST_USE nsresult PushBack(const char *data, uint32_t length);
MOZ_MUST_USE nsresult ResumeSend();
MOZ_MUST_USE nsresult ResumeRecv();
int64_t MaxBytesRead() {return mMaxBytesRead;}
uint8_t GetLastHttpResponseVersion() { return mLastHttpResponseVersion; }
friend class HttpConnectionForceIO;
nsresult ForceSend();
nsresult ForceRecv();
MOZ_MUST_USE nsresult ForceSend();
MOZ_MUST_USE nsresult ForceRecv();
static nsresult ReadFromStream(nsIInputStream *, void *, const char *,
uint32_t, uint32_t, uint32_t *);
static MOZ_MUST_USE nsresult ReadFromStream(nsIInputStream *, void *,
const char *, uint32_t,
uint32_t, uint32_t *);
// When a persistent connection is in the connection manager idle
// connection pool, the nsHttpConnection still reads errors and hangups
@ -191,9 +196,9 @@ public:
// non null HTTP transaction of any version.
bool IsExperienced() { return mExperienced; }
static nsresult MakeConnectString(nsAHttpTransaction *trans,
nsHttpRequestHead *request,
nsACString &result);
static MOZ_MUST_USE nsresult MakeConnectString(nsAHttpTransaction *trans,
nsHttpRequestHead *request,
nsACString &result);
void SetupSecondaryTLS();
void SetInSpdyTunnel(bool arg);
@ -220,22 +225,23 @@ private:
};
// called to cause the underlying socket to start speaking SSL
nsresult InitSSLParams(bool connectingToProxy, bool ProxyStartSSL);
nsresult SetupNPNList(nsISSLSocketControl *ssl, uint32_t caps);
MOZ_MUST_USE nsresult InitSSLParams(bool connectingToProxy,
bool ProxyStartSSL);
MOZ_MUST_USE nsresult SetupNPNList(nsISSLSocketControl *ssl, uint32_t caps);
nsresult OnTransactionDone(nsresult reason);
nsresult OnSocketWritable();
nsresult OnSocketReadable();
MOZ_MUST_USE nsresult OnTransactionDone(nsresult reason);
MOZ_MUST_USE nsresult OnSocketWritable();
MOZ_MUST_USE nsresult OnSocketReadable();
nsresult SetupProxyConnect();
MOZ_MUST_USE nsresult SetupProxyConnect();
PRIntervalTime IdleTime();
bool IsAlive();
// Makes certain the SSL handshake is complete and NPN negotiation
// has had a chance to happen
bool EnsureNPNComplete(nsresult &aOut0RTTWriteHandshakeValue,
uint32_t &aOut0RTTBytesWritten);
MOZ_MUST_USE bool EnsureNPNComplete(nsresult &aOut0RTTWriteHandshakeValue,
uint32_t &aOut0RTTBytesWritten);
void SetupSSL();
// Start the Spdy transaction handler when NPN indicates spdy/*
@ -249,13 +255,13 @@ private:
nsresult MoveTransactionsToSpdy(nsresult status, nsTArray<RefPtr<nsAHttpTransaction> > &list);
// Directly Add a transaction to an active connection for SPDY
nsresult AddTransaction(nsAHttpTransaction *, int32_t);
MOZ_MUST_USE nsresult AddTransaction(nsAHttpTransaction *, int32_t);
// Used to set TCP keepalives for fast detection of dead connections during
// an initial period, and slower detection for long-lived connections.
nsresult StartShortLivedTCPKeepalives();
nsresult StartLongLivedTCPKeepalives();
nsresult DisableTCPKeepalives();
MOZ_MUST_USE nsresult StartShortLivedTCPKeepalives();
MOZ_MUST_USE nsresult StartLongLivedTCPKeepalives();
MOZ_MUST_USE nsresult DisableTCPKeepalives();
private:
nsCOMPtr<nsISocketTransport> mSocketTransport;
@ -351,7 +357,7 @@ private:
private:
// For ForceSend()
static void ForceSendIO(nsITimer *aTimer, void *aClosure);
nsresult MaybeForceSendIO();
MOZ_MUST_USE nsresult MaybeForceSendIO();
bool mForceSendPending;
nsCOMPtr<nsITimer> mForceSendTimer;

View File

@ -82,7 +82,7 @@ public:
// OK to treat these as an infalible allocation
nsHttpConnectionInfo* Clone() const;
void CloneAsDirectRoute(nsHttpConnectionInfo **outParam);
nsresult CreateWildCard(nsHttpConnectionInfo **outParam);
MOZ_MUST_USE nsresult CreateWildCard(nsHttpConnectionInfo **outParam);
const char *ProxyHost() const { return mProxyInfo ? mProxyInfo->Host().get() : nullptr; }
int32_t ProxyPort() const { return mProxyInfo ? mProxyInfo->Port() : -1; }

View File

@ -57,11 +57,11 @@ public:
nsHttpConnectionMgr();
nsresult Init(uint16_t maxConnections,
uint16_t maxPersistentConnectionsPerHost,
uint16_t maxPersistentConnectionsPerProxy,
uint16_t maxRequestDelay);
nsresult Shutdown();
MOZ_MUST_USE nsresult Init(uint16_t maxConnections,
uint16_t maxPersistentConnectionsPerHost,
uint16_t maxPersistentConnectionsPerProxy,
uint16_t maxRequestDelay);
MOZ_MUST_USE nsresult Shutdown();
//-------------------------------------------------------------------------
// NOTE: functions below may be called on any thread.
@ -80,36 +80,39 @@ public:
void ConditionallyStopTimeoutTick();
// adds a transaction to the list of managed transactions.
nsresult AddTransaction(nsHttpTransaction *, int32_t priority);
MOZ_MUST_USE nsresult AddTransaction(nsHttpTransaction *, int32_t priority);
// called to reschedule the given transaction. it must already have been
// added to the connection manager via AddTransaction.
nsresult RescheduleTransaction(nsHttpTransaction *, int32_t priority);
MOZ_MUST_USE nsresult RescheduleTransaction(nsHttpTransaction *,
int32_t priority);
// cancels a transaction w/ the given reason.
nsresult CancelTransaction(nsHttpTransaction *, nsresult reason);
nsresult CancelTransactions(nsHttpConnectionInfo *, nsresult reason);
MOZ_MUST_USE nsresult CancelTransaction(nsHttpTransaction *,
nsresult reason);
MOZ_MUST_USE nsresult CancelTransactions(nsHttpConnectionInfo *,
nsresult reason);
// called to force the connection manager to prune its list of idle
// connections.
nsresult PruneDeadConnections();
MOZ_MUST_USE nsresult PruneDeadConnections();
// called to close active connections with no registered "traffic"
nsresult PruneNoTraffic();
MOZ_MUST_USE nsresult PruneNoTraffic();
// "VerifyTraffic" means marking connections now, and then check again in
// N seconds to see if there's been any traffic and if not, kill
// that connection.
nsresult VerifyTraffic();
MOZ_MUST_USE nsresult VerifyTraffic();
// Close all idle persistent connections and prevent any active connections
// from being reused. Optional connection info resets CI specific
// information such as Happy Eyeballs history.
nsresult DoShiftReloadConnectionCleanup(nsHttpConnectionInfo *);
MOZ_MUST_USE nsresult DoShiftReloadConnectionCleanup(nsHttpConnectionInfo *);
// called to get a reference to the socket transport service. the socket
// transport service is not available when the connection manager is down.
nsresult GetSocketThreadTarget(nsIEventTarget **);
MOZ_MUST_USE nsresult GetSocketThreadTarget(nsIEventTarget **);
// called to indicate a transaction for the connectionInfo is likely coming
// soon. The connection manager may use this information to start a TCP
@ -117,33 +120,34 @@ public:
// ready when the transaction is submitted. No obligation is taken on by the
// connection manager, nor is the submitter obligated to actually submit a
// real transaction for this connectionInfo.
nsresult SpeculativeConnect(nsHttpConnectionInfo *,
nsIInterfaceRequestor *,
uint32_t caps = 0,
NullHttpTransaction * = nullptr);
MOZ_MUST_USE nsresult SpeculativeConnect(nsHttpConnectionInfo *,
nsIInterfaceRequestor *,
uint32_t caps = 0,
NullHttpTransaction * = nullptr);
// called when a connection is done processing a transaction. if the
// connection can be reused then it will be added to the idle list, else
// it will be closed.
nsresult ReclaimConnection(nsHttpConnection *conn);
MOZ_MUST_USE nsresult ReclaimConnection(nsHttpConnection *conn);
// called by the main thread to execute the taketransport() logic on the
// socket thread after a 101 response has been received and the socket
// needs to be transferred to an expectant upgrade listener such as
// websockets.
nsresult CompleteUpgrade(nsAHttpConnection *aConn,
nsIHttpUpgradeListener *aUpgradeListener);
MOZ_MUST_USE nsresult
CompleteUpgrade(nsAHttpConnection *aConn,
nsIHttpUpgradeListener *aUpgradeListener);
// called to update a parameter after the connection manager has already
// been initialized.
nsresult UpdateParam(nsParamName name, uint16_t value);
MOZ_MUST_USE nsresult UpdateParam(nsParamName name, uint16_t value);
// called from main thread to post a new request token bucket
// to the socket thread
nsresult UpdateRequestTokenBucket(EventTokenBucket *aBucket);
MOZ_MUST_USE nsresult UpdateRequestTokenBucket(EventTokenBucket *aBucket);
// clears the connection history mCT
nsresult ClearConnectionHistory();
MOZ_MUST_USE nsresult ClearConnectionHistory();
void ReportFailedToProcess(nsIURI *uri);
@ -163,16 +167,16 @@ public:
// called to force the transaction queue to be processed once more, giving
// preference to the specified connection.
nsresult ProcessPendingQ(nsHttpConnectionInfo *);
bool ProcessPendingQForEntry(nsHttpConnectionInfo *);
MOZ_MUST_USE nsresult ProcessPendingQ(nsHttpConnectionInfo *);
MOZ_MUST_USE bool ProcessPendingQForEntry(nsHttpConnectionInfo *);
// Try and process all pending transactions
nsresult ProcessPendingQ();
MOZ_MUST_USE nsresult ProcessPendingQ();
// This is used to force an idle connection to be closed and removed from
// the idle connection list. It is called when the idle connection detects
// that the network peer has closed the transport.
nsresult CloseIdleConnection(nsHttpConnection *);
MOZ_MUST_USE nsresult CloseIdleConnection(nsHttpConnection *);
// The connection manager needs to know when a normal HTTP connection has been
// upgraded to SPDY because the dispatch and idle semantics are a little
@ -282,12 +286,12 @@ private:
nsAHttpTransaction *trans,
uint32_t caps);
nsresult SetupStreams(nsISocketTransport **,
nsIAsyncInputStream **,
nsIAsyncOutputStream **,
bool isBackup);
nsresult SetupPrimaryStreams();
nsresult SetupBackupStreams();
MOZ_MUST_USE nsresult SetupStreams(nsISocketTransport **,
nsIAsyncInputStream **,
nsIAsyncOutputStream **,
bool isBackup);
MOZ_MUST_USE nsresult SetupPrimaryStreams();
MOZ_MUST_USE nsresult SetupBackupStreams();
void SetupBackupTimer();
void CancelBackupTimer();
void Abandon();
@ -370,26 +374,28 @@ private:
// NOTE: these members are only accessed on the socket transport thread
//-------------------------------------------------------------------------
bool ProcessPendingQForEntry(nsConnectionEntry *, bool considerAll);
MOZ_MUST_USE bool ProcessPendingQForEntry(nsConnectionEntry *,
bool considerAll);
bool AtActiveConnectionLimit(nsConnectionEntry *, uint32_t caps);
nsresult TryDispatchTransaction(nsConnectionEntry *ent,
bool onlyReusedConnection,
nsHttpTransaction *trans);
nsresult DispatchTransaction(nsConnectionEntry *,
nsHttpTransaction *,
nsHttpConnection *);
nsresult DispatchAbstractTransaction(nsConnectionEntry *,
nsAHttpTransaction *,
uint32_t,
nsHttpConnection *,
int32_t);
MOZ_MUST_USE nsresult TryDispatchTransaction(nsConnectionEntry *ent,
bool onlyReusedConnection,
nsHttpTransaction *trans);
MOZ_MUST_USE nsresult DispatchTransaction(nsConnectionEntry *,
nsHttpTransaction *,
nsHttpConnection *);
MOZ_MUST_USE nsresult DispatchAbstractTransaction(nsConnectionEntry *,
nsAHttpTransaction *,
uint32_t,
nsHttpConnection *,
int32_t);
bool RestrictConnections(nsConnectionEntry *);
nsresult ProcessNewTransaction(nsHttpTransaction *);
nsresult EnsureSocketThreadTarget();
MOZ_MUST_USE nsresult ProcessNewTransaction(nsHttpTransaction *);
MOZ_MUST_USE nsresult EnsureSocketThreadTarget();
void ClosePersistentConnections(nsConnectionEntry *ent);
void ReportProxyTelemetry(nsConnectionEntry *ent);
nsresult CreateTransport(nsConnectionEntry *, nsAHttpTransaction *,
uint32_t, bool, bool, bool);
MOZ_MUST_USE nsresult CreateTransport(nsConnectionEntry *,
nsAHttpTransaction *, uint32_t, bool,
bool, bool);
void AddActiveConn(nsHttpConnection *, nsConnectionEntry *);
void DecrementActiveConnCount(nsHttpConnection *);
void StartedConnect();
@ -398,8 +404,8 @@ private:
nsConnectionEntry *GetOrCreateConnectionEntry(nsHttpConnectionInfo *,
bool allowWildCard);
nsresult MakeNewConnection(nsConnectionEntry *ent,
nsHttpTransaction *trans);
MOZ_MUST_USE nsresult MakeNewConnection(nsConnectionEntry *ent,
nsHttpTransaction *trans);
// Manage the preferred spdy connection entry for this address
nsConnectionEntry *GetSpdyPreferredEnt(nsConnectionEntry *aOriginalEntry);
@ -415,9 +421,9 @@ private:
void ProcessSpdyPendingQ(nsConnectionEntry *ent);
// used to marshall events to the socket transport thread.
nsresult PostEvent(nsConnEventHandler handler,
int32_t iparam = 0,
ARefBase *vparam = nullptr);
MOZ_MUST_USE nsresult PostEvent(nsConnEventHandler handler,
int32_t iparam = 0,
ARefBase *vparam = nullptr);
// message handlers
void OnMsgShutdown (int32_t, ARefBase *);

View File

@ -41,48 +41,48 @@ class nsHttpDigestAuth final : public nsIHttpAuthenticator
protected:
~nsHttpDigestAuth();
nsresult ExpandToHex(const char * digest, char * result);
MOZ_MUST_USE nsresult ExpandToHex(const char * digest, char * result);
nsresult CalculateResponse(const char * ha1_digest,
const char * ha2_digest,
const nsAFlatCString & nonce,
uint16_t qop,
const char * nonce_count,
const nsAFlatCString & cnonce,
char * result);
MOZ_MUST_USE nsresult CalculateResponse(const char * ha1_digest,
const char * ha2_digest,
const nsAFlatCString & nonce,
uint16_t qop,
const char * nonce_count,
const nsAFlatCString & cnonce,
char * result);
nsresult CalculateHA1(const nsAFlatCString & username,
const nsAFlatCString & password,
const nsAFlatCString & realm,
uint16_t algorithm,
const nsAFlatCString & nonce,
const nsAFlatCString & cnonce,
char * result);
MOZ_MUST_USE nsresult CalculateHA1(const nsAFlatCString & username,
const nsAFlatCString & password,
const nsAFlatCString & realm,
uint16_t algorithm,
const nsAFlatCString & nonce,
const nsAFlatCString & cnonce,
char * result);
nsresult CalculateHA2(const nsAFlatCString & http_method,
const nsAFlatCString & http_uri_path,
uint16_t qop,
const char * body_digest,
char * result);
MOZ_MUST_USE nsresult CalculateHA2(const nsAFlatCString & http_method,
const nsAFlatCString & http_uri_path,
uint16_t qop,
const char * body_digest,
char * result);
nsresult ParseChallenge(const char * challenge,
nsACString & realm,
nsACString & domain,
nsACString & nonce,
nsACString & opaque,
bool * stale,
uint16_t * algorithm,
uint16_t * qop);
MOZ_MUST_USE nsresult ParseChallenge(const char * challenge,
nsACString & realm,
nsACString & domain,
nsACString & nonce,
nsACString & opaque,
bool * stale,
uint16_t * algorithm,
uint16_t * qop);
// result is in mHashBuf
nsresult MD5Hash(const char *buf, uint32_t len);
MOZ_MUST_USE nsresult MD5Hash(const char *buf, uint32_t len);
nsresult GetMethodAndPath(nsIHttpAuthenticableChannel *,
bool, nsCString &, nsCString &);
MOZ_MUST_USE nsresult GetMethodAndPath(nsIHttpAuthenticableChannel *,
bool, nsCString &, nsCString &);
// append the quoted version of value to aHeaderLine
nsresult AppendQuotedString(const nsACString & value,
nsACString & aHeaderLine);
MOZ_MUST_USE nsresult AppendQuotedString(const nsACString & value,
nsACString & aHeaderLine);
protected:
nsCOMPtr<nsICryptoHash> mVerifier;

View File

@ -69,10 +69,11 @@ public:
nsHttpHandler();
nsresult Init();
nsresult AddStandardRequestHeaders(nsHttpRequestHead *, bool isSecure);
nsresult AddConnectionHeader(nsHttpRequestHead *,
uint32_t capabilities);
MOZ_MUST_USE nsresult Init();
MOZ_MUST_USE nsresult AddStandardRequestHeaders(nsHttpRequestHead *,
bool isSecure);
MOZ_MUST_USE nsresult AddConnectionHeader(nsHttpRequestHead *,
uint32_t capabilities);
bool IsAcceptableEncoding(const char *encoding, bool isSecure);
const nsAFlatCString &UserAgent();
@ -189,50 +190,53 @@ public:
// Called to kick-off a new transaction, by default the transaction
// will be put on the pending transaction queue if it cannot be
// initiated at this time. Callable from any thread.
nsresult InitiateTransaction(nsHttpTransaction *trans, int32_t priority)
MOZ_MUST_USE nsresult InitiateTransaction(nsHttpTransaction *trans,
int32_t priority)
{
return mConnMgr->AddTransaction(trans, priority);
}
// Called to change the priority of an existing transaction that has
// already been initiated.
nsresult RescheduleTransaction(nsHttpTransaction *trans, int32_t priority)
MOZ_MUST_USE nsresult RescheduleTransaction(nsHttpTransaction *trans,
int32_t priority)
{
return mConnMgr->RescheduleTransaction(trans, priority);
}
// Called to cancel a transaction, which may or may not be assigned to
// a connection. Callable from any thread.
nsresult CancelTransaction(nsHttpTransaction *trans, nsresult reason)
MOZ_MUST_USE nsresult CancelTransaction(nsHttpTransaction *trans,
nsresult reason)
{
return mConnMgr->CancelTransaction(trans, reason);
}
// Called when a connection is done processing a transaction. Callable
// from any thread.
nsresult ReclaimConnection(nsHttpConnection *conn)
MOZ_MUST_USE nsresult ReclaimConnection(nsHttpConnection *conn)
{
return mConnMgr->ReclaimConnection(conn);
}
nsresult ProcessPendingQ(nsHttpConnectionInfo *cinfo)
MOZ_MUST_USE nsresult ProcessPendingQ(nsHttpConnectionInfo *cinfo)
{
return mConnMgr->ProcessPendingQ(cinfo);
}
nsresult ProcessPendingQ()
MOZ_MUST_USE nsresult ProcessPendingQ()
{
return mConnMgr->ProcessPendingQ();
}
nsresult GetSocketThreadTarget(nsIEventTarget **target)
MOZ_MUST_USE nsresult GetSocketThreadTarget(nsIEventTarget **target)
{
return mConnMgr->GetSocketThreadTarget(target);
}
nsresult SpeculativeConnect(nsHttpConnectionInfo *ci,
nsIInterfaceRequestor *callbacks,
uint32_t caps = 0)
MOZ_MUST_USE nsresult SpeculativeConnect(nsHttpConnectionInfo *ci,
nsIInterfaceRequestor *callbacks,
uint32_t caps = 0)
{
TickleWifi(callbacks);
return mConnMgr->SpeculativeConnect(ci, callbacks, caps);
@ -261,8 +265,8 @@ public:
// The HTTP handler caches pointers to specific XPCOM services, and
// provides the following helper routines for accessing those services:
//
nsresult GetStreamConverterService(nsIStreamConverterService **);
nsresult GetIOService(nsIIOService** service);
MOZ_MUST_USE nsresult GetStreamConverterService(nsIStreamConverterService **);
MOZ_MUST_USE nsresult GetIOService(nsIIOService** service);
nsICookieService * GetCookieService(); // not addrefed
nsISiteSecurityService * GetSSService();
nsIThrottlingService * GetThrottlingService();
@ -302,8 +306,9 @@ public:
// Called by channels before a redirect happens. This notifies both the
// channel's and the global redirect observers.
nsresult AsyncOnChannelRedirect(nsIChannel* oldChan, nsIChannel* newChan,
uint32_t flags);
MOZ_MUST_USE nsresult AsyncOnChannelRedirect(nsIChannel* oldChan,
nsIChannel* newChan,
uint32_t flags);
// Called by the channel when the response is read from the cache without
// communicating with the server.
@ -314,8 +319,9 @@ public:
// Generates the host:port string for use in the Host: header as well as the
// CONNECT line for proxies. This handles IPv6 literals correctly.
static nsresult GenerateHostPort(const nsCString& host, int32_t port,
nsACString& hostLine);
static MOZ_MUST_USE nsresult GenerateHostPort(const nsCString& host,
int32_t port,
nsACString& hostLine);
SpdyInformation *SpdyInfo() { return &mSpdyInfo; }
@ -362,11 +368,11 @@ private:
void InitUserAgentComponents();
void PrefsChanged(nsIPrefBranch *prefs, const char *pref);
nsresult SetAccept(const char *);
nsresult SetAcceptLanguages(const char *);
nsresult SetAcceptEncodings(const char *, bool mIsSecure);
MOZ_MUST_USE nsresult SetAccept(const char *);
MOZ_MUST_USE nsresult SetAcceptLanguages(const char *);
MOZ_MUST_USE nsresult SetAcceptEncodings(const char *, bool mIsSecure);
nsresult InitConnectionMgr();
MOZ_MUST_USE nsresult InitConnectionMgr();
void NotifyObservers(nsIHttpChannel *chan, const char *event);
@ -567,8 +573,8 @@ private:
public:
// Socket thread only
nsresult SubmitPacedRequest(ATokenBucketEvent *event,
nsICancelable **cancel)
MOZ_MUST_USE nsresult SubmitPacedRequest(ATokenBucketEvent *event,
nsICancelable **cancel)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
if (!mRequestTokenBucket) {
@ -598,16 +604,17 @@ private:
void TickleWifi(nsIInterfaceRequestor *cb);
private:
nsresult SpeculativeConnectInternal(nsIURI *aURI,
nsIPrincipal *aPrincipal,
nsIInterfaceRequestor *aCallbacks,
bool anonymous);
MOZ_MUST_USE nsresult
SpeculativeConnectInternal(nsIURI *aURI,
nsIPrincipal *aPrincipal,
nsIInterfaceRequestor *aCallbacks,
bool anonymous);
// UUID generator for channelIds
nsCOMPtr<nsIUUIDGenerator> mUUIDGen;
public:
nsresult NewChannelId(nsID *channelId);
MOZ_MUST_USE nsresult NewChannelId(nsID *channelId);
};
extern nsHttpHandler *gHttpHandler;
@ -634,7 +641,7 @@ public:
nsHttpsHandler() { }
nsresult Init();
MOZ_MUST_USE nsresult Init();
};
} // namespace net

View File

@ -49,24 +49,27 @@ public:
};
// Used by internal setters: to set header from network use SetHeaderFromNet
nsresult SetHeader(nsHttpAtom header, const nsACString &value,
bool merge, HeaderVariety variety);
MOZ_MUST_USE nsresult SetHeader(nsHttpAtom header, const nsACString &value,
bool merge, HeaderVariety variety);
// Used by internal setters to set an empty header
nsresult SetEmptyHeader(nsHttpAtom header, HeaderVariety variety);
MOZ_MUST_USE nsresult SetEmptyHeader(nsHttpAtom header,
HeaderVariety variety);
// Merges supported headers. For other duplicate values, determines if error
// needs to be thrown or 1st value kept.
// For the response header we keep the original headers as well.
nsresult SetHeaderFromNet(nsHttpAtom header, const nsACString &value,
bool response);
MOZ_MUST_USE nsresult SetHeaderFromNet(nsHttpAtom header,
const nsACString &value,
bool response);
nsresult SetResponseHeaderFromCache(nsHttpAtom header, const nsACString &value,
HeaderVariety variety);
MOZ_MUST_USE nsresult SetResponseHeaderFromCache(nsHttpAtom header,
const nsACString &value,
HeaderVariety variety);
nsresult GetHeader(nsHttpAtom header, nsACString &value) const;
nsresult GetOriginalHeader(nsHttpAtom aHeader,
nsIHttpHeaderVisitor *aVisitor);
MOZ_MUST_USE nsresult GetHeader(nsHttpAtom header, nsACString &value) const;
MOZ_MUST_USE nsresult GetOriginalHeader(nsHttpAtom aHeader,
nsIHttpHeaderVisitor *aVisitor);
void ClearHeader(nsHttpAtom h);
// Find the location of the given header value, or null if none exists.
@ -92,13 +95,14 @@ public:
eFilterResponseOriginal
};
nsresult VisitHeaders(nsIHttpHeaderVisitor *visitor, VisitorFilter filter = eFilterAll);
MOZ_MUST_USE nsresult VisitHeaders(nsIHttpHeaderVisitor *visitor,
VisitorFilter filter = eFilterAll);
// parse a header line, return the header atom and a pointer to the
// header value (the substring of the header line -- do not free).
static nsresult ParseHeaderLine(const nsACString& line,
nsHttpAtom *header=nullptr,
nsACString* value=nullptr);
static MOZ_MUST_USE nsresult ParseHeaderLine(const nsACString& line,
nsHttpAtom *header=nullptr,
nsACString* value=nullptr);
void Flatten(nsACString &, bool pruneProxyHeaders, bool pruneTransients);
void FlattenOriginalHeader(nsACString &);
@ -138,10 +142,12 @@ private:
// It will ignore original headers from the network.
int32_t LookupEntry(nsHttpAtom header, const nsEntry **) const;
int32_t LookupEntry(nsHttpAtom header, nsEntry **);
nsresult MergeHeader(nsHttpAtom header, nsEntry *entry,
const nsACString &value, HeaderVariety variety);
nsresult SetHeader_internal(nsHttpAtom header, const nsACString &value,
HeaderVariety variety);
MOZ_MUST_USE nsresult MergeHeader(nsHttpAtom header, nsEntry *entry,
const nsACString &value,
HeaderVariety variety);
MOZ_MUST_USE nsresult SetHeader_internal(nsHttpAtom header,
const nsACString &value,
HeaderVariety variety);
// Header cannot be merged: only one value possible
bool IsSingletonHeader(nsHttpAtom header);
@ -227,7 +233,7 @@ nsHttpHeaderArray::TrackEmptyHeader(nsHttpAtom header)
header == nsHttp::Access_Control_Allow_Origin;
}
inline nsresult
inline MOZ_MUST_USE nsresult
nsHttpHeaderArray::MergeHeader(nsHttpAtom header,
nsEntry *entry,
const nsACString &value,

View File

@ -43,9 +43,10 @@ public:
// Using this function it is possible to itereate through all headers
// automatically under one lock.
nsresult VisitHeaders(nsIHttpHeaderVisitor *visitor,
nsHttpHeaderArray::VisitorFilter filter =
nsHttpHeaderArray::eFilterAll);
MOZ_MUST_USE nsresult
VisitHeaders(nsIHttpHeaderVisitor *visitor,
nsHttpHeaderArray::VisitorFilter filter =
nsHttpHeaderArray::eFilterAll);
void Method(nsACString &aMethod);
nsHttpVersion Version();
void RequestURI(nsACString &RequestURI);
@ -57,13 +58,14 @@ public:
int32_t port);
void Origin(nsACString &aOrigin);
nsresult SetHeader(nsHttpAtom h, const nsACString &v, bool m=false);
nsresult SetHeader(nsHttpAtom h, const nsACString &v, bool m,
nsHttpHeaderArray::HeaderVariety variety);
nsresult SetEmptyHeader(nsHttpAtom h);
nsresult GetHeader(nsHttpAtom h, nsACString &v);
MOZ_MUST_USE nsresult SetHeader(nsHttpAtom h, const nsACString &v,
bool m=false);
MOZ_MUST_USE nsresult SetHeader(nsHttpAtom h, const nsACString &v, bool m,
nsHttpHeaderArray::HeaderVariety variety);
MOZ_MUST_USE nsresult SetEmptyHeader(nsHttpAtom h);
MOZ_MUST_USE nsresult GetHeader(nsHttpAtom h, nsACString &v);
nsresult ClearHeader(nsHttpAtom h);
MOZ_MUST_USE nsresult ClearHeader(nsHttpAtom h);
void ClearHeaders();
bool HasHeaderValue(nsHttpAtom h, const char *v);
@ -73,7 +75,8 @@ public:
void Flatten(nsACString &, bool pruneProxyHeaders = false);
// Don't allow duplicate values
nsresult SetHeaderOnce(nsHttpAtom h, const char *v, bool merge = false);
MOZ_MUST_USE nsresult SetHeaderOnce(nsHttpAtom h, const char *v,
bool merge = false);
bool IsSafeMethod();

View File

@ -65,8 +65,9 @@ public:
*/
int64_t TotalEntitySize();
nsresult SetHeader(nsHttpAtom h, const nsACString &v, bool m=false);
nsresult GetHeader(nsHttpAtom h, nsACString &v);
MOZ_MUST_USE nsresult SetHeader(nsHttpAtom h, const nsACString &v,
bool m=false);
MOZ_MUST_USE nsresult GetHeader(nsHttpAtom h, nsACString &v);
void ClearHeader(nsHttpAtom h);
void ClearHeaders();
bool HasHeaderValue(nsHttpAtom h, const char *v);
@ -90,19 +91,19 @@ public:
// ParseCachedOriginalHeaders FIRST and then ParseCachedHead.
//
// block must be null terminated.
nsresult ParseCachedHead(const char *block);
nsresult ParseCachedOriginalHeaders(char *block);
MOZ_MUST_USE nsresult ParseCachedHead(const char *block);
MOZ_MUST_USE nsresult ParseCachedOriginalHeaders(char *block);
// parse the status line.
void ParseStatusLine(const nsACString &line);
// parse a header line.
nsresult ParseHeaderLine(const nsACString &line);
MOZ_MUST_USE nsresult ParseHeaderLine(const nsACString &line);
// cache validation support methods
nsresult ComputeFreshnessLifetime(uint32_t *);
nsresult ComputeCurrentAge(uint32_t now, uint32_t requestTime,
uint32_t *result);
MOZ_MUST_USE nsresult ComputeFreshnessLifetime(uint32_t *);
MOZ_MUST_USE nsresult ComputeCurrentAge(uint32_t now, uint32_t requestTime,
uint32_t *result);
bool MustValidate();
bool MustValidateIfExpired();
@ -114,30 +115,30 @@ public:
bool ExpiresInPast();
// update headers...
nsresult UpdateHeaders(nsHttpResponseHead *headers);
MOZ_MUST_USE nsresult UpdateHeaders(nsHttpResponseHead *headers);
// reset the response head to it's initial state
void Reset();
nsresult GetAgeValue(uint32_t *result);
nsresult GetMaxAgeValue(uint32_t *result);
nsresult GetDateValue(uint32_t *result);
nsresult GetExpiresValue(uint32_t *result);
nsresult GetLastModifiedValue(uint32_t *result);
MOZ_MUST_USE nsresult GetAgeValue(uint32_t *result);
MOZ_MUST_USE nsresult GetMaxAgeValue(uint32_t *result);
MOZ_MUST_USE nsresult GetDateValue(uint32_t *result);
MOZ_MUST_USE nsresult GetExpiresValue(uint32_t *result);
MOZ_MUST_USE nsresult GetLastModifiedValue(uint32_t *result);
bool operator==(const nsHttpResponseHead& aOther) const;
// Using this function it is possible to itereate through all headers
// automatically under one lock.
nsresult VisitHeaders(nsIHttpHeaderVisitor *visitor,
nsHttpHeaderArray::VisitorFilter filter);
nsresult GetOriginalHeader(nsHttpAtom aHeader,
nsIHttpHeaderVisitor *aVisitor);
MOZ_MUST_USE nsresult VisitHeaders(nsIHttpHeaderVisitor *visitor,
nsHttpHeaderArray::VisitorFilter filter);
MOZ_MUST_USE nsresult GetOriginalHeader(nsHttpAtom aHeader,
nsIHttpHeaderVisitor *aVisitor);
bool HasContentType();
bool HasContentCharset();
private:
nsresult SetHeader_locked(nsHttpAtom h, const nsACString &v,
MOZ_MUST_USE nsresult SetHeader_locked(nsHttpAtom h, const nsACString &v,
bool m=false);
void AssignDefaultStatusText();
void ParseVersion(const char *);
@ -145,22 +146,24 @@ private:
void ParsePragma(const char *);
void ParseStatusLine_locked(const nsACString &line);
nsresult ParseHeaderLine_locked(const nsACString &line, bool originalFromNetHeaders);
MOZ_MUST_USE nsresult ParseHeaderLine_locked(const nsACString &line,
bool originalFromNetHeaders);
// these return failure if the header does not exist.
nsresult ParseDateHeader(nsHttpAtom header, uint32_t *result) const;
MOZ_MUST_USE nsresult ParseDateHeader(nsHttpAtom header,
uint32_t *result) const;
bool ExpiresInPast_locked() const;
nsresult GetAgeValue_locked(uint32_t *result) const;
nsresult GetExpiresValue_locked(uint32_t *result) const;
nsresult GetMaxAgeValue_locked(uint32_t *result) const;
MOZ_MUST_USE nsresult GetAgeValue_locked(uint32_t *result) const;
MOZ_MUST_USE nsresult GetExpiresValue_locked(uint32_t *result) const;
MOZ_MUST_USE nsresult GetMaxAgeValue_locked(uint32_t *result) const;
nsresult GetDateValue_locked(uint32_t *result) const
MOZ_MUST_USE nsresult GetDateValue_locked(uint32_t *result) const
{
return ParseDateHeader(nsHttp::Date, result);
}
nsresult GetLastModifiedValue_locked(uint32_t *result) const
MOZ_MUST_USE nsresult GetLastModifiedValue_locked(uint32_t *result) const
{
return ParseDateHeader(nsHttp::Last_Modified, result);
}

View File

@ -79,15 +79,15 @@ public:
// wait on this input stream for data. on first notification,
// headers should be available (check transaction status).
//
nsresult Init(uint32_t caps,
nsHttpConnectionInfo *connInfo,
nsHttpRequestHead *reqHeaders,
nsIInputStream *reqBody,
bool reqBodyIncludesHeaders,
nsIEventTarget *consumerTarget,
nsIInterfaceRequestor *callbacks,
nsITransportEventSink *eventsink,
nsIAsyncInputStream **responseBody);
MOZ_MUST_USE nsresult Init(uint32_t caps,
nsHttpConnectionInfo *connInfo,
nsHttpRequestHead *reqHeaders,
nsIInputStream *reqBody,
bool reqBodyIncludesHeaders,
nsIEventTarget *consumerTarget,
nsIInterfaceRequestor *callbacks,
nsITransportEventSink *eventsink,
nsIAsyncInputStream **responseBody);
// attributes
nsHttpResponseHead *ResponseHead() { return mHaveAllHeaders ? mResponseHead : nullptr; }
@ -164,28 +164,33 @@ public:
int64_t GetTransferSize() { return mTransferSize; }
bool Do0RTT() override;
nsresult Finish0RTT(bool aRestart, bool aAlpnChanged /* ignored */) override;
MOZ_MUST_USE bool Do0RTT() override;
MOZ_MUST_USE nsresult Finish0RTT(bool aRestart, bool aAlpnChanged /* ignored */) override;
private:
friend class DeleteHttpTransaction;
virtual ~nsHttpTransaction();
nsresult Restart();
MOZ_MUST_USE nsresult Restart();
char *LocateHttpStart(char *buf, uint32_t len,
bool aAllowPartialMatch);
nsresult ParseLine(nsACString &line);
nsresult ParseLineSegment(char *seg, uint32_t len);
nsresult ParseHead(char *, uint32_t count, uint32_t *countRead);
nsresult HandleContentStart();
nsresult HandleContent(char *, uint32_t count, uint32_t *contentRead, uint32_t *contentRemaining);
nsresult ProcessData(char *, uint32_t, uint32_t *);
MOZ_MUST_USE nsresult ParseLine(nsACString &line);
MOZ_MUST_USE nsresult ParseLineSegment(char *seg, uint32_t len);
MOZ_MUST_USE nsresult ParseHead(char *, uint32_t count,
uint32_t *countRead);
MOZ_MUST_USE nsresult HandleContentStart();
MOZ_MUST_USE nsresult HandleContent(char *, uint32_t count,
uint32_t *contentRead,
uint32_t *contentRemaining);
MOZ_MUST_USE nsresult ProcessData(char *, uint32_t, uint32_t *);
void DeleteSelfOnConsumerThread();
void ReleaseBlockingTransaction();
static nsresult ReadRequestSegment(nsIInputStream *, void *, const char *,
uint32_t, uint32_t, uint32_t *);
static nsresult WritePipeSegment(nsIOutputStream *, void *, char *,
uint32_t, uint32_t, uint32_t *);
static MOZ_MUST_USE nsresult ReadRequestSegment(nsIInputStream *, void *,
const char *, uint32_t,
uint32_t, uint32_t *);
static MOZ_MUST_USE nsresult WritePipeSegment(nsIOutputStream *, void *,
char *, uint32_t, uint32_t,
uint32_t *);
bool TimingEnabled() const { return mCaps & NS_HTTP_TIMING_ENABLED; }

View File

@ -31,7 +31,7 @@ interface nsIHstsPrimingCallback : nsISupports
*
* @param aCached whether the result was already in the HSTS cache
*/
[noscript, nostdcall]
[noscript, nostdcall, must_use]
void onHSTSPrimingSucceeded(in bool aCached);
/**
@ -46,6 +46,6 @@ interface nsIHstsPrimingCallback : nsISupports
* @param aError The error which caused this failure, or NS_ERROR_CONTENT_BLOCKED
* @param aCached whether the result was already in the HSTS cache
*/
[noscript, nostdcall]
[noscript, nostdcall, must_use]
void onHSTSPrimingFailed(in nsresult aError, in bool aCached);
};

View File

@ -44,6 +44,7 @@ interface nsIHttpActivityObserver : nsISupports
* Any extra string data optionally available with
* this activity
*/
[must_use]
void observeActivity(in nsISupports aHttpChannel,
in uint32_t aActivityType,
in uint32_t aActivitySubtype,
@ -57,7 +58,7 @@ interface nsIHttpActivityObserver : nsISupports
* be called. It is present for compatibility reasons and should be
* implemented only by nsHttpActivityDistributor.
*/
readonly attribute boolean isActive;
[must_use] readonly attribute boolean isActive;
const unsigned long ACTIVITY_TYPE_SOCKET_TRANSPORT = 0x0001;
const unsigned long ACTIVITY_TYPE_HTTP_TRANSACTION = 0x0002;

View File

@ -54,17 +54,17 @@ interface nsIHttpAuthManager : nsISupports
* the principal from which to derive information about which
* app/mozbrowser is in use for this request
*/
void getAuthIdentity(in ACString aScheme,
in ACString aHost,
in int32_t aPort,
in ACString aAuthType,
in ACString aRealm,
in ACString aPath,
out AString aUserDomain,
out AString aUserName,
out AString aUserPassword,
[optional] in bool aIsPrivate,
[optional] in nsIPrincipal aPrincipal);
[must_use] void getAuthIdentity(in ACString aScheme,
in ACString aHost,
in int32_t aPort,
in ACString aAuthType,
in ACString aRealm,
in ACString aPath,
out AString aUserDomain,
out AString aUserName,
out AString aUserPassword,
[optional] in bool aIsPrivate,
[optional] in nsIPrincipal aPrincipal);
/**
* Store auth identity.
@ -96,20 +96,20 @@ interface nsIHttpAuthManager : nsISupports
* the principal from which to derive information about which
* app/mozbrowser is in use for this request
*/
void setAuthIdentity(in ACString aScheme,
in ACString aHost,
in int32_t aPort,
in ACString aAuthType,
in ACString aRealm,
in ACString aPath,
in AString aUserDomain,
in AString aUserName,
in AString aUserPassword,
[optional] in boolean aIsPrivate,
[optional] in nsIPrincipal aPrincipal);
[must_use] void setAuthIdentity(in ACString aScheme,
in ACString aHost,
in int32_t aPort,
in ACString aAuthType,
in ACString aRealm,
in ACString aPath,
in AString aUserDomain,
in AString aUserName,
in AString aUserPassword,
[optional] in boolean aIsPrivate,
[optional] in nsIPrincipal aPrincipal);
/**
* Clear all auth cache.
*/
void clearAll();
[must_use] void clearAll();
};

View File

@ -16,72 +16,72 @@ interface nsIHttpAuthenticableChannel : nsIProxiedChannel
/**
* If the channel being authenticated is using SSL.
*/
readonly attribute boolean isSSL;
[must_use] readonly attribute boolean isSSL;
/**
* Returns if the proxy HTTP method used is CONNECT. If no proxy is being
* used it must return PR_FALSE.
*/
readonly attribute boolean proxyMethodIsConnect;
[must_use] readonly attribute boolean proxyMethodIsConnect;
/**
* Cancels the current request. See nsIRequest.
*/
void cancel(in nsresult aStatus);
[must_use] void cancel(in nsresult aStatus);
/**
* The load flags of this request. See nsIRequest.
*/
readonly attribute nsLoadFlags loadFlags;
[must_use] readonly attribute nsLoadFlags loadFlags;
/**
* The URI corresponding to the channel. See nsIChannel.
*/
readonly attribute nsIURI URI;
[must_use] readonly attribute nsIURI URI;
/**
* The load group of this request. It is here for querying its
* notificationCallbacks. See nsIRequest.
*/
readonly attribute nsILoadGroup loadGroup;
[must_use] readonly attribute nsILoadGroup loadGroup;
/**
* The notification callbacks for the channel. See nsIChannel.
*/
readonly attribute nsIInterfaceRequestor notificationCallbacks;
[must_use] readonly attribute nsIInterfaceRequestor notificationCallbacks;
/**
* The HTTP request method. See nsIHttpChannel.
*/
readonly attribute ACString requestMethod;
[must_use] readonly attribute ACString requestMethod;
/**
* The "Server" response header.
* Return NS_ERROR_NOT_AVAILABLE if not available.
*/
readonly attribute ACString serverResponseHeader;
[must_use] readonly attribute ACString serverResponseHeader;
/**
* The Proxy-Authenticate response header.
*/
readonly attribute ACString proxyChallenges;
[must_use] readonly attribute ACString proxyChallenges;
/**
* The WWW-Authenticate response header.
*/
readonly attribute ACString WWWChallenges;
[must_use] readonly attribute ACString WWWChallenges;
/**
* Sets the Proxy-Authorization request header. An empty string
* will clear it.
*/
void setProxyCredentials(in ACString credentials);
[must_use] void setProxyCredentials(in ACString credentials);
/**
* Sets the Authorization request header. An empty string
* will clear it.
*/
void setWWWCredentials(in ACString credentials);
[must_use] void setWWWCredentials(in ACString credentials);
/**
* Called when authentication information is ready and has been set on this
@ -94,7 +94,7 @@ interface nsIHttpAuthenticableChannel : nsIProxiedChannel
*
* @note Any exceptions thrown from this method should be ignored.
*/
void onAuthAvailable();
[must_use] void onAuthAvailable();
/**
* Notifies that the prompt was cancelled. It is called asynchronously
@ -104,12 +104,12 @@ interface nsIHttpAuthenticableChannel : nsIProxiedChannel
* @param userCancel
* If the user was cancelled has cancelled the authentication prompt.
*/
void onAuthCancelled(in boolean userCancel);
[must_use] void onAuthCancelled(in boolean userCancel);
/**
* Tells the channel to drop and close any sticky connection, since this
* connection oriented schema cannot be negotiated second time on
* the same connection.
*/
void closeStickyConnection();
[must_use] void closeStickyConnection();
};

View File

@ -47,6 +47,7 @@ interface nsIHttpAuthenticator : nsISupports
* return value indicating whether or not to prompt the user for a
* revised identity.
*/
[must_use]
void challengeReceived(in nsIHttpAuthenticableChannel aChannel,
in string aChallenge,
in boolean aProxyAuth,
@ -92,6 +93,7 @@ interface nsIHttpAuthenticator : nsISupports
* returns cancellable runnable object which caller can use to cancel
* calling aCallback when finished.
*/
[must_use]
void generateCredentialsAsync(in nsIHttpAuthenticableChannel aChannel,
in nsIHttpAuthenticatorCallback aCallback,
in string aChallenge,
@ -138,6 +140,7 @@ interface nsIHttpAuthenticator : nsISupports
* @param aFlags
* authenticator may return one of the generate flags bellow.
*/
[must_use]
string generateCredentials(in nsIHttpAuthenticableChannel aChannel,
in string aChallenge,
in boolean aProxyAuth,
@ -163,7 +166,7 @@ interface nsIHttpAuthenticator : nsISupports
/**
* Flags defining various properties of the authenticator.
*/
readonly attribute unsigned long authFlags;
[must_use] readonly attribute unsigned long authFlags;
/**
* A request based authentication scheme only authenticates an individual

View File

@ -36,7 +36,7 @@ interface nsIHttpChannel : nsIChannel
*
* @throws NS_ERROR_IN_PROGRESS if set after the channel has been opened.
*/
attribute ACString requestMethod;
[must_use] attribute ACString requestMethod;
/**
* Get/set the HTTP referrer URI. This is the address (URI) of the
@ -55,7 +55,7 @@ interface nsIHttpChannel : nsIChannel
* @throws NS_ERROR_FAILURE if used for setting referrer during
* visitRequestHeaders. Getting the value will not throw.
*/
attribute nsIURI referrer;
[must_use] attribute nsIURI referrer;
/**
* Referrer policies. See ReferrerPolicy.h for more details.
@ -91,12 +91,13 @@ interface nsIHttpChannel : nsIChannel
* referrer tag, which can be one of many values (see ReferrerPolicy.h for
* more details).
*/
readonly attribute unsigned long referrerPolicy;
[must_use] readonly attribute unsigned long referrerPolicy;
/**
* Set the HTTP referrer URI with a referrer policy.
* @throws NS_ERROR_FAILURE if called during visitRequestHeaders.
*/
[must_use]
void setReferrerWithPolicy(in nsIURI referrer, in unsigned long referrerPolicy);
/**
@ -106,23 +107,23 @@ interface nsIHttpChannel : nsIChannel
* @throws NS_ERROR_NOT_AVAILABLE if called before the response
* has been received (before onStartRequest).
*/
readonly attribute ACString protocolVersion;
[must_use] readonly attribute ACString protocolVersion;
/**
* size consumed by the response header fields and the response payload body
*/
readonly attribute uint64_t transferSize;
[must_use] readonly attribute uint64_t transferSize;
/**
* The size of the message body received by the client,
* after removing any applied content-codings
*/
readonly attribute uint64_t decodedBodySize;
[must_use] readonly attribute uint64_t decodedBodySize;
/**
* The size in octets of the payload body, prior to removing content-codings
*/
readonly attribute uint64_t encodedBodySize;
[must_use] readonly attribute uint64_t encodedBodySize;
/**
* Get the value of a particular request header.
@ -134,7 +135,7 @@ interface nsIHttpChannel : nsIChannel
* @return the value of the request header.
* @throws NS_ERROR_NOT_AVAILABLE if the header is not set.
*/
ACString getRequestHeader(in ACString aHeader);
[must_use] ACString getRequestHeader(in ACString aHeader);
/**
* Set the value of a particular request header.
@ -164,9 +165,9 @@ interface nsIHttpChannel : nsIChannel
* opened.
* @throws NS_ERROR_FAILURE if called during visitRequestHeaders.
*/
void setRequestHeader(in ACString aHeader,
in ACString aValue,
in boolean aMerge);
[must_use] void setRequestHeader(in ACString aHeader,
in ACString aValue,
in boolean aMerge);
/**
* Set a request header with empty value.
@ -184,7 +185,7 @@ interface nsIHttpChannel : nsIChannel
* opened.
* @throws NS_ERROR_FAILURE if called during visitRequestHeaders.
*/
void setEmptyRequestHeader(in ACString aHeader);
[must_use] void setEmptyRequestHeader(in ACString aHeader);
/**
* Call this method to visit all request headers. Calling setRequestHeader
@ -193,7 +194,7 @@ interface nsIHttpChannel : nsIChannel
* @param aVisitor
* the header visitor instance.
*/
void visitRequestHeaders(in nsIHttpHeaderVisitor aVisitor);
[must_use] void visitRequestHeaders(in nsIHttpHeaderVisitor aVisitor);
/**
* Call this method to visit all non-default (UA-provided) request headers.
@ -203,6 +204,7 @@ interface nsIHttpChannel : nsIChannel
* @param aVisitor
* the header visitor instance.
*/
[must_use]
void visitNonDefaultRequestHeaders(in nsIHttpHeaderVisitor aVisitor);
/**
@ -210,7 +212,7 @@ interface nsIHttpChannel : nsIChannel
*
* @throws NS_ERROR_FAILURE if set after the channel has been opened.
*/
attribute boolean allowPipelining;
[must_use] attribute boolean allowPipelining;
/**
* This attribute of the channel indicates whether or not
@ -224,7 +226,7 @@ interface nsIHttpChannel : nsIChannel
* @throws NS_ERROR_IN_PROGRESS or NS_ERROR_ALREADY_OPENED
* if called after the channel has been opened.
*/
attribute boolean allowSTS;
[must_use] attribute boolean allowSTS;
/**
* This attribute specifies the number of redirects this channel is allowed
@ -238,7 +240,7 @@ interface nsIHttpChannel : nsIChannel
* for this attribute may be a configurable preference (depending on the
* implementation).
*/
attribute unsigned long redirectionLimit;
[must_use] attribute unsigned long redirectionLimit;
/**************************************************************************
@ -253,7 +255,7 @@ interface nsIHttpChannel : nsIChannel
* @throws NS_ERROR_NOT_AVAILABLE if called before the response
* has been received (before onStartRequest).
*/
readonly attribute unsigned long responseStatus;
[must_use] readonly attribute unsigned long responseStatus;
/**
* Get the HTTP response status text (e.g., "OK").
@ -265,7 +267,7 @@ interface nsIHttpChannel : nsIChannel
* @throws NS_ERROR_NOT_AVAILABLE if called before the response
* has been received (before onStartRequest).
*/
readonly attribute ACString responseStatusText;
[must_use] readonly attribute ACString responseStatusText;
/**
* Returns true if the HTTP response code indicates success. The value of
@ -280,13 +282,13 @@ interface nsIHttpChannel : nsIChannel
* @throws NS_ERROR_NOT_AVAILABLE if called before the response
* has been received (before onStartRequest).
*/
readonly attribute boolean requestSucceeded;
[must_use] readonly attribute boolean requestSucceeded;
/** Indicates whether channel should be treated as the main one for the
* current document. If manually set to true, will always remain true. Otherwise,
* will be true iff LOAD_DOCUMENT_URI is set in the channel's loadflags.
*/
attribute boolean isMainDocumentChannel;
[must_use] attribute boolean isMainDocumentChannel;
/**
* Get the value of a particular response header.
@ -301,7 +303,7 @@ interface nsIHttpChannel : nsIChannel
* has been received (before onStartRequest) or if the header is
* not set in the response.
*/
ACString getResponseHeader(in ACString header);
[must_use] ACString getResponseHeader(in ACString header);
/**
* Set the value of a particular response header.
@ -332,9 +334,9 @@ interface nsIHttpChannel : nsIChannel
* @throws NS_ERROR_FAILURE if called during visitResponseHeaders,
* VisitOriginalResponseHeaders or getOriginalResponseHeader.
*/
void setResponseHeader(in ACString header,
in ACString value,
in boolean merge);
[must_use] void setResponseHeader(in ACString header,
in ACString value,
in boolean merge);
/**
* Call this method to visit all response headers. Calling
@ -347,7 +349,7 @@ interface nsIHttpChannel : nsIChannel
* @throws NS_ERROR_NOT_AVAILABLE if called before the response
* has been received (before onStartRequest).
*/
void visitResponseHeaders(in nsIHttpHeaderVisitor aVisitor);
[must_use] void visitResponseHeaders(in nsIHttpHeaderVisitor aVisitor);
/**
* Get the value(s) of a particular response header in the form and order
@ -365,8 +367,8 @@ interface nsIHttpChannel : nsIChannel
* has been received (before onStartRequest) or if the header is
* not set in the response.
*/
void getOriginalResponseHeader(in ACString aHeader,
in nsIHttpHeaderVisitor aVisitor);
[must_use] void getOriginalResponseHeader(in ACString aHeader,
in nsIHttpHeaderVisitor aVisitor);
/**
* Call this method to visit all response headers in the form and order as
@ -380,6 +382,7 @@ interface nsIHttpChannel : nsIChannel
* @throws NS_ERROR_NOT_AVAILABLE if called before the response
* has been received (before onStartRequest).
*/
[must_use]
void visitOriginalResponseHeaders(in nsIHttpHeaderVisitor aVisitor);
/**
@ -389,7 +392,7 @@ interface nsIHttpChannel : nsIChannel
* @throws NS_ERROR_NOT_AVAILABLE if called before the response
* has been received (before onStartRequest).
*/
boolean isNoStoreResponse();
[must_use] boolean isNoStoreResponse();
/**
* Returns true if the server sent the equivalent of a "Cache-control:
@ -400,7 +403,7 @@ interface nsIHttpChannel : nsIChannel
* @throws NS_ERROR_NOT_AVAILABLE if called before the response
* has been received (before onStartRequest).
*/
boolean isNoCacheResponse();
[must_use] boolean isNoCacheResponse();
/**
* Returns true if the server sent a "Cache-Control: private" response
@ -409,7 +412,7 @@ interface nsIHttpChannel : nsIChannel
* @throws NS_ERROR_NOT_AVAILABLE if called before the response
* has been received (before onStartRequest).
*/
boolean isPrivateResponse();
[must_use] boolean isPrivateResponse();
/**
* Instructs the channel to immediately redirect to a new destination.
@ -439,25 +442,25 @@ interface nsIHttpChannel : nsIChannel
* @throws NS_ERROR_NOT_AVAILABLE if called after the channel has already
* started to deliver the content to its listener.
*/
void redirectTo(in nsIURI aTargetURI);
[must_use] void redirectTo(in nsIURI aTargetURI);
/**
* Identifies the request context for this load.
*/
[noscript] attribute nsID requestContextID;
[noscript, must_use] attribute nsID requestContextID;
/**
* Unique ID of the channel, shared between parent and child. Needed if
* the channel activity needs to be monitored across process boundaries,
* like in devtools net monitor. See bug 1274556.
*/
attribute ACString channelId;
[must_use] attribute ACString channelId;
/**
* ID of the top-level document's inner window. Identifies the content
* this channels is being load in.
*/
attribute uint64_t topLevelContentWindowId;
[must_use] attribute uint64_t topLevelContentWindowId;
/**
* Returns true if the channel has loaded a resource that is on the tracking

View File

@ -32,7 +32,7 @@ interface nsIHttpChannelAuthProvider : nsICancelable
* Initializes the http authentication support for the channel.
* Implementations must hold a weak reference of the channel.
*/
void init(in nsIHttpAuthenticableChannel channel);
[must_use] void init(in nsIHttpAuthenticableChannel channel);
/**
* Upon receipt of a server challenge, this function is called to determine
@ -53,8 +53,8 @@ interface nsIHttpChannelAuthProvider : nsICancelable
* nsIHttpAuthenticableChannel's methods or
* until disconnect be called.
*/
void processAuthentication(in unsigned long httpStatus,
in boolean sslConnectFailed);
[must_use] void processAuthentication(in unsigned long httpStatus,
in boolean sslConnectFailed);
/**
* Add credentials from the http auth cache.
@ -63,17 +63,17 @@ interface nsIHttpChannelAuthProvider : nsICancelable
* When true, the method will not add any Authorization headers from
* the auth cache.
*/
void addAuthorizationHeaders(in boolean dontUseCachedWWWCreds);
[must_use] void addAuthorizationHeaders(in boolean dontUseCachedWWWCreds);
/**
* Check if an unnecessary(and maybe malicious) url authentication has been
* provided.
*/
void checkForSuperfluousAuth();
[must_use] void checkForSuperfluousAuth();
/**
* Cancel pending user auth prompts and release the callback and channel
* weak references.
*/
void disconnect(in nsresult status);
[must_use] void disconnect(in nsresult status);
};

View File

@ -14,15 +14,16 @@ interface nsIURI;
[uuid(d02b96ed-2789-4f42-a25c-7abe63de7c18)]
interface nsIHttpChannelChild : nsISupports
{
void addCookiesToRequest();
[must_use] void addCookiesToRequest();
// Mark this channel as requiring an interception; this will propagate
// to the corresponding parent channel when a redirect occurs.
[must_use]
void forceIntercepted(in boolean postRedirectChannelShouldIntercept,
in boolean postRedirectChannelShouldUpgrade);
// Headers that the channel client has set via SetRequestHeader.
readonly attribute RequestHeaderTuples clientSetRequestHeaders;
[must_use] readonly attribute RequestHeaderTuples clientSetRequestHeaders;
// Headers that the channel client has set via SetRequestHeader.
[notxpcom, nostdcall]
@ -30,5 +31,6 @@ interface nsIHttpChannelChild : nsISupports
// This method is called by nsCORSListenerProxy if we need to remove
// an entry from the CORS preflight cache in the parent process.
[must_use]
void removeCorsPreflightCacheEntry(in nsIURI aURI, in nsIPrincipal aRequestingPrincipal);
};

View File

@ -29,9 +29,9 @@ interface nsIURI;
[scriptable, uuid(5b515449-ab64-4dba-b3cd-da8fc2f83064)]
interface nsIHttpUpgradeListener : nsISupports
{
void onTransportAvailable(in nsISocketTransport aTransport,
in nsIAsyncInputStream aSocketIn,
in nsIAsyncOutputStream aSocketOut);
[must_use] void onTransportAvailable(in nsISocketTransport aTransport,
in nsIAsyncInputStream aSocketIn,
in nsIAsyncOutputStream aSocketOut);
};
/**
@ -45,23 +45,26 @@ interface nsIHttpChannelInternal : nsISupports
/**
* An http channel can own a reference to the document URI
*/
attribute nsIURI documentURI;
[must_use] attribute nsIURI documentURI;
/**
* Get the major/minor version numbers for the request
*/
[must_use]
void getRequestVersion(out unsigned long major, out unsigned long minor);
/**
* Get the major/minor version numbers for the response
*/
[must_use]
void getResponseVersion(out unsigned long major, out unsigned long minor);
/*
* Retrieves all security messages from the security message queue
* and empties the queue after retrieval
*/
[noscript] void takeAllSecurityMessages(in securityMessagesArray aMessages);
[noscript, must_use]
void takeAllSecurityMessages(in securityMessagesArray aMessages);
/**
* Helper method to set a cookie with a consumer-provided
@ -71,12 +74,12 @@ interface nsIHttpChannelInternal : nsISupports
* @param aCookieHeader
* The cookie header to be parsed.
*/
void setCookie(in string aCookieHeader);
[must_use] void setCookie(in string aCookieHeader);
/**
* Setup this channel as an application cache fallback channel.
*/
void setupFallbackChannel(in string aFallbackKey);
[must_use] void setupFallbackChannel(in string aFallbackKey);
/**
* This flag is set to force relevant cookies to be sent with this load
@ -88,25 +91,25 @@ interface nsIHttpChannelInternal : nsISupports
* When set, these flags modify the algorithm used to decide whether to
* send 3rd party cookies for a given channel.
*/
attribute unsigned long thirdPartyFlags;
[must_use] attribute unsigned long thirdPartyFlags;
/**
* This attribute was added before the "flags" above and is retained here
* for compatibility. When set to true, has the same effect as
* THIRD_PARTY_FORCE_ALLOW, described above.
*/
attribute boolean forceAllowThirdPartyCookie;
[must_use] attribute boolean forceAllowThirdPartyCookie;
/**
* True iff the channel has been canceled.
*/
readonly attribute boolean canceled;
[must_use] readonly attribute boolean canceled;
/**
* External handlers may set this to true to notify the channel
* that it is open on behalf of a download.
*/
attribute boolean channelIsForDownload;
[must_use] attribute boolean channelIsForDownload;
/**
* The local IP address to which this channel is bound, in the
@ -118,7 +121,7 @@ interface nsIHttpChannelInternal : nsISupports
* endpoints are not yet determined, or in any case when
* nsIHttpActivityObserver.isActive is false. See bugs 534698 and 526207.
*/
readonly attribute AUTF8String localAddress;
[must_use] readonly attribute AUTF8String localAddress;
/**
* The local port number to which this channel is bound.
@ -127,7 +130,7 @@ interface nsIHttpChannelInternal : nsISupports
* endpoints are not yet determined, or in any case when
* nsIHttpActivityObserver.isActive is false. See bugs 534698 and 526207.
*/
readonly attribute int32_t localPort;
[must_use] readonly attribute int32_t localPort;
/**
* The IP address of the remote host that this channel is
@ -137,7 +140,7 @@ interface nsIHttpChannelInternal : nsISupports
* endpoints are not yet determined, or in any case when
* nsIHttpActivityObserver.isActive is false. See bugs 534698 and 526207.
*/
readonly attribute AUTF8String remoteAddress;
[must_use] readonly attribute AUTF8String remoteAddress;
/**
* The remote port number that this channel is connected to.
@ -146,12 +149,13 @@ interface nsIHttpChannelInternal : nsISupports
* endpoints are not yet determined, or in any case when
* nsIHttpActivityObserver.isActive is false. See bugs 534698 and 526207.
*/
readonly attribute int32_t remotePort;
[must_use] readonly attribute int32_t remotePort;
/**
* Transfer chain of redirected cache-keys.
*/
[noscript] void setCacheKeysRedirectChain(in StringArray cacheKeys);
[noscript, must_use]
void setCacheKeysRedirectChain(in StringArray cacheKeys);
/**
* HTTPUpgrade allows for the use of HTTP to bootstrap another protocol
@ -170,65 +174,65 @@ interface nsIHttpChannelInternal : nsISupports
* @param aListener
* The callback object used to handle a successful upgrade
*/
void HTTPUpgrade(in ACString aProtocolName,
in nsIHttpUpgradeListener aListener);
[must_use] void HTTPUpgrade(in ACString aProtocolName,
in nsIHttpUpgradeListener aListener);
/**
* Enable/Disable Spdy negotiation on per channel basis.
* The network.http.spdy.enabled preference is still a pre-requisite
* for starting spdy.
*/
attribute boolean allowSpdy;
[must_use] attribute boolean allowSpdy;
/**
* This attribute en/disables the timeout for the first byte of an HTTP
* response. Enabled by default.
*/
attribute boolean responseTimeoutEnabled;
[must_use] attribute boolean responseTimeoutEnabled;
/**
* If the underlying transport supports RWIN manipulation, this is the
* intiial window value for the channel. HTTP/2 implements this.
* 0 means no override from system default. Set before opening channel.
*/
attribute unsigned long initialRwin;
[must_use] attribute unsigned long initialRwin;
/**
* Get value of the URI passed to nsIHttpChannel.redirectTo() if any.
* May return null when redirectTo() has not been called.
*/
readonly attribute nsIURI apiRedirectToURI;
[must_use] readonly attribute nsIURI apiRedirectToURI;
/**
* Enable/Disable use of Alternate Services with this channel.
* The network.http.altsvc.enabled preference is still a pre-requisite.
*/
attribute boolean allowAltSvc;
[must_use] attribute boolean allowAltSvc;
/**
* If true, do not use newer protocol features that might have interop problems
* on the Internet. Intended only for use with critical infra like the updater.
* default is false.
*/
attribute boolean beConservative;
[must_use] attribute boolean beConservative;
readonly attribute PRTime lastModifiedTime;
[must_use] readonly attribute PRTime lastModifiedTime;
/**
* Force a channel that has not been AsyncOpen'ed to skip any check for possible
* interception and proceed immediately to open a previously-synthesized cache
* entry using the provided ID.
*/
void forceIntercepted(in uint64_t aInterceptionID);
[must_use] void forceIntercepted(in uint64_t aInterceptionID);
readonly attribute boolean responseSynthesized;
[must_use] readonly attribute boolean responseSynthesized;
/**
* Set by nsCORSListenerProxy if credentials should be included in
* cross-origin requests. false indicates "same-origin", users should still
* check flag LOAD_ANONYMOUS!
*/
attribute boolean corsIncludeCredentials;
[must_use] attribute boolean corsIncludeCredentials;
const unsigned long CORS_MODE_SAME_ORIGIN = 0;
const unsigned long CORS_MODE_NO_CORS = 1;
@ -237,7 +241,7 @@ interface nsIHttpChannelInternal : nsISupports
/**
* Set by nsCORSListenerProxy to indicate CORS load type. Defaults to CORS_MODE_NO_CORS.
*/
attribute unsigned long corsMode;
[must_use] attribute unsigned long corsMode;
const unsigned long REDIRECT_MODE_FOLLOW = 0;
const unsigned long REDIRECT_MODE_ERROR = 1;
@ -247,7 +251,7 @@ interface nsIHttpChannelInternal : nsISupports
* interception. No policy enforcement is performed by the channel for this
* value.
*/
attribute unsigned long redirectMode;
[must_use] attribute unsigned long redirectMode;
const unsigned long FETCH_CACHE_MODE_DEFAULT = 0;
const unsigned long FETCH_CACHE_MODE_NO_STORE = 1;
@ -260,23 +264,23 @@ interface nsIHttpChannelInternal : nsISupports
* semantics, and is also used for exposing this value to the Web page
* during service worker interception.
*/
attribute unsigned long fetchCacheMode;
[must_use] attribute unsigned long fetchCacheMode;
/**
* The URI of the top-level window that's associated with this channel.
*/
readonly attribute nsIURI topWindowURI;
[must_use] readonly attribute nsIURI topWindowURI;
/**
* The network interface id that's associated with this channel.
*/
attribute ACString networkInterfaceId;
[must_use] attribute ACString networkInterfaceId;
/**
* Read the proxy URI, which, if non-null, will be used to resolve
* proxies for this channel.
*/
readonly attribute nsIURI proxyURI;
[must_use] readonly attribute nsIURI proxyURI;
/**
* Make cross-origin CORS loads happen with a CORS preflight, and specify
@ -297,10 +301,10 @@ interface nsIHttpChannelInternal : nsISupports
/**
* Set to indicate Request.integrity.
*/
attribute AString integrityMetadata;
[must_use] attribute AString integrityMetadata;
/**
* The connection info's hash key. We use it to test connection separation.
*/
readonly attribute ACString connectionInfoHashKey;
[must_use] readonly attribute ACString connectionInfoHashKey;
};

View File

@ -32,6 +32,6 @@ interface nsIHttpEventSink : nsISupports
*
* @return failure cancels redirect
*/
void onRedirect(in nsIHttpChannel httpChannel,
in nsIChannel newChannel);
[must_use] void onRedirect(in nsIHttpChannel httpChannel,
in nsIChannel newChannel);
};

View File

@ -22,5 +22,5 @@ interface nsIHttpHeaderVisitor : nsISupports
*
* @throw any exception to terminate enumeration
*/
void visitHeader(in ACString aHeader, in ACString aValue);
[must_use] void visitHeader(in ACString aHeader, in ACString aValue);
};

View File

@ -11,21 +11,21 @@ interface nsIHttpProtocolHandler : nsIProxiedProtocolHandler
/**
* Get the HTTP advertised user agent string.
*/
readonly attribute ACString userAgent;
[must_use] readonly attribute ACString userAgent;
/**
* Get the application name.
*
* @return The name of this application (eg. "Mozilla").
*/
readonly attribute ACString appName;
[must_use] readonly attribute ACString appName;
/**
* Get the application version string.
*
* @return The complete version (major and minor) string. (eg. "5.0")
*/
readonly attribute ACString appVersion;
[must_use] readonly attribute ACString appVersion;
/**
* Get the current platform.
@ -33,19 +33,19 @@ interface nsIHttpProtocolHandler : nsIProxiedProtocolHandler
* @return The platform this application is running on
* (eg. "Windows", "Macintosh", "X11")
*/
readonly attribute ACString platform;
[must_use] readonly attribute ACString platform;
/**
* Get the current oscpu.
*
* @return The oscpu this application is running on
*/
readonly attribute ACString oscpu;
[must_use] readonly attribute ACString oscpu;
/**
* Get the application comment misc portion.
*/
readonly attribute ACString misc;
[must_use] readonly attribute ACString misc;
};

View File

@ -16,11 +16,11 @@
[scriptable, uuid(b4f96c89-5238-450c-8bda-e12c26f1d150)]
interface nsIWellKnownOpportunisticUtils : nsISupports
{
void verify(in ACString aJSON,
[must_use] void verify(in ACString aJSON,
in ACString aOrigin,
in long aAlternatePort);
readonly attribute bool valid;
readonly attribute bool mixed; /* mixed-scheme */
readonly attribute long lifetime;
[must_use] readonly attribute bool valid;
[must_use] readonly attribute bool mixed; /* mixed-scheme */
[must_use] readonly attribute long lifetime;
};