thoughtbot/capybara-webkit — Issue #215: Cookies in response headers
Author: alexkalish
Created: 2011-11-22 16:40:30+00:00
State: open

This isn't a big issue, but the hash returned by Capybara::Driver::Webkit::Browser#response_headers doesn't provide an easy or consistent way of examining cookies. The first cookie set is properly keyed to ```"Set-Cookie"```, but all other cookies are set to a key of the cookie value and a value of nil. This is probably best illustrated via an example.

Adding this to a controller:

```
cookies[:foo] = 'bar'
cookies[:baz] = 'blah'
```

Results in #response_headers returning this:

```
{
"foo=bar; path=/" => nil,
"X-Ua-Compatible" => "IE=Edge,chrome=1",
"Etag" => "\"082aff03214a4cec7ffb90d950874b9e\"",
"X-Runtime" => "0.032122",
"Date" => "Tue, 22 Nov 2011 16:35:08 GMT",
"Content-Type" => "text/html; charset=utf-8",
"Content-Length" => "757",
"Server" => "WEBrick/1.3.1 (Ruby/1.8.7/2011-02-18)",
"Set-Cookie" => "baz=blah; path=/",
"user_device_token=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT" => nil,
"Cache-Control" => "max-age=0, private, must-revalidate",
"Connection" => "Keep-Alive"
}
```

Am I missing something obvious? Is this a known issue? I realize that I can access cookies via Capybara::Driver::Webkit::Browser#get_cookies, but it would great if I could easily access them in the headers too. Thanks so much!