Bug 758973 - Make handling of status code 308 more consistent. r=bsmith

This commit is contained in:
julian.reschke@gmx.de 2012-09-22 11:27:17 -04:00
parent ec8c04607a
commit 9d97b3ceb2
4 changed files with 12 additions and 2 deletions

View File

@ -286,3 +286,10 @@ nsHttp::ParseInt64(const char *input, const char **next, int64_t *r)
*next = input;
return true;
}
bool
nsHttp::IsPermanentRedirect(PRUint32 httpStatus)
{
return httpStatus == 301 || httpStatus == 308;
}

View File

@ -180,6 +180,9 @@ struct nsHttp
return ParseInt64(input, &next, result) && *next == '\0';
}
// Return whether the HTTP status code represents a permanent redirect
static bool IsPermanentRedirect(PRUint32 httpStatus);
// Declare all atoms
//
// The atom names and values are stored in nsHttpAtomList.h and are brought

View File

@ -4101,7 +4101,7 @@ nsHttpChannel::ContinueProcessRedirectionAfterFallback(nsresult rv)
if (NS_FAILED(rv)) return rv;
uint32_t redirectFlags;
if (mRedirectType == 301) // Moved Permanently
if (nsHttp::IsPermanentRedirect(mRedirectType))
redirectFlags = nsIChannelEventSink::REDIRECT_PERMANENT;
else
redirectFlags = nsIChannelEventSink::REDIRECT_TEMPORARY;

View File

@ -290,7 +290,7 @@ nsHttpResponseHead::ComputeFreshnessLifetime(uint32_t *result) const
}
// These responses can be cached indefinitely.
if ((mStatus == 300) || (mStatus == 301)) {
if ((mStatus == 300) || nsHttp::IsPermanentRedirect(mStatus)) {
*result = uint32_t(-1);
return NS_OK;
}