aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cache.c9
-rw-r--r--src/cache.h1
-rw-r--r--src/capi.c27
-rw-r--r--src/capi.h1
-rw-r--r--src/html.cc14
5 files changed, 42 insertions, 10 deletions
diff --git a/src/cache.c b/src/cache.c
index 38b1e672..ae8a512d 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -414,6 +414,15 @@ int a_Cache_open_url(void *web, CA_Callback_t Call, void *CbData)
*/
uint_t a_Cache_get_flags(const DilloUrl *url)
{
+ CacheEntry_t *entry = Cache_entry_search(url);
+ return (entry ? entry->Flags : 0);
+}
+
+/*
+ * Get cache entry status (following redirections).
+ */
+uint_t a_Cache_get_flags_with_redirection(const DilloUrl *url)
+{
CacheEntry_t *entry = Cache_entry_search_with_redirect(url);
return (entry ? entry->Flags : 0);
}
diff --git a/src/cache.h b/src/cache.h
index bbcb9a22..ff286a0e 100644
--- a/src/cache.h
+++ b/src/cache.h
@@ -65,6 +65,7 @@ const char *a_Cache_get_content_type(const DilloUrl *url);
const char *a_Cache_set_content_type(const DilloUrl *url, const char *ctype,
const char *from);
uint_t a_Cache_get_flags(const DilloUrl *url);
+uint_t a_Cache_get_flags_with_redirection(const DilloUrl *url);
void a_Cache_process_dbuf(int Op, const char *buf, size_t buf_size,
const DilloUrl *Url);
void a_Cache_entry_inject(const DilloUrl *Url, Dstr *data_ds);
diff --git a/src/capi.c b/src/capi.c
index 8220e206..faa3035e 100644
--- a/src/capi.c
+++ b/src/capi.c
@@ -314,7 +314,7 @@ int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData)
if (web->flags & WEB_Download) {
/* download request: if cached save from cache, else
* for http, ftp or https, use the downloads dpi */
- if (a_Capi_get_flags(web->url) & CAPI_IsCached) {
+ if (a_Capi_get_flags_with_redirection(web->url) & CAPI_IsCached) {
if (web->filename) {
if ((web->stream = fopen(web->filename, "w"))) {
use_cache = 1;
@@ -376,12 +376,11 @@ int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData)
}
/*
- * Return status information of an URL's content-transfer process.
+ * Convert cache-defined flags to Capi ones.
*/
-int a_Capi_get_flags(const DilloUrl *Url)
+static int Capi_map_cache_flags(uint_t flags)
{
int status = 0;
- uint_t flags = a_Cache_get_flags(Url);
if (flags) {
status |= CAPI_IsCached;
@@ -398,6 +397,26 @@ int a_Capi_get_flags(const DilloUrl *Url)
}
/*
+ * Return status information of an URL's content-transfer process.
+ */
+int a_Capi_get_flags(const DilloUrl *Url)
+{
+ uint_t flags = a_Cache_get_flags(Url);
+ int status = flags ? Capi_map_cache_flags(flags) : 0;
+ return status;
+}
+
+/*
+ * Same as a_Capi_get_flags() but following redirections.
+ */
+int a_Capi_get_flags_with_redirection(const DilloUrl *Url)
+{
+ uint_t flags = a_Cache_get_flags_with_redirection(Url);
+ int status = flags ? Capi_map_cache_flags(flags) : 0;
+ return status;
+}
+
+/*
* Get the cache's buffer for the URL, and its size.
* Return: 1 cached, 0 not cached.
*/
diff --git a/src/capi.h b/src/capi.h
index 3bfc313e..94a8d1c4 100644
--- a/src/capi.h
+++ b/src/capi.h
@@ -29,6 +29,7 @@ const char *a_Capi_get_content_type(const DilloUrl *url);
const char *a_Capi_set_content_type(const DilloUrl *url, const char *ctype,
const char *from);
int a_Capi_get_flags(const DilloUrl *Url);
+int a_Capi_get_flags_with_redirection(const DilloUrl *Url);
int a_Capi_dpi_send_cmd(DilloUrl *url, void *bw, char *cmd, char *server,
int flags);
void a_Capi_stop_client(int Key, int force);
diff --git a/src/html.cc b/src/html.cc
index d887b620..ea178277 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -1805,9 +1805,11 @@ static void Html_tag_open_frame (DilloHtml *html, const char *tag, int tagsize)
src = dStrdup(attrbuf);
- if (a_Capi_get_flags(url) & CAPI_IsCached) { /* visited frame */
+ if (a_Capi_get_flags_with_redirection(url) & CAPI_IsCached) {
+ /* visited frame */
html->styleEngine->setPseudoVisited ();
- } else { /* unvisited frame */
+ } else {
+ /* unvisited frame */
html->styleEngine->setPseudoLink ();
}
@@ -2067,7 +2069,7 @@ DilloImage *a_Html_image_new(DilloHtml *html, const char *tag,
Image->bg_color = DW2TB(html->dw)->getBgColor()->getColor();
load_now = prefs.load_images ||
- (a_Capi_get_flags(url) & CAPI_IsCached);
+ (a_Capi_get_flags_with_redirection(url) & CAPI_IsCached);
Html_add_new_linkimage(html, &url, load_now ? NULL : Image);
if (load_now)
Html_load_image(html->bw, url, Image);
@@ -2312,7 +2314,7 @@ static void Html_tag_open_object(DilloHtml *html, const char *tag, int tagsize)
URL_STR(base_url), (base_url != NULL));
dReturn_if_fail ( url != NULL );
- if (a_Capi_get_flags(url) & CAPI_IsCached) {
+ if (a_Capi_get_flags_with_redirection(url) & CAPI_IsCached) {
html->styleEngine->setPseudoVisited ();
} else {
html->styleEngine->setPseudoLink ();
@@ -2389,7 +2391,7 @@ static void Html_tag_open_a(DilloHtml *html, const char *tag, int tagsize)
url = a_Html_url_new(html, attrbuf, NULL, 0);
dReturn_if_fail ( url != NULL );
- if (a_Capi_get_flags(url) & CAPI_IsCached) {
+ if (a_Capi_get_flags_with_redirection(url) & CAPI_IsCached) {
html->InVisitedLink = true;
html->styleEngine->setPseudoVisited ();
if (html->non_css_visited_color != -1)
@@ -2883,7 +2885,7 @@ void a_Html_load_stylesheet(DilloHtml *html, DilloUrl *url)
_MSG("Html_load_stylesheet: ");
if (a_Capi_get_buf(url, &data, &len)) {
_MSG("cached URL=%s len=%d", URL_STR(url), len);
- if (a_Capi_get_flags(url) & CAPI_Completed)
+ if (a_Capi_get_flags_with_redirection(url) & CAPI_Completed)
html->styleEngine->parse(html, url, data, len, CSS_ORIGIN_AUTHOR);
a_Capi_unref_buf(url);
} else {