private function sendReply ($reply, array $headers = [])
    {
        if ($this->sent) {
            throw new Exception\AlreadySentException();
        }

        $headers = array_merge(
            [
                'Connection: close',
                'Content-Length: ' . strlen($reply),
            ],
            $headers
        );

        $hasContentType = false;
        foreach ($headers as $headerLine) {
            if (stripos($headerLine, 'Content-Type') !== false) {
                $hasContentType = true;
                break;
            }
        }

        if (!$hasContentType) {
            $headers[] = 'Content-Type: application/xml';
        }
        
        $this->sent = true;
        $this->printReply($reply, $headers);
    }
private function sendReply ($reply, array $headers = [])
    {
        if ($this->sent) {
            throw new Exception\AlreadySentException();
        }

        $headers = array_merge(
            [
                'Connection: close',
                'Content-Length: ' . strlen($reply),
            ],
            $headers
        );

        $hasContentType = false;
        foreach ($headers as $headerLine) {
            if (stripos($headerLine, 'Content-Type') !== false) {
                $hasContentType = true;
                break;
            }
        }

        if (!$hasContentType) {
            $headers[] = 'Content-Type: application/xml';
        }
        
        $this->sent = true;
        $this->printReply($reply, $headers);
    }
private function sendReply ( $ reply , array $ headers = [ ] ) { if ( $ this -> sent ) { throw new Exception \ AlreadySentException ( ) ; } $ headers = array_merge ( [ 'Connection: close' , 'Content-Length: ' . strlen ( $ reply ) , ] , $ headers ) ; $ hasContentType = false ; foreach ( $ headers as $ headerLine ) { if ( stripos ( $ headerLine , 'Content-Type' ) !== false ) { $ hasContentType = true ; break ; } } if ( ! $ hasContentType ) { $ headers [ ] = 'Content-Type: application/xml' ; } $ this -> sent = true ; $ this -> printReply ( $ reply , $ headers ) ; }
Handles the sending of the reply. Throws an exception if a reply has previously been sent.

@param string $reply
@param array  $headers

@throws Exception\AlreadySentException
Handles the sending of the reply . Throws an exception if a reply has previously been sent .