diff -r bd595ad770fc -r 1c2f13fd785c web/enmi/Zend/Json/Server/Response/Http.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/enmi/Zend/Json/Server/Response/Http.php Thu Jan 20 19:30:54 2011 +0100 @@ -0,0 +1,81 @@ +sendHeaders(); + if (!$this->isError() && null === $this->getId()) { + return ''; + } + + return parent::toJson(); + } + + /** + * Send headers + * + * If headers are already sent, do nothing. If null ID, send HTTP 204 + * header. Otherwise, send content type header based on content type of + * service map. + * + * @return void + */ + public function sendHeaders() + { + if (headers_sent()) { + return; + } + + if (!$this->isError() && (null === $this->getId())) { + header('HTTP/1.1 204 No Content'); + return; + } + + if (null === ($smd = $this->getServiceMap())) { + return; + } + + $contentType = $smd->getContentType(); + if (!empty($contentType)) { + header('Content-Type: ' . $contentType); + } + } +}