ZF-9873: Zend_Http_Client is not using the correct separator for the cookie header

Description

The problem: Zend_Http_Client is not sending the correct Cookie header when multiple cookies are used. Exemple:

 
Cookie: var1=value1, var2=value2, var3=value3

This is not correct. According to RFC2965 the correct separator between cookies is ';' not ','. For details please see http://tools.ietf.org/html/rfc2965 section 3.1 (Syntax: General). The correct cookie header sent should be:

 
Cookie: var1=value1; var2=value2; var3=value3

Suggested fix In file Zend/Http/Client.php replace block of code starting at line 1140


        // Add all other user defined headers
        foreach ($this->headers as $header) {
            list($name, $value) = $header;
            if (is_array($value)) {
                $value = implode(', ', $value);
            }

            $headers[] = "$name: $value";
        }

with:


        // Add all other user defined headers
        foreach ($this->headers as $normalized_name => $header) {
            list($name, $value) = $header;
            if (is_array($value)) {
                if ('cookie' == $normalized_name || 'set-cookie2' == $normalized_name)
                    $separator = '; ';
                else
                    $separator = ', ';
                $value = implode($separator, $value);
            }

            $headers[] = "$name: $value";
        }

Comments

I started to work on this, but then I wondered if making this change would potentially break any kind of existing code. It shouldn't right?

It should not brake any existing functionality. The changes that I suggested are only applied to Cookie and Set-Cookie2 headers and are according to standard.

This should not break existing functionality if done as suggested above.

Note that the ';' separator is unique to the Cookie header, and the HTTP RFC (which is the only really accepted RFC, as the Cookie RFC-2965 is not really commonly implemented) states that multiple header values are separated by ','.

Is this something which should be fixed in ZF 1.12?