Updates Content-Security-Policy headers in a response.

@return array
432680
private function updateCspHeaders(Response $response, array $nonces = [])
    {
        $nonces = array_replace([
            'csp_script_nonce' => $this->generateNonce(),
            'csp_style_nonce' => $this->generateNonce(),
        ], $nonces);

        $ruleIsSet = false;

        $headers = $this->getCspHeaders($response);

        foreach ($headers as $header => $directives) {
            foreach (['script-src' => 'csp_script_nonce', 'style-src' => 'csp_style_nonce'] as $type => $tokenName) {
                if ($this->authorizesInline($directives, $type)) {
                    continue;
                }
                if (!isset($headers[$header][$type])) {
                    if (isset($headers[$header]['default-src'])) {
                        $headers[$header][$type] = $headers[$header]['default-src'];
                    } else {
                        // If there is no script-src/style-src and no default-src, no additional rules required.
                        continue;
                    }
                }
                $ruleIsSet = true;
                if (!\in_array('\'unsafe-inline\'', $headers[$header][$type], true)) {
                    $headers[$header][$type][] = '\'unsafe-inline\'';
                }
                $headers[$header][$type][] = sprintf('\'nonce-%s\'', $nonces[$tokenName]);
            }
        }

        if (!$ruleIsSet) {
            return $nonces;
        }

        foreach ($headers as $header => $directives) {
            $response->headers->set($header, $this->generateCspHeader($directives));
        }

        return $nonces;
    }
439390
protected function buildHeaders(): array
    {
        $this->headers = [
            'User-Agent' => 'Cog-YouTrack-REST-PHP/' . self::VERSION,
            'Accept' => 'application/json',
        ];

        $this->authorizer->appendHeadersTo($this);

        return $this->headers;
    }
316494
public function updateAccess()
    {
        $data = request()->only('role_id', 'permission_id');

        $superAdmin = Roles::superAdmin()->first();

        if( $data['role_id'] == $superAdmin->id ) {
            return \HCLog::info('ACCESS-0001', trans('HCACL::validator.roles.cant_update_super'));
        }

        if( ! auth()->user()->hasRole('admin') && ! auth()->user()->isSuperAdmin() ) {
            return \HCLog::info('ACCESS-0001', trans('HCACL::validator.roles.cant_update_roles'));
        }

        $record = RolesPermissionsConnections::where($data)->first();

        if( is_null($record) ) {
            RolesPermissionsConnections::create($data);
            $message = 'created';
        } else {
            RolesPermissionsConnections::where($data)->delete();
            $message = 'deleted';
        }

        // clear permissions and menu items cache!
        cache()->forget('hc-admin-menu');
        cache()->forget('hc-permissions');

        return ['success' => true, 'message' => $message];
    }
1177699
public function getHeaders() {
		$headers = array();
		foreach ($this->headers as $name => $values) {
			foreach ($values as $value) {
				$headers[] = strtolower($name) . ': ' . $value;
			}
		}
		$headers[] = self::HEADER_KEY_CONTENT_LENGTH . ': ' . strlen($this->getBody());
		return $headers;
	}
1088644
protected function normalizeCustomHeaders()
    {
        $headers = [];

        // The spec requires that headers are sorted by header name.
        sort($this->headers);
        foreach ($this->headers as $header) {
            if ($this->request->hasHeader($header)) {
                $headers[] = strtolower($header) . ':' . $this->request->getHeaderLine($header);
            }
        }

        return $headers;
    }
1185613
public function sendHeaders()
	{
		if (!$this->checkHeadersSent())
		{
			foreach ($this->response->headers as $header)
			{
				if (strtolower($header['name']) == 'status')
				{
					// 'status' headers indicate an HTTP status, and need to be handled slightly differently
					$status = $this->getHttpStatusValue($header['value']);

					$this->header($status, true, (int) $header['value']);
				}
				else
				{
					$this->header($header['name'] . ': ' . $header['value']);
				}
			}
		}

		return $this;
	}
