original_string: protected static function setContentType($headers, $response)
      {
          if (isset($headers['Content-Type'])) {
              return $headers;
          }
          if (in_array($response->statusCode(), [204, 304])) {
              return $headers;
          }
  
          $whitelist = [
              'application/javascript', 'application/json', 'application/xml', 'application/rss+xml'
          ];
  
          $type = $response->type();
          $charset = $response->charset();
  
          $hasCharset = false;
          if ($charset && (strpos($type, 'text/') === 0 || in_array($type, $whitelist))) {
              $hasCharset = true;
          }
  
          $value = $type;
          if ($hasCharset) {
              $value = "{$type}; charset={$charset}";
          }
          $headers['Content-Type'] = $value;
  
          return $headers;
      }
code: protected static function setContentType($headers, $response)
      {
          if (isset($headers['Content-Type'])) {
              return $headers;
          }
          if (in_array($response->statusCode(), [204, 304])) {
              return $headers;
          }
  
          $whitelist = [
              'application/javascript', 'application/json', 'application/xml', 'application/rss+xml'
          ];
  
          $type = $response->type();
          $charset = $response->charset();
  
          $hasCharset = false;
          if ($charset && (strpos($type, 'text/') === 0 || in_array($type, $whitelist))) {
              $hasCharset = true;
          }
  
          $value = $type;
          if ($hasCharset) {
              $value = "{$type}; charset={$charset}";
          }
          $headers['Content-Type'] = $value;
  
          return $headers;
      }
code_tokens: protected static function setContentType ( $ headers , $ response ) { if ( isset ( $ headers [ 'Content-Type' ] ) ) { return $ headers ; } if ( in_array ( $ response -> statusCode ( ) , [ 204 , 304 ] ) ) { return $ headers ; } $ whitelist = [ 'application/javascript' , 'application/json' , 'application/xml' , 'application/rss+xml' ] ; $ type = $ response -> type ( ) ; $ charset = $ response -> charset ( ) ; $ hasCharset = false ; if ( $ charset && ( strpos ( $ type , 'text/' ) === 0 || in_array ( $ type , $ whitelist ) ) ) { $ hasCharset = true ; } $ value = $ type ; if ( $ hasCharset ) { $ value = "{$type}; charset={$charset}" ; } $ headers [ 'Content-Type' ] = $ value ; return $ headers ; }
docstring: Add in the Content-Type header if necessary.
  
  @param array $headers The headers to update
  @param \Cake\Http\Response $response The CakePHP response to convert
  @return array The updated headers.
docstring_tokens: Add in the Content - Type header if necessary .