original_string: public function populateCorsResponse(HttpRequest $request, HttpResponse $response)
      {
          $origin = $this->getAllowedOriginValue($request);
  
          // If $origin is "null", then it means than the origin is not allowed. As this is
          // a simple request, it is useless to continue the processing as it will be refused
          // by the browser anyway, so we throw an exception
          if ($origin === 'null') {
              $origin = $request->getHeader('Origin');
              $originHeader = $origin ? $origin->getFieldValue() : '';
              throw new DisallowedOriginException(
                  sprintf(
                      'The origin "%s" is not authorized',
                      $originHeader
                  )
              );
          }
  
          $headers = $response->getHeaders();
          $headers->addHeaderLine('Access-Control-Allow-Origin', $origin);
          $headers->addHeaderLine('Access-Control-Expose-Headers', implode(', ', $this->options->getExposedHeaders()));
  
          $headers = $this->ensureVaryHeader($response);
  
          if ($this->options->getAllowedCredentials()) {
              $headers->addHeaderLine('Access-Control-Allow-Credentials', 'true');
          }
  
          $response->setHeaders($headers);
  
          return $response;
      }
code: public function populateCorsResponse(HttpRequest $request, HttpResponse $response)
      {
          $origin = $this->getAllowedOriginValue($request);
  
          // If $origin is "null", then it means than the origin is not allowed. As this is
          // a simple request, it is useless to continue the processing as it will be refused
          // by the browser anyway, so we throw an exception
          if ($origin === 'null') {
              $origin = $request->getHeader('Origin');
              $originHeader = $origin ? $origin->getFieldValue() : '';
              throw new DisallowedOriginException(
                  sprintf(
                      'The origin "%s" is not authorized',
                      $originHeader
                  )
              );
          }
  
          $headers = $response->getHeaders();
          $headers->addHeaderLine('Access-Control-Allow-Origin', $origin);
          $headers->addHeaderLine('Access-Control-Expose-Headers', implode(', ', $this->options->getExposedHeaders()));
  
          $headers = $this->ensureVaryHeader($response);
  
          if ($this->options->getAllowedCredentials()) {
              $headers->addHeaderLine('Access-Control-Allow-Credentials', 'true');
          }
  
          $response->setHeaders($headers);
  
          return $response;
      }
code_tokens: public function populateCorsResponse ( HttpRequest $ request , HttpResponse $ response ) { $ origin = $ this -> getAllowedOriginValue ( $ request ) ; // If $origin is "null", then it means than the origin is not allowed. As this is // a simple request, it is useless to continue the processing as it will be refused // by the browser anyway, so we throw an exception if ( $ origin === 'null' ) { $ origin = $ request -> getHeader ( 'Origin' ) ; $ originHeader = $ origin ? $ origin -> getFieldValue ( ) : '' ; throw new DisallowedOriginException ( sprintf ( 'The origin "%s" is not authorized' , $ originHeader ) ) ; } $ headers = $ response -> getHeaders ( ) ; $ headers -> addHeaderLine ( 'Access-Control-Allow-Origin' , $ origin ) ; $ headers -> addHeaderLine ( 'Access-Control-Expose-Headers' , implode ( ', ' , $ this -> options -> getExposedHeaders ( ) ) ) ; $ headers = $ this -> ensureVaryHeader ( $ response ) ; if ( $ this -> options -> getAllowedCredentials ( ) ) { $ headers -> addHeaderLine ( 'Access-Control-Allow-Credentials' , 'true' ) ; } $ response -> setHeaders ( $ headers ) ; return $ response ; }
docstring: Populate a simple CORS response
  
  @param  HttpRequest               $request
  @param  HttpResponse              $response
  @return HttpResponse
  @throws DisallowedOriginException If the origin is not allowed
docstring_tokens: Populate a simple CORS response