GNOME Bugzilla – Bug 547133
Getting mtime over http backend is broken
Last modified: 2009-02-13 02:37:33 UTC
This is a regression from gnomevfs where it used to be possible to retrieve the mtime of files via http
For example, the following does not work
gvfs-info -a 'time::*' 'http://www.gnome.org/~jstowers/conduit_test_data/Image.png'
The following does work
u = gnomevfs.URI('http://www.gnome.org/~jstowers/conduit_test_data/Image.png')
i = gnomevfs.get_file_info(u)
Etags work, BTW.
Created attachment 116392 [details]
working example using soup
compile with gcc -o test `pkg-config --cflags --libs libsoup-2.4` main.c
** (process:10228): DEBUG: Last Modified: Tue, 04 Dec 2007 09:36:32 GMT
So bug must be in gvfs somewhere.
Dear Gicmo, please help us. (CC'ing)
query_info_ready function in gvfs-0.2.5/daemon/gvfsbackendhttp.c contains:
text = soup_message_headers_get (msg->response_headers,
if (g_time_val_from_iso8601 (text, &tv))
g_file_info_set_modification_time (info, &tv);
Parsing the time specifier (g_time_val_from_iso8601) seems to fail and modification time never gets set.
Patch to update previously posted test-case:
14:08 < pterjan> http://en.wikipedia.org/wiki/ISO_8601
The text used in Last-Modified headers is not in ISO 8601 format.
Here's a description on how to parse the "HTTP-date" format:
Doesn't look like there are any convenient glib functions that will do all the work for us.
(Will try implementing a fix/parser when I get some more time, unless someone else has already fixed it by then.)
Why not pull the code from gnome-vfs?
I'm attaching my lame parser functions which is probably to picky, unportable and broken.... They seem to work atleast for the original soap example. Consider my part of the file (test.c:g_time_val_from_*) WTFPL version 2 or LGPLv2+....
gnome_vfs_atotm() is apparently not portable to windows since it uses strptime.
There's also this comment:
Needless to say, what we *really* need here is something like
Marcus Hennecke's atotm(), which is forgiving, fast, to-the-point,
and does not use strptime(). atotm() is to be found in the sources
of `phttpd', a little-known HTTP server written by Peter Erikson. */
Marcus atotm() seems to be GPLv2+ so I guess someone would need to ask for relicensing....
Created attachment 116454 [details]
Example code which includes new g_time_val_from_* helpers.
Please note that the g_time_val_from_rfc* functions has not been verified against the relevant RFC, just checked according to the w3.org HTTP-date specified formats.
If libsoup exported it's "parse_textual_date", using that together with "soup_date_to_string" to reformat the header string to iso8601 would be an option....
Created attachment 116518 [details] [review]
Use soup_date to convert to http-date string to iso8601.
I don't know what's wrong with me today. Ofcourse I should use soup_date_new_from_string (not parse_textual_date) .... This entire day has been nothing but problems.
This patch (against 0.2.5, hope that's ok) seems to work, but please review it carefully! Don't forget to log out and in again for gvfs changes to take effect.
Patch looks fine to me.
Could someone please commit this?
gicmo, hpj: ping - this is blocking dev work.
Whoever does the release will need to update the libsoup reqs in configure.
2008-08-22 Bastien Nocera <firstname.lastname@example.org>
* daemon/gvfsbackendhttp.c (query_info_ready): Use
libsoup to parse the "Last-Modified" header, not
the ISO-8601 parsing functions (Closes: #547133)
Requires libsoup trunk