Skip to content

Commit 7a44329

Browse files
committed
Update Response::negotiateContentType method
1 parent 5271c53 commit 7a44329

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/Response.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,7 @@ protected function sendHeaders() : void
520520
if ($this->getHeader(ResponseHeader::DATE) === null) {
521521
$this->setDate();
522522
}
523-
if ($this->getHeader(ResponseHeader::CONTENT_TYPE) === null) {
524-
$this->negotiateContentType();
525-
}
523+
$this->negotiateContentType();
526524
if ($this->isAutoEtag() && !$this->hasDownload()) {
527525
$this->negotiateEtag();
528526
}
@@ -597,8 +595,8 @@ protected function negotiateCsp() : void
597595
}
598596

599597
/**
600-
* Negotiates the Content-Type header, setting the MIME type "text/html" if
601-
* the response body is not empty.
598+
* Negotiates the Content-Type header (if it is not set), setting the MIME
599+
* type "text/html" if the response body is not empty.
602600
*
603601
* If the response body is empty, it removes the Content-Type header,
604602
* and it will not appear to the client from the request.
@@ -610,6 +608,9 @@ protected function negotiateCsp() : void
610608
*/
611609
protected function negotiateContentType() : void
612610
{
611+
if ($this->getHeader(ResponseHeader::CONTENT_TYPE) !== null) {
612+
return;
613+
}
613614
if ($this->getBody() !== '') {
614615
$this->setContentType('text/html');
615616
return;

0 commit comments

Comments
 (0)