-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
Hello,
the method HTTPHeadersParser::parse is not producing a valid headers array in some situations. If the response contains multiple headers with the same name (which happenend to me with "set-cookie") an awkward nested array is created in this line:
$carry[$match[1]] = isset($carry[$match[1]]) ? [$carry[$match[1]], $match[2]] : trim($match[2]);
So if you have more than two "set-cookie" headers you would end up with a multiple nested array which cannot be handled by symfonys Cookie::fromString($cookie) method (explode will fail and cause exception).
I fixed it by writing my own global "http_parse_headers" function, replacing the line above with this:
if( isset($carry[$match[1]]) ) {
if(!is_array($carry[$match[1]]))
$carry[$match[1]] = array($carry[$match[1]], $match[2]);
else{
$carry[$match[1]][] = trim($match[2]);
}
} else {
$carry[$match[1]] = trim($match[2]);
}
Greetings!
Metadata
Metadata
Assignees
Labels
No labels