Skip to content

Commit 248a2d2

Browse files
committed
Also check the initial cookies header value.
1 parent 928d673 commit 248a2d2

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/rack/conform/application.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ def test_cookies(env)
4545
cookies = request.cookies
4646

4747
Rack::Response.new.tap do |response|
48+
# Hex encode non-printable characters:
49+
value = env['HTTP_COOKIE'].gsub(/[^[:print:]]/, &:ord)
50+
response.add_header('x-http-cookie', value)
51+
4852
cookies.each do |key, value|
4953
response.set_cookie(key, value)
5054
end

test/rack/conform/cookies.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def body(headers)
1515

1616
expect(response.status).to be == 200
1717
expect(response.headers).to have_keys(
18+
'x-http-cookie' => be == ['a=1'],
1819
'set-cookie' => be == ['a=1']
1920
)
2021
ensure
@@ -26,6 +27,7 @@ def body(headers)
2627

2728
expect(response.status).to be == 200
2829
expect(response.headers).to have_keys(
30+
'x-http-cookie' => be == ['a=1;b=2'],
2931
'set-cookie' => be == ["a=1", "b=2"]
3032
)
3133
ensure
@@ -37,6 +39,7 @@ def body(headers)
3739

3840
expect(response.status).to be == 200
3941
expect(response.headers).to have_keys(
42+
'x-http-cookie' => be == ['a=1;b=2'],
4043
'set-cookie' => be == ['a=1', 'b=2']
4144
)
4245
ensure

0 commit comments

Comments
 (0)