lib/cuba_api/utils.rb in cuba-api-0.3.1 vs lib/cuba_api/utils.rb in cuba-api-0.3.2
- old
+ new
@@ -25,11 +25,11 @@
limit = ( to_int( 'count' ) || count ) - 1 + offset
{ method => set[ offset..limit ], :offset => offset, :total_count => count }
end
def last_modified( last )
- res[ 'Last-Modified' ] = last.rfc2822
+ res[ 'Last-Modified' ] = rfc2616( last )
end
def modified_since
@modified_since ||=
if date = env[ 'HTTP_IF_MODIFIED_SINCE' ]
@@ -37,16 +37,16 @@
end
end
def expires_in( minutes )
now = DateTime.now
- res[ 'Date' ] = now.rfc2822
- res[ 'Expires' ] = ( now + minutes / 1440.0 ).rfc2822
+ res[ 'Date' ] = rfc2616( now )
+ res[ 'Expires' ] = rfc2616( now + minutes / 1440.0 )
end
def browser_only_cache
- res[ 'Date' ] = DateTime.now.rfc2822
+ res[ 'Date' ] = rfc2616
res[ 'Expires' ] = "Fri, 01 Jan 1990 00:00:00 GMT"
res[ 'Cache-Control' ] = "private, max-age=0, must-revalidate"
end
def browser_only_cache_no_store
@@ -58,16 +58,20 @@
no_cache
res["Cache-Control"] += ", no-store"
end
def no_cache
- res["Date"] = Time.now.rfc2822
+ res["Date"] = rfc2616
res["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
res["Pragma"] = "no-cache"
res["Cache-Control"] = "no-cache, must-revalidate"
end
def content_type( mime )
res[ 'Content-Type' ] = mime if mime
+ end
+
+ def rfc2616( time = DateTime.now )
+ time.to_time.utc.rfc2822.sub( /.....$/, 'GMT')
end
end
end