Skip to content

Commit c931171

Browse files
committed
Also check the initial cookies header value.
1 parent a7f30d4 commit c931171

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
@@ -43,6 +43,10 @@ def test_cookies(env)
4343
cookies = request.cookies
4444

4545
Rack::Response.new.tap do |response|
46+
# Hex encode non-printable characters:
47+
value = env['HTTP_COOKIE'].gsub(/[^[:print:]]/, &:ord)
48+
response.add_header('x-http-cookie', value)
49+
4650
cookies.each do |key, value|
4751
response.set_cookie(key, value)
4852
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)