Skip to content

Commit 10851c5

Browse files
committed
1 parent e87e2f9 commit 10851c5

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/webmachine/cookie.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,12 @@ def to_s
102102

103103
private
104104

105+
# Format timestamps for the 'Expires' portion of the cookie string, as per RFC 2822 and 2616.
106+
#
107+
# @see https://www.rfc-editor.org/rfc/rfc2616#section-3.3.1
108+
# @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Expires
105109
def rfc2822(time)
106-
wday = Time::RFC2822_DAY_NAME[time.wday]
107-
mon = Time::RFC2822_MONTH_NAME[time.mon - 1]
108-
time.strftime("#{wday}, %d-#{mon}-%Y %H:%M:%S GMT")
110+
time.strftime('%a, %d %b %Y %T GMT')
109111
end
110112

111113
if URI.respond_to?(:decode_www_form_component) and defined?(::Encoding)

spec/webmachine/cookie_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
expect(str).to include "Path=/"
6161
expect(str).to include "Version=1"
6262
expect(str).to include "Max-Age=60"
63-
expect(str).to include "Expires=Sun, 14-Mar-2010 03:14:00 GMT"
63+
expect(str).to include "Expires=Sun, 14 Mar 2010 03:14:00 GMT"
6464
end
6565
end
6666
end

0 commit comments

Comments
 (0)