Source of file Http.php
Size: 1,497 Bytes - Last Modified: 2014-03-12T23:21:18+01:00
/home/theseer/Downloads/ZendFramework-2.3.0/library/Zend/Json/Server/Response/Http.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 | <?php /** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace Zend\Json\Server\Response; use Zend\Json\Server\Response as JsonResponse; class Http extends JsonResponse { /** * Emit JSON * * Send appropriate HTTP headers. If no Id, then return an empty string. * * @return string */ public function toJson() { $this->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); } } } |