After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 547133 - Getting mtime over http backend is broken
Getting mtime over http backend is broken
Status: RESOLVED FIXED
Product: gvfs
Classification: Core
Component: http backend
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gvfs-maint
gvfs-maint
Depends on: 549006
Blocks: 569774
 
 
Reported: 2008-08-10 04:49 UTC by John Stowers
Modified: 2009-02-13 02:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
working example using soup (618 bytes, text/plain)
2008-08-11 23:24 UTC, John Stowers
  Details
Example code which includes new g_time_val_from_* helpers. (5.18 KB, text/x-csrc)
2008-08-12 21:02 UTC, Andreas Henriksson
  Details
Use soup_date to convert to http-date string to iso8601. (835 bytes, patch)
2008-08-13 19:33 UTC, Andreas Henriksson
none Details | Review

Description John Stowers 2008-08-10 04:49:58 UTC
Hi,

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

import gnomevfs
u = gnomevfs.URI('http://www.gnome.org/~jstowers/conduit_test_data/Image.png')
i = gnomevfs.get_file_info(u)
i.mtime
Out[7]: 1196757392L
Comment 1 Alexander “weej” Jones 2008-08-10 13:02:43 UTC
Etags work, BTW.
Comment 2 John Stowers 2008-08-11 23:24:57 UTC
Created attachment 116392 [details]
working example using soup

compile with gcc -o test `pkg-config --cflags --libs libsoup-2.4` main.c

john@nzjrs-laptop:~/Desktop/header$ ./test 
** (process:10228): DEBUG: Last Modified: Tue, 04 Dec 2007 09:36:32 GMT

So bug must be in gvfs somewhere.
Comment 3 André Klapper 2008-08-12 00:53:54 UTC
Dear Gicmo, please help us. (CC'ing)
Comment 4 Andreas Henriksson 2008-08-12 11:32:57 UTC
query_info_ready function in gvfs-0.2.5/daemon/gvfsbackendhttp.c contains:

  text = soup_message_headers_get (msg->response_headers,
                                   "Last-Modified");
  if (text)
    {
      GTimeVal tv;
      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:
http://fatal.se/tmp/gvfs-http-mtime-test.diff
Comment 5 Andreas Henriksson 2008-08-12 12:44:21 UTC
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:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1

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.)
Comment 6 Alexander “weej” Jones 2008-08-12 13:51:34 UTC
Why not pull the code from gnome-vfs?
Comment 7 Andreas Henriksson 2008-08-12 20:59:49 UTC
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....

Comment 8 Andreas Henriksson 2008-08-12 21:02:13 UTC
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.
Comment 9 Andreas Henriksson 2008-08-13 18:38:27 UTC
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....
Comment 10 Andreas Henriksson 2008-08-13 19:33:19 UTC
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.
Comment 11 Matthias Clasen 2008-08-15 20:31:45 UTC
Patch looks fine to me. 
Comment 12 John Stowers 2008-08-19 03:45:04 UTC
Could someone please commit this?
Comment 13 André Klapper 2008-08-19 09:25:07 UTC
gicmo, hpj: ping - this is blocking dev work.
Comment 14 Bastien Nocera 2008-08-22 14:20:47 UTC
Whoever does the release will need to update the libsoup reqs in configure.

2008-08-22  Bastien Nocera  <hadess@hadess.net>

	* 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