<?php


namespace Zend\Http\PhpEnvironment;

use Zend\Http\Response as HttpResponse,
    Zend\Stdlib\Parameters;

class Response extends HttpResponse
{
    protected $headersSent = false;

    protected $contentSent = false;

    public function __construct()
    {
    }
    
    public function headersSent()
    {
        return $this->headersSent;
    }
    
    public function contentSent()
    {
        return $this->contentSent;
    }
    
    public function sendHeaders()
    {
        if ($this->headersSent()) {
            return;
        }

        $version = $this->getVersion();
        $code    = $this->getStatusCode();
        $message = $this->getReasonPhrase();
        $status  = sprintf('HTTP/%s %d %s', $version, $code, $message);
        header($status);

        foreach ($this->headers() as $header) {
            header($header->toString());
        }

        $this->headersSent = true;
        return $this;
    }
    
    public function sendContent()
    {
        if ($this->contentSent()) {
            return;
        }
        echo $this->getContent();
        $this->contentSent = true;
        return $this;
    }

    public function send()
    {
        $this->sendHeaders()
             ->sendContent();
        return $this;
    }
    
}
    

<?php


namespace Zend\Http\PhpEnvironment;

use Zend\Http\Header\MultipleHeaderDescription,
    Zend\Http\Response as HttpResponse,
    Zend\Stdlib\Parameters;

class Response extends HttpResponse
{
    protected $headersSent = false;

    protected $contentSent = false;

    public function __construct()
    {
    }
    
    public function headersSent()
    {
        return $this->headersSent;
    }
    
    public function contentSent()
    {
        return $this->contentSent;
    }
    
    public function sendHeaders()
    {
        if ($this->headersSent()) {
            return;
        }

        $version = $this->getVersion();
        $code    = $this->getStatusCode();
        $message = $this->getReasonPhrase();
        $status  = sprintf('HTTP/%s %d %s', $version, $code, $message);
        header($status);

        foreach ($this->headers() as $header) {
            if ($header instanceof MultipleHeaderDescription) {
                header($header->toString(), false);
                continue;
            }
            header($header->toString());
        }

        $this->headersSent = true;
        return $this;
    }
    
    public function sendContent()
    {
        if ($this->contentSent()) {
            return;
        }
        echo $this->getContent();
        $this->contentSent = true;
        return $this;
    }

    public function send()
    {
        $this->sendHeaders()
             ->sendContent();
        return $this;
    }
    
}
    

Allow PHP response to send MultipleHeaders safely
Allow PHP response to send MultipleHeaders safely

- Detect MultipleHeaderDescription
  - when found, pass boolean false as second argument to header()
