Fixed bug 75709 "expires header not honored, gets cached copy"

r=gordon, sr=dougt, a=asa
This commit is contained in:
darin%netscape.com 2001-06-13 01:10:17 +00:00
Родитель a8e5c0b7bc
Коммит ba87abb6dd
2 изменённых файлов: 18 добавлений и 4 удалений

Просмотреть файл

@ -746,6 +746,20 @@ nsHttpChannel::CheckCache()
goto end;
}
// Compare the Expires header to the Date header. If the server sent an
// Expires header with a timestamp in the past, then we must validate this
// cached response before reusing.
{
PRUint32 expiresVal, dateVal;
if (NS_SUCCEEDED(mCachedResponseHead->GetExpiresValue(&expiresVal)) &&
NS_SUCCEEDED(mCachedResponseHead->GetDateValue(&dateVal)) &&
expiresVal < dateVal) {
LOG(("Validating since Expires < Date\n"));
doValidation = PR_TRUE;
goto end;
}
}
// Check the Vary header. Per comments on bug 37609, most of the request
// headers that we generate do not vary with the exception of Accept-Charset
// and Accept-Language, so we force validation only if these headers or "*"

Просмотреть файл

@ -81,10 +81,6 @@ public:
// reset the response head to it's initial state
void Reset();
private:
void ParseVersion(const char *);
nsresult ParseContentType(char *);
// these return failure if the header does not exist.
nsresult ParseDateHeader(nsHttpAtom header, PRUint32 *result);
nsresult GetAgeValue(PRUint32 *result);
@ -93,6 +89,10 @@ private:
nsresult GetExpiresValue(PRUint32 *result) { return ParseDateHeader(nsHttp::Expires, result); }
nsresult GetLastModifiedValue(PRUint32 *result) { return ParseDateHeader(nsHttp::Last_Modified, result); }
private:
void ParseVersion(const char *);
nsresult ParseContentType(char *);
private:
nsHttpHeaderArray mHeaders;
nsHttpVersion mVersion;