625067
public function getHeaders()
    {
        $headers = array();
        foreach ($this->response->getHeaders()->getAll() as $header => $headerObject) {
            $allHeaderValues = $headerObject->toArray();
            $headers[strtolower($header)] = implode(';', $allHeaderValues);
        }

        return $headers;
    }
589438
public function getHeaders()
    {
        if (!isset($this->properties[MessageProperties::KEY_HEADERS])) {
            $this->properties[MessageProperties::KEY_HEADERS] = [];
        }

        return $this->properties[MessageProperties::KEY_HEADERS];
    }
88239
protected function getHttpHeaders()
    {
        $headers = [];
        if (null !== $this->_maxage) {
            $headers['Cache-Control'] = 'max-age=' . $this->_maxage;
        }
        if ($this->_gzipped) {
            $headers['Content-Encoding'] = 'gzip';
        }

        return $headers;
    }
43113
public function getRequestHeaders()
  {
    $headers = parent::getRequestHeaders();
    if (!is_null($this->modifiedSince)) {
      $headers['If-Modified-Since'] = $this->modifiedSince->format('r');
    }

    return $headers;
  }
158251
def _getHeaders(self, updateParams=None):
		
		if not updateParams:
			updateParams = {}
		policies = self.defaultPolicies
		if len(updateParams) > 0:
			for k,v in updateParams.items():
				k = k.replace('-','_')
				c = globals()[k](v)
				try:
					policies[k] = c.update_policy(self.defaultPolicies[k])
				except Exception, e:
					raise

		return [globals()[k](v).create_header()
				for k,v in policies.items() if v is not None]
944321
private static function headers() {
        if (empty(self::$config['httpHeaders'])) {
            return;
        }

        $response = self::$config['httpContext']->getResponse();
        $response->setHeaders(self::$config['httpHeaders']);
    }
778189
public function updateAction()
    {
        $model = $this->getServiceLocator()
                      ->get( 'Grid\Core\Model\Package\Model' );

        if ( ! $model->getEnabledPackageCount() )
        {
            $this->getResponse()
                 ->setStatusCode( 404 );

            return;
        }

        if ( ! $model->canModify() )
        {
            $this->getResponse()
                 ->setStatusCode( 403 );

            return;
        }

        return array();
    }
984835
def update_policy(self,defaultHeaders):
		
		if self.inputs is not None:
			for k,v in defaultHeaders.items():
				if k not in self.inputs:
					self.inputs[k] = v
				if k == 'pins':
					self.inputs[k] = self.inputs[k] + defaultHeaders[k]
			return self.inputs
		else:
			return self.inputs
990139
private function getResponseHeaders()
    {
        if (!$this->responseHeaders) {
            foreach ($this->getSentHeaders() as $item) {
                list($key, $value) = explode(':', $item, 2);

                $this->responseHeaders[$key] = trim($value);
            }
        }

        return $this->responseHeaders;
    }
954672
public function getHeaders()
	{
		// Define a headers array
		$headers = [];

		foreach($this->items as $key => $value)
		{
			// Does our server attribute have our header prefix ?
			if(strpos($key, $this->http_header_prefix) === 0)
			{
				$key = substr($key, strlen($this->http_header_prefix));
			}
			else if(! in_array($key, $this->http_nonprefixed_headers))
			{
				continue;
			}

			$key = HeaderCollection::normalizeKey($key);

			// Add our server attribute to our header array
			$headers[$key] = $value;
		}

		return $headers;
	}
593270
protected function send_headers() {
        header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0');
        header('Expires: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT');
        header('Pragma: no-cache');
        header('Accept-Ranges: none');
        header('Content-Length: ' . strlen($this->response));
        header('Content-Type: application/xml; charset=utf-8');
        header('Content-Disposition: inline; filename="response.xml"');
    }