summaryrefslogtreecommitdiff
path: root/libsoup
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
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')
-rw-r--r--libsoup/soup-cache.c22
-rw-r--r--libsoup/soup-request-http.c5
2 files changed, 16 insertions, 11 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;
}
diff --git a/libsoup/soup-request-http.c b/libsoup/soup-request-http.c
index 42cc6e01..8ef95fc6 100644
--- a/libsoup/soup-request-http.c
+++ b/libsoup/soup-request-http.c
@@ -133,14 +133,15 @@ conditional_get_ready_cb (SoupSession *session, SoupMessage *msg, gpointer user_
if (msg->status_code == SOUP_STATUS_NOT_MODIFIED) {
SoupCache *cache = (SoupCache *)soup_session_get_feature (session, SOUP_TYPE_CACHE);
- httpstream = (SoupHTTPInputStream *)soup_cache_send_response (cache, msg);
+ httpstream = (SoupHTTPInputStream *)soup_cache_send_response (cache, helper->original);
if (httpstream) {
g_simple_async_result_set_op_res_gpointer (simple, httpstream, g_object_unref);
soup_message_got_headers (helper->original);
if (soup_session_get_feature_for_message (session, SOUP_TYPE_CONTENT_SNIFFER, helper->original)) {
- const char *content_type = soup_message_headers_get_content_type (msg->response_headers, NULL);
+ const char *content_type =
+ soup_message_headers_get_content_type (helper->original->response_headers, NULL);
soup_message_content_sniffed (helper->original, content_type, NULL);
}