/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
nsresult nsAboutCacheEntry::Channel::WriteCacheEntryDescription(
nsICacheEntry* entry) {
nsresult rv; // This method appears to run in a situation where the run-time stack // should have plenty of space, so allocating a large string on the // stack is OK.
nsAutoCStringN<4097> buffer;
uint32_t n;
nsAutoCString str;
rv = entry->GetKey(str); if (NS_FAILED(rv)) return rv;
buffer.AssignLiteral( "
\n" "
\n" "
key:
\n" "
td-key\">");
// Test if the key is actually a URI
nsCOMPtr<nsIURI> uri;
rv = NS_NewURI(getter_AddRefs(uri), str);
// Last Fetched
entry->GetLastFetched(&u); if (u) {
PrintTimeString(timeBuf, sizeof(timeBuf), u);
APPEND_ROW("last fetched", timeBuf);
} else {
APPEND_ROW("last fetched", "No last fetch time (bug 1000338)");
}
// Last Modified
entry->GetLastModified(&u); if (u) {
PrintTimeString(timeBuf, sizeof(timeBuf), u);
APPEND_ROW("last modified", timeBuf);
} else {
APPEND_ROW("last modified", "No last modified time (bug 1000338)");
}
// Expiration Time
entry->GetExpirationTime(&u);
// Bug - 633747. // When expiration time is 0, we show 1970-01-01 01:00:00 which is confusing. // So we check if time is 0, then we show a message, "Expired Immediately" if (u == 0) {
APPEND_ROW("expires", "Expired Immediately");
} elseif (u < 0xFFFFFFFF) {
PrintTimeString(timeBuf, sizeof(timeBuf), u);
APPEND_ROW("expires", timeBuf);
} else {
APPEND_ROW("expires", "No expiration time");
}
// Data Size
s.Truncate();
uint32_t dataSize; if (NS_FAILED(entry->GetStorageDataSize(&dataSize))) dataSize = 0;
s.AppendInt(
(int32_t)dataSize); // XXX nsICacheEntryInfo interfaces should be fixed.
s.AppendLiteral(" B");
APPEND_ROW("Data size", s);
// TODO - mayhemer // Here used to be a link to the disk file (in the old cache for entries that // did not fit any of the block files, in the new cache every time). // I'd rather have a small set of buttons here to action on the entry: // 1. save the content // 2. save as a complete HTTP response (response head, headers, content) // 3. doom the entry // A new bug(s) should be filed here.
// Security Info
nsCOMPtr<nsITransportSecurityInfo> securityInfo;
entry->GetSecurityInfo(getter_AddRefs(securityInfo)); if (securityInfo) {
APPEND_ROW("Security", "This is a secure document.");
} else {
APPEND_ROW( "Security", "This document does not have any security info associated with it.");
}
buffer.AppendLiteral( "
\n" "\n" "
\n");
mBuffer = &buffer; // make it available for OnMetaDataElement().
entry->VisitMetaData(this);
mBuffer = nullptr;
// Provide a hexdump of the data if (!dataSize) { return NS_OK;
}
nsCOMPtr<nsIInputStream> stream;
entry->OpenInputStream(0, getter_AddRefs(stream)); if (!stream) { return NS_OK;
}
RefPtr<nsInputStreamPump> pump;
rv = nsInputStreamPump::Create(getter_AddRefs(pump), stream); if (NS_FAILED(rv)) { return NS_OK; // just ignore
}
rv = pump->AsyncRead(this); if (NS_FAILED(rv)) { return NS_OK; // just ignore
}
mWaitingForData = true; return NS_OK;
}
nsresult nsAboutCacheEntry::Channel::WriteCacheEntryUnavailable() {
uint32_t n;
constexpr auto buffer = "The cache entry you selected is not available."_ns;
mOutputStream->Write(buffer.get(), buffer.Length(), &n); return NS_OK;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.