JsonResponse: Set content type at initialization and not at sendHeaders
refs #12161
This commit is contained in:
parent
c3276d4341
commit
703561f874
|
@ -67,6 +67,13 @@ class JsonResponse extends Response
|
|||
*/
|
||||
protected $successData;
|
||||
|
||||
/**
|
||||
* Content type of this response
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $contentType = 'application/json';
|
||||
|
||||
/**
|
||||
* Get the JSON encoding options
|
||||
*
|
||||
|
@ -186,15 +193,6 @@ class JsonResponse extends Response
|
|||
echo json_encode($body, $this->getEncodingOptions());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function sendHeaders()
|
||||
{
|
||||
$this->setContentType('application/json');
|
||||
parent::sendHeaders();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue