src/Leevel/Http/Response.php
public function setContentType(string $contentType, ?string $charset = null): IResponse
    {
        if ($this->checkFlowControl()) {
            return $this;
        }

        if (null === $charset) {
            $charset = $this->getCharset();
        }

        if (null === $charset) {
            $this->setHeader('Content-Type', $contentType);
        } else {
            $this->setHeader('Content-Type', $contentType.'; charset='.$charset);
        }

        return $this;
    }
public function setContentType(string $contentType, ?string $charset = null): IResponse
    {
        if ($this->checkFlowControl()) {
            return $this;
        }

        if (null === $charset) {
            $charset = $this->getCharset();
        }

        if (null === $charset) {
            $this->setHeader('Content-Type', $contentType);
        } else {
            $this->setHeader('Content-Type', $contentType.'; charset='.$charset);
        }

        return $this;
    }
设置响应内容类型.

@param string $contentType
@param string $charset

@return $this