Bug 1363848 P1 Record the last redirect flags on the http channel. r=dragana

This commit is contained in:
Ben Kelly 2017-06-15 07:52:41 -07:00
parent fb3f580b62
commit 92ebf95b57
3 changed files with 37 additions and 2 deletions

View File

@ -209,6 +209,7 @@ HttpBaseChannel::HttpBaseChannel()
, mAltDataLength(0)
, mForceMainDocumentChannel(false)
, mIsTrackingResource(false)
, mLastRedirectFlags(0)
{
LOG(("Creating HttpBaseChannel @%p\n", this));
@ -3249,8 +3250,12 @@ HttpBaseChannel::SetupReplacementChannel(nsIURI *newURI,
// Preserve the CORS preflight information.
nsCOMPtr<nsIHttpChannelInternal> httpInternal = do_QueryInterface(newChannel);
if (mRequireCORSPreflight && httpInternal) {
httpInternal->SetCorsPreflightParameters(mUnsafeHeaders);
if (httpInternal) {
httpInternal->SetLastRedirectFlags(redirectFlags);
if (mRequireCORSPreflight) {
httpInternal->SetCorsPreflightParameters(mUnsafeHeaders);
}
}
if (preserveMethod) {
@ -4063,5 +4068,20 @@ HttpBaseChannel::GetConnectionInfoHashKey(nsACString& aConnectionInfoHashKey)
return NS_OK;
}
NS_IMETHODIMP
HttpBaseChannel::GetLastRedirectFlags(uint32_t *aValue)
{
NS_ENSURE_ARG(aValue);
*aValue = mLastRedirectFlags;
return NS_OK;
}
NS_IMETHODIMP
HttpBaseChannel::SetLastRedirectFlags(uint32_t aValue)
{
mLastRedirectFlags = aValue;
return NS_OK;
}
} // namespace net
} // namespace mozilla

View File

@ -261,6 +261,8 @@ public:
NS_IMETHOD GetConnectionInfoHashKey(nsACString& aConnectionInfoHashKey) override;
NS_IMETHOD GetIntegrityMetadata(nsAString& aIntegrityMetadata) override;
NS_IMETHOD SetIntegrityMetadata(const nsAString& aIntegrityMetadata) override;
NS_IMETHOD GetLastRedirectFlags(uint32_t *aValue) override;
NS_IMETHOD SetLastRedirectFlags(uint32_t aValue) override;
inline void CleanRedirectCacheChainIfNecessary()
{
@ -631,6 +633,11 @@ protected:
uint64_t mChannelId;
// If this channel was created as the result of a redirect, then this value
// will reflect the redirect flags passed to the SetupReplacementChannel()
// method.
uint32_t mLastRedirectFlags;
nsString mIntegrityMetadata;
// Classified channel's matched information

View File

@ -314,4 +314,12 @@ interface nsIHttpChannelInternal : nsISupports
* The connection info's hash key. We use it to test connection separation.
*/
[must_use] readonly attribute ACString connectionInfoHashKey;
/**
* If this channel was created as the result of a redirect, then this
* value will reflect the redirect flags passed to the
* SetupReplacementChannel() method.
*/
[noscript, infallible]
attribute unsigned long lastRedirectFlags;
};