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;
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;
}
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);
}