buildCookies() function throws a notice when dealing with host's cookies #399

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants

Sometimes, the "cookies" array inside the request object contains hosts names as keys to group cookies by hosts. The buildCookies functions wasn't considering it and the execution causes a notice:

Notice (8): Undefined index: value [CORE/Cake/Network/Http/HttpSocket.php, line 881]

This failed because on line 274, for example, the function was called passing the array in question, after it was the result of a merge between whatever there was in the array and the host cookies on the config object on line 261.

261: $this->request['cookies'] = array_merge($this->request['cookies'], $this->config['request']['cookies'][$Host], $request['cookies']);
…
274: $cookies = $this->buildCookies($this->request['cookies']);

To reproduce this error, make a request to a host which response comes with cookies. You can use bandcamp's api, for example. HttpSocket will put these cookies inside $this->request->cookies['api.bandcamp.com']. Then, make another request right away, it could be to the same host.
The cookies array will still be the same and cause the warning explained above.

Lucho Molina fixed buildCookies() function, it was throwing a notice when dealing …
…with host's cookies

Sometimes, the "cookies" array inside the request object contains hosts
names as keys to group cookies by hosts. The buildCookies functions
wasn't considering it and the execution causes a notice:

Notice (8): Undefined index: value
[CORE/Cake/Network/Http/HttpSocket.php, line 881]

This failed because on line 274, for example, the function was called
passing the array in question, after it was the result of a merge
between whatever there was in the array and the host cookies on the
config object on line 261.

261: $this->request['cookies'] = array_merge($this->request['cookies'],
$this->config['request']['cookies'][$Host], $request['cookies']);
…
274: $cookies = $this->buildCookies($this->request['cookies']);

To reproduce this error, make a request to a host which response comes
with cookies. You can use bandcamp's api, for example. HttpSocket will
put these cookies inside $this->request->cookies['api.bandcamp.com'].
Then, make another request right away, it could be to the same host.
The cookies array will still be the same and cause the warning
explained above.
b784593
Owner

markstory commented Jan 13, 2012

How would someone reproduce this issue? I'm not totally clear on that.

Forget it. I am using Neil Crooke's ReST DataSource and it was messing up the request cookies before calling HttpSocket's request().

Realized about it after performing isolated tests.

Sorry for the hassle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment