diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp
index 8333a40be51..93b1e8e3129 100644
--- a/mozilla/content/html/document/src/nsHTMLDocument.cpp
+++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp
@@ -16,6 +16,7 @@
* Reserved.
*/
#include "nsCOMPtr.h"
+#include "nsXPIDLString.h"
#include "nsHTMLDocument.h"
#include "nsIParser.h"
#include "nsIParserFilter.h"
@@ -70,7 +71,7 @@
#include "nsGenericHTMLElement.h"
#include "nsGenericDOMNodeList.h"
#include "nsICSSLoader.h"
-
+#include "nsIHTTPChannel.h"
#include "nsICharsetDetector.h"
#include "nsICharsetDetectionAdaptor.h"
@@ -140,7 +141,8 @@ nsHTMLDocument::nsHTMLDocument()
mAttrStyleSheet(nsnull),
mStyleAttrStyleSheet(nsnull),
mBaseURL(nsnull),
- mBaseTarget(nsnull)
+ mBaseTarget(nsnull),
+ mLastModified(nsnull)
{
mImages = nsnull;
mApplets = nsnull;
@@ -197,6 +199,10 @@ nsHTMLDocument::~nsHTMLDocument()
delete mBaseTarget;
mBaseTarget = nsnull;
}
+ if (nsnull != mLastModified) {
+ delete mLastModified;
+ mLastModified = nsnull;
+ }
NS_IF_RELEASE(mParser);
for (i = 0; i < mImageMaps.Count(); i++) {
nsIDOMHTMLMapElement* map = (nsIDOMHTMLMapElement*)mImageMaps.ElementAt(i);
@@ -372,6 +378,25 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
nsCOMPtr aURL;
rv = aChannel->GetURI(getter_AddRefs(aURL));
if (NS_FAILED(rv)) return rv;
+
+ nsCOMPtr httpChannel = do_QueryInterface(aChannel);
+ if (httpChannel) {
+ nsXPIDLCString header;
+ nsAutoString lastModified;
+ nsIAtom* key = NS_NewAtom("last-modified");
+
+ rv = httpChannel->GetResponseHeader(key,
+ getter_Copies(header));
+
+ NS_RELEASE(key);
+ if (NS_SUCCEEDED(rv)) {
+ lastModified = header;
+ SetLastModified(lastModified);
+ }
+ // Don't propogate the result code beyond here, since it
+ // could just be that the response header wasn't found.
+ rv = NS_OK;
+ }
#endif
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
@@ -757,6 +782,25 @@ nsHTMLDocument:: SetBaseTarget(const nsString& aTarget)
return NS_OK;
}
+NS_IMETHODIMP
+nsHTMLDocument::SetLastModified(const nsString& aLastModified)
+{
+ if (0 < aLastModified.Length()) {
+ if (nsnull != mLastModified) {
+ *mLastModified = aLastModified;
+ }
+ else {
+ mLastModified = aLastModified.ToNewString();
+ }
+ }
+ else if (nsnull != mLastModified) {
+ delete mLastModified;
+ mLastModified = nsnull;
+ }
+
+ return NS_OK;
+}
+
NS_IMETHODIMP
nsHTMLDocument::GetCSSLoader(nsICSSLoader*& aLoader)
{
@@ -1956,7 +2000,13 @@ NS_IMETHODIMP
nsHTMLDocument::GetLastModified(nsString& aLastModified)
{
//XXX TBImplemented
- aLastModified.Truncate();
+ if (nsnull != mLastModified) {
+ aLastModified = *mLastModified;
+ }
+ else {
+ aLastModified.SetString("January 1, 1970 GMT");
+ }
+
return NS_OK;
}
diff --git a/mozilla/content/html/document/src/nsHTMLDocument.h b/mozilla/content/html/document/src/nsHTMLDocument.h
index a6bf843a145..05782f9d555 100644
--- a/mozilla/content/html/document/src/nsHTMLDocument.h
+++ b/mozilla/content/html/document/src/nsHTMLDocument.h
@@ -87,6 +87,8 @@ public:
NS_IMETHOD GetBaseTarget(nsString& aTarget) const;
NS_IMETHOD SetBaseTarget(const nsString& aTarget);
+ NS_IMETHOD SetLastModified(const nsString& aLastModified);
+
NS_IMETHOD GetDTDMode(nsDTDMode& aMode);
NS_IMETHOD SetDTDMode(nsDTDMode aMode);
@@ -204,6 +206,7 @@ protected:
nsIHTMLCSSStyleSheet* mStyleAttrStyleSheet;
nsIURI* mBaseURL;
nsString* mBaseTarget;
+ nsString* mLastModified;
nsDTDMode mDTDMode;
nsVoidArray mImageMaps;
nsICSSLoader* mCSSLoader;
diff --git a/mozilla/content/html/document/src/nsIHTMLDocument.h b/mozilla/content/html/document/src/nsIHTMLDocument.h
index d00110172bc..fc85a47542f 100644
--- a/mozilla/content/html/document/src/nsIHTMLDocument.h
+++ b/mozilla/content/html/document/src/nsIHTMLDocument.h
@@ -63,6 +63,8 @@ public:
NS_IMETHOD GetBaseTarget(nsString& aTarget) const = 0;
NS_IMETHOD SetBaseTarget(const nsString& aTarget) = 0;
+ NS_IMETHOD SetLastModified(const nsString& aLastModified) = 0;
+
/**
* Access DTD compatibility mode for this document
*/
diff --git a/mozilla/layout/html/document/src/nsHTMLDocument.cpp b/mozilla/layout/html/document/src/nsHTMLDocument.cpp
index 8333a40be51..93b1e8e3129 100644
--- a/mozilla/layout/html/document/src/nsHTMLDocument.cpp
+++ b/mozilla/layout/html/document/src/nsHTMLDocument.cpp
@@ -16,6 +16,7 @@
* Reserved.
*/
#include "nsCOMPtr.h"
+#include "nsXPIDLString.h"
#include "nsHTMLDocument.h"
#include "nsIParser.h"
#include "nsIParserFilter.h"
@@ -70,7 +71,7 @@
#include "nsGenericHTMLElement.h"
#include "nsGenericDOMNodeList.h"
#include "nsICSSLoader.h"
-
+#include "nsIHTTPChannel.h"
#include "nsICharsetDetector.h"
#include "nsICharsetDetectionAdaptor.h"
@@ -140,7 +141,8 @@ nsHTMLDocument::nsHTMLDocument()
mAttrStyleSheet(nsnull),
mStyleAttrStyleSheet(nsnull),
mBaseURL(nsnull),
- mBaseTarget(nsnull)
+ mBaseTarget(nsnull),
+ mLastModified(nsnull)
{
mImages = nsnull;
mApplets = nsnull;
@@ -197,6 +199,10 @@ nsHTMLDocument::~nsHTMLDocument()
delete mBaseTarget;
mBaseTarget = nsnull;
}
+ if (nsnull != mLastModified) {
+ delete mLastModified;
+ mLastModified = nsnull;
+ }
NS_IF_RELEASE(mParser);
for (i = 0; i < mImageMaps.Count(); i++) {
nsIDOMHTMLMapElement* map = (nsIDOMHTMLMapElement*)mImageMaps.ElementAt(i);
@@ -372,6 +378,25 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
nsCOMPtr aURL;
rv = aChannel->GetURI(getter_AddRefs(aURL));
if (NS_FAILED(rv)) return rv;
+
+ nsCOMPtr httpChannel = do_QueryInterface(aChannel);
+ if (httpChannel) {
+ nsXPIDLCString header;
+ nsAutoString lastModified;
+ nsIAtom* key = NS_NewAtom("last-modified");
+
+ rv = httpChannel->GetResponseHeader(key,
+ getter_Copies(header));
+
+ NS_RELEASE(key);
+ if (NS_SUCCEEDED(rv)) {
+ lastModified = header;
+ SetLastModified(lastModified);
+ }
+ // Don't propogate the result code beyond here, since it
+ // could just be that the response header wasn't found.
+ rv = NS_OK;
+ }
#endif
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
@@ -757,6 +782,25 @@ nsHTMLDocument:: SetBaseTarget(const nsString& aTarget)
return NS_OK;
}
+NS_IMETHODIMP
+nsHTMLDocument::SetLastModified(const nsString& aLastModified)
+{
+ if (0 < aLastModified.Length()) {
+ if (nsnull != mLastModified) {
+ *mLastModified = aLastModified;
+ }
+ else {
+ mLastModified = aLastModified.ToNewString();
+ }
+ }
+ else if (nsnull != mLastModified) {
+ delete mLastModified;
+ mLastModified = nsnull;
+ }
+
+ return NS_OK;
+}
+
NS_IMETHODIMP
nsHTMLDocument::GetCSSLoader(nsICSSLoader*& aLoader)
{
@@ -1956,7 +2000,13 @@ NS_IMETHODIMP
nsHTMLDocument::GetLastModified(nsString& aLastModified)
{
//XXX TBImplemented
- aLastModified.Truncate();
+ if (nsnull != mLastModified) {
+ aLastModified = *mLastModified;
+ }
+ else {
+ aLastModified.SetString("January 1, 1970 GMT");
+ }
+
return NS_OK;
}
diff --git a/mozilla/layout/html/document/src/nsHTMLDocument.h b/mozilla/layout/html/document/src/nsHTMLDocument.h
index a6bf843a145..05782f9d555 100644
--- a/mozilla/layout/html/document/src/nsHTMLDocument.h
+++ b/mozilla/layout/html/document/src/nsHTMLDocument.h
@@ -87,6 +87,8 @@ public:
NS_IMETHOD GetBaseTarget(nsString& aTarget) const;
NS_IMETHOD SetBaseTarget(const nsString& aTarget);
+ NS_IMETHOD SetLastModified(const nsString& aLastModified);
+
NS_IMETHOD GetDTDMode(nsDTDMode& aMode);
NS_IMETHOD SetDTDMode(nsDTDMode aMode);
@@ -204,6 +206,7 @@ protected:
nsIHTMLCSSStyleSheet* mStyleAttrStyleSheet;
nsIURI* mBaseURL;
nsString* mBaseTarget;
+ nsString* mLastModified;
nsDTDMode mDTDMode;
nsVoidArray mImageMaps;
nsICSSLoader* mCSSLoader;
diff --git a/mozilla/layout/html/document/src/nsIHTMLDocument.h b/mozilla/layout/html/document/src/nsIHTMLDocument.h
index d00110172bc..fc85a47542f 100644
--- a/mozilla/layout/html/document/src/nsIHTMLDocument.h
+++ b/mozilla/layout/html/document/src/nsIHTMLDocument.h
@@ -63,6 +63,8 @@ public:
NS_IMETHOD GetBaseTarget(nsString& aTarget) const = 0;
NS_IMETHOD SetBaseTarget(const nsString& aTarget) = 0;
+ NS_IMETHOD SetLastModified(const nsString& aLastModified) = 0;
+
/**
* Access DTD compatibility mode for this document
*/