protected function addPolicyHeader(ResponseInterface $response)
    {
        $this->loadDefaultProfiles();

        $currentHeader = $response->getHeader($this->header);

        $initialConfig = [];
        if (count($currentHeader)) {
            $initialConfig = $this->decodeConfiguration($currentHeader[0]);
        }

        $initialDirectives = $this->encodeConfiguration($initialConfig);

        $this->mergeProfileWithConfig($initialConfig);

        $newDirectives = $this->encodeConfiguration($this->config);

        if ($newDirectives != $initialDirectives) {
            $response = $response->withHeader($this->header, $newDirectives);
        }

        return $response;
    }
protected function addPolicyHeader(ResponseInterface $response)
    {
        $this->loadDefaultProfiles();

        $currentHeader = $response->getHeader($this->header);

        $initialConfig = [];
        if (count($currentHeader)) {
            $initialConfig = $this->decodeConfiguration($currentHeader[0]);
        }

        $initialDirectives = $this->encodeConfiguration($initialConfig);

        $this->mergeProfileWithConfig($initialConfig);

        $newDirectives = $this->encodeConfiguration($this->config);

        if ($newDirectives != $initialDirectives) {
            $response = $response->withHeader($this->header, $newDirectives);
        }

        return $response;
    }
protected function addPolicyHeader ( ResponseInterface $ response ) { $ this -> loadDefaultProfiles ( ) ; $ currentHeader = $ response -> getHeader ( $ this -> header ) ; $ initialConfig = [ ] ; if ( count ( $ currentHeader ) ) { $ initialConfig = $ this -> decodeConfiguration ( $ currentHeader [ 0 ] ) ; } $ initialDirectives = $ this -> encodeConfiguration ( $ initialConfig ) ; $ this -> mergeProfileWithConfig ( $ initialConfig ) ; $ newDirectives = $ this -> encodeConfiguration ( $ this -> config ) ; if ( $ newDirectives != $ initialDirectives ) { $ response = $ response -> withHeader ( $ this -> header , $ newDirectives ) ; } return $ response ; }
Add content security policy header to response

@param  ResponseInterface  $response

@return ResponseInterface
Add content security policy header to response