summaryrefslogtreecommitdiff
path: root/libsoup/soup-cache.c
diff options
context:
space:
mode:
authorSergio Villar Senin <svillar@igalia.com>2011-06-08 09:18:07 +0200
committerSergio Villar Senin <svillar@igalia.com>2011-06-08 09:18:07 +0200
commit5743afe84ad3bbad4c9e8876ddba8136ea4eb430 (patch)
treec7e9f033dd96932f1345a35ff163e77362539310 /libsoup/soup-cache.c
parentc56c66aa2625bc95f54f8a1972e13503f454a51a (diff)
downloadlibsoup-5743afe84ad3bbad4c9e8876ddba8136ea4eb430.tar.gz
soup-cache: update state of SoupMessages when returning data from the cache
SoupCache generates conditional requests to validate some resources. As the cache is transparent for the client it must update the state of the SoupMessage used by the SoupHTTPRequest as if the message was really transmitted over the network. SoupCache was not updating the state (basically status code and headers) of the SoupMessage that belongs to the SoupHTTPRequest but the one used for freshness validation. https://bugzilla.gnome.org/show_bug.cgi?id=649965
Diffstat (limited to 'libsoup/soup-cache.c')
-rw-r--r--libsoup/soup-cache.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/libsoup/soup-cache.c b/libsoup/soup-cache.c
index 70d865aa..5816e588 100644
--- a/libsoup/soup-cache.c
+++ b/libsoup/soup-cache.c
@@ -1008,6 +1008,19 @@ soup_cache_send_response (SoupCache *cache, SoupMessage *msg)
g_free (key);
g_return_val_if_fail (entry, NULL);
+ /* TODO: the original idea was to save reads, but current code
+ assumes that a stream is always returned. Need to reach
+ some agreement here. Also we have to handle the situation
+ were the file was no longer there (for example files
+ removed without notifying the cache */
+ file = g_file_new_for_path (entry->filename);
+ stream = G_INPUT_STREAM (g_file_read (file, NULL, NULL));
+ g_object_unref (file);
+
+ /* Do not change the original message if there is no resource */
+ if (stream == NULL)
+ return stream;
+
/* If we are told to send a response from cache any validation
in course is over by now */
entry->being_validated = FALSE;
@@ -1022,15 +1035,6 @@ soup_cache_send_response (SoupCache *cache, SoupMessage *msg)
current_age);
g_free (current_age);
- /* TODO: the original idea was to save reads, but current code
- assumes that a stream is always returned. Need to reach
- some agreement here. Also we have to handle the situation
- were the file was no longer there (for example files
- removed without notifying the cache */
- file = g_file_new_for_path (entry->filename);
- stream = G_INPUT_STREAM (g_file_read (file, NULL, NULL));
- g_object_unref (file);
-
return stream;
}