UPDATE:
Re-enabling old post, because I found more information about it.
Goal
I want to send the cookie using drupalGet.
Example:
drupalGet($path, $options, array('Cookie: my_cookie=' . $user->name, 'User-Agent: Mozilla'));
Problem
drupalGet/curl is sending two 'Cookie' headers (in two lines).
Bad example (as it's currently):
Cookie: SESSd5f6d078ecfc43ac091312829e2f7ae5=017d67075033939108c868775afea2da
Cookie: my_cookie=vk1VVdO7
What I was expecting is the following header (in one line):
Cookie: my_cookie=vk1VVdO7; SESS077a2739d9e46e582c048b5db2da58c1=08f246f1e898c24df3a28ebf263682d3
If there are two lines of 'Cookie' header, $_COOKIE global variable looks invalid.
Example (having print_r($_COOKIE); exit; in my hook_boot):
$ curl -v -H "Cookie: SESS123=123; my_cookie=vk1VVdO7" http://localhost/
Array
(
[SESS123] => 123
[my_cookie] => vk1VVdO7
)
CORRECT!
$ curl -v -H "Cookie: SESS123=123" -H "Cookie: my_cookie=vk1VVdO7" http://localhost/
Array
(
[SESS123] => 123, my_cookie=vk1VVdO7
)
NOT CORRECT!
Not sure if it's reproducible in Drupal 7.x
Original issue report
Code:
$this->drupalGet($url, NULL, array('Cookie: cookie=cookievalue;'));
var_dump($this->drupalGetHeaders()); exit;
Result:
array(13) {
[":status"]=>
string(15) "HTTP/1.1 200 OK"
["date"]=>
string(29) "Mon, 24 Oct 2011 14:39:26 GMT"
["server"]=>
string(6) "Apache"
["x-powered-by"]=>
string(9) "PHP/5.3.6"
["set-cookie"]=>
string(126) "SESS60f7eff84479fe668a24e164b6291550=8bc3aeeb78109aa3438548c41f1e426c; expires=Wed, 16-Nov-2011 18:12:46 GMT; path=/; HttpOnly"
["expires"]=>
string(29) "Sun, 19 Nov 1978 05:00:00 GMT"
["last-modified"]=>
string(31) "Mon, 24 Oct 2011 14:39:26 +0000"
["cache-control"]=>
string(52) "no-cache, must-revalidate, post-check=0, pre-check=0"
["etag"]=>
string(12) ""1319467166""
I can't see 'Cookie:' in the response.
Is there any way to pass the cookie for the request?
Related topics:
http://groups.drupal.org/node/22176
#457804: Enable simpletest to manipulate cookies
Comments
Comment #1
kenorb commentedIt doesn't return in header, but the URL which is called has access to cookie via $_COOKIE.
Comment #1.0
kenorb commentedadded question
Comment #2
kenorb commentedComment #2.0
kenorb commentedupdating the old issue with more investigation
Comment #2.1
kenorb commentedremoving repetition
Comment #2.2
kenorb commentedchanging cookie name
Comment #3
kenorb commentedComment #4
kenorb commentedRelated (libcurl):
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=3513010&gro...
Comment #5
kenorb commentedReproducing the bug in simple way
Following script test the bug:
It should give you something like:
Which is wrong (Cookie section has two lines, instead of one).
If additional session cookie is not generated by drush, try pasting somewhere else, i.e. Devel PHP Code.
Comment #6
kenorb commentedFollowing patch fix the problem.
Tested on Drupal 6.x (Pressflow). Should be pretty the same for Drupal 7.x.
Now the testing code from #5 returns this:
P.S. I'm behind the proxy, so I can't create the proper patch against the latest git version.
Workaround
As workaround (without patching) it's possible to defining own drupalGet method in the test.
Comment #6.0
kenorb commentedsimplified cookie name
Comment #7
kenorb commentedAs per http://stackoverflow.com/questions/9142964/curl-cookie-value
marking it as a feature.
Comment #10
kenorb commented