yii\httpclient\Response::detectFormatByHeaders PHP Method

detectFormatByHeaders() protected method

Detects format from headers.
protected detectFormatByHeaders ( HeaderCollection $headers ) : null | string
$headers yii\web\HeaderCollection source headers.
return null | string format name, 'null' - if detection failed.
    protected function detectFormatByHeaders(HeaderCollection $headers)
    {
        $contentType = $headers->get('content-type');
        if (!empty($contentType)) {
            if (stripos($contentType, 'json') !== false) {
                return Client::FORMAT_JSON;
            }
            if (stripos($contentType, 'urlencoded') !== false) {
                return Client::FORMAT_URLENCODED;
            }
            if (stripos($contentType, 'xml') !== false) {
                return Client::FORMAT_XML;
            }
        }
        return null;
    }