Skip to content

Commit da5f03a

Browse files
authored
Merge pull request #263 from orien/ruby-3.1
Format cookie `Expires` timestamps as per RFC 2616
2 parents a17691c + 10851c5 commit da5f03a

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,18 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
ruby_version: ["2.3.8", "2.4.5", "2.5.3", "2.6.3", "2.7.2"]
12+
ruby_version: ["2.3", "2.4", "2.5", "2.6", "2.7", "3.0", "3.1"]
1313
experimental: [false]
1414
include:
15-
- ruby_version: "3.0"
15+
- ruby_version: "3.2"
1616
experimental: true
1717
- ruby_version: "ruby-head"
1818
experimental: true
19-
- ruby_version: "jruby-head"
20-
experimental: true
2119

2220
steps:
23-
- uses: actions/checkout@v2
21+
- uses: actions/checkout@v3
2422
- uses: ruby/setup-ruby@v1
2523
with:
2624
ruby-version: ${{ matrix.ruby_version }}
27-
- run: "bundle install"
25+
bundler-cache: true
2826
- run: "bundle exec rspec spec/ -b"

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)