code: public function addCorsHeaders($response, $headers)
      {
          if (empty($headers) === false) {
              $responseHeaders = $response->getHeaders();
              foreach ($headers as $field => $value) {
                  $responseHeaders->set($field, $value);
              }
          }
      }
docs: Adds the CORS headers to the response.
  @param Response $response
  @param array $headers CORS headers which have been computed