Project

General

Profile

Feature #302

Support If-Modified-Since

Added by Wido den Hollander over 13 years ago. Updated about 6 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Target version:
-
% Done:

0%

Source:
Tags:
Backport:
Reviewed:
Affected Versions:
Pull request ID:

Description

"The If-Modified-Since request-header field is used with a method to make it conditional: if the requested variant has not been modified since the time specified in this field, an entity will not be returned from the server; instead, a 304 (not modified) response will be returned without any message-body. "

Source: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

We should support this now we also sent out the Last-Modified header, we should also support this conditional header.

Compare the time sent in this header with the mtime of a object should be sufficient. If the object is newer then the specified time, return the content, else reply with a 304 header.

0001-rgw-Parse-times-correctly-and-convert-them-to-GMT-so.patch View (905 Bytes) Wido den Hollander, 07/23/2010 02:35 PM

gmt_times.patch View - Convert all times to GMT (1.93 KB) Wido den Hollander, 07/26/2010 02:01 PM

History

#1 Updated by Yehuda Sadeh over 13 years ago

Actually we do implement the If-Modified-Since, if it's not working that's a bug. One difference is that we don't return 304, but some other error code. Does Amazon S3 return 304 in such a case?

#2 Updated by Wido den Hollander over 13 years ago

Yes, Amazon does that. The RFC specifies that when you do so, you have to return a 304 Not Modified header.

Like you said there is already some work for this, but the correct header isn't set, this should be done then.

#3 Updated by Wido den Hollander over 13 years ago

Seems that the times were not parsed correctly and converted to GMT.

Attached patch will fix this and make the if-modified-since work.

#4 Updated by Wido den Hollander over 13 years ago

There is some more to this and it might need some more work to do so.

Right now, all the times stored by the RADOS gateway are in the timezone where the gateway is, but all the HTTP RFC's specify that GMT should be used.

When working with the "If-Modified-Since" header (or the If-Unmodified-Since) the "mtime" coming from RADOS has to be converted to GMT.

But the same goes for displaying the "Last-Modified" header, the time coming from RADOS first has to be converted to GMT, which then makes it prone to errors.

I would suggest saving all the dates in GMT, so no conversion has to be made to them, but this has a drawback. The time_t datatype in C++ is always to be converted according to the local system timezone, this is done by mktime, localtime and gmtime. So this makes the time conversions a bit unreliable.

To do so we would have to switch to a different method of saving times inside the gateway, but i think this goes even deeper then the gateway, it goes down all the way to librados i assume.

Right now i'm hacking around in the code to get the If-Modified-Since working, but i keep coming up with the timezone difference. I'm in GMT +2, so it takes 2 hours before i get the "304 Not Modified" response on a file.

Later today i'll post a patch which would solve the issue, but i still think we will have to go deeper then just converting all the times, imho, all the times saved should be GMT and converted from there on.

#5 Updated by Wido den Hollander over 13 years ago

See the attached patch, this will convert all times to GMT, so they can be compared correctly.

#6 Updated by Yehuda Sadeh over 13 years ago

The patch seems fine, just a small issue is that you changed the return code in the unmodified-since case. This would make it incompatible with the error codes described in the amazon S3 API documentation.

#7 Updated by Yehuda Sadeh over 13 years ago

  • Status changed from New to Resolved

#8 Updated by Sage Weil about 13 years ago

  • Category set to radosgw

#9 Updated by Sage Weil about 13 years ago

  • Project changed from RADOS Gateway to Ceph
  • Category changed from radosgw to 22

#10 Updated by John Spray about 6 years ago

  • Project changed from Ceph to rgw
  • Category deleted (22)

Bulk reassign of radosgw category to RGW project.

Also available in: Atom PDF