GNOME Bugzilla – Bug 680029
Responses from soup cache always have zero content-legth and null content type
Last modified: 2012-07-16 17:08:46 UTC
This breaks WebKit2 unit tests when disk cache is enabled, because it assumes valid content-length and content-type from the cache.
Created attachment 218925 [details] [review] Add Content-Length to the response headers before sending the response
Created attachment 218927 [details] [review] Save the sniffed mime type in the cache too
Comment on attachment 218925 [details] [review] Add Content-Length to the response headers before sending the response >+ /* Content-Length */ >+ soup_message_headers_set_content_length (msg->response_headers, entry->length); Hm... So WK requires that anything retrieved from cache has a known Content-Length, even if we didn't know the Content-Length when it was originally downloaded? (eg, chunked or read-to-eof encoding)?
Comment on attachment 218927 [details] [review] Save the sniffed mime type in the cache too ok
(In reply to comment #3) > (From update of attachment 218925 [details] [review]) > >+ /* Content-Length */ > >+ soup_message_headers_set_content_length (msg->response_headers, entry->length); > > Hm... So WK requires that anything retrieved from cache has a known > Content-Length, even if we didn't know the Content-Length when it was > originally downloaded? (eg, chunked or read-to-eof encoding)? No, it's just the resources unit tests, that assumes content-length is set in the headers. We always check the content length is the same than the resource data size. It works the first time, but fails the second time because the resources is loaded from the cache.
If the original response had a Content-Length header, then that should be saved in the cache with the rest of the headers, and then copied back in to the cache response with the rest of the headers, and then read back by soup_request_http_get_content_length()... so this code shouldn't be needed if everything is working correctly.
I think the content length header is always reset by soup cache, because copy_end_to_end_headers removes the tansfer encoding header. So even if the original request had content lenght it's not saved in the cache
Created attachment 218935 [details] [review] soup_message_headers_get_content_length: recheck encoding Use soup_message_headers_get_encoding() rather than looking at hdrs->encoding directly, so that it gets recomputed if it's stale (eg, from another header having been removed). ==== Try this...
It works!
Pushed both patches to git master.