original_string: private static function createRedirectResolver(array $options, string $host): \Closure
      {
          $redirectHeaders = [];
          if (0 < $options['max_redirects']) {
              $redirectHeaders['host'] = $host;
              $redirectHeaders['with_auth'] = $redirectHeaders['no_auth'] = array_filter($options['request_headers'], static function ($h) {
                  return 0 !== stripos($h, 'Host:');
              });
  
              if (isset($options['headers']['authorization']) || isset($options['headers']['cookie'])) {
                  $redirectHeaders['no_auth'] = array_filter($options['request_headers'], static function ($h) {
                      return 0 !== stripos($h, 'Authorization:') && 0 !== stripos($h, 'Cookie:');
                  });
              }
          }
  
          return static function ($ch, string $location) use ($redirectHeaders) {
              if ($redirectHeaders && $host = parse_url($location, PHP_URL_HOST)) {
                  $requestHeaders = $redirectHeaders['host'] === $host ? $redirectHeaders['with_auth'] : $redirectHeaders['no_auth'];
                  curl_setopt($ch, CURLOPT_HTTPHEADER, $requestHeaders);
              }
  
              $url = self::parseUrl(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL));
  
              return implode('', self::resolveUrl(self::parseUrl($location), $url));
          };
      }
code: private static function createRedirectResolver(array $options, string $host): \Closure
      {
          $redirectHeaders = [];
          if (0 < $options['max_redirects']) {
              $redirectHeaders['host'] = $host;
              $redirectHeaders['with_auth'] = $redirectHeaders['no_auth'] = array_filter($options['request_headers'], static function ($h) {
                  return 0 !== stripos($h, 'Host:');
              });
  
              if (isset($options['headers']['authorization']) || isset($options['headers']['cookie'])) {
                  $redirectHeaders['no_auth'] = array_filter($options['request_headers'], static function ($h) {
                      return 0 !== stripos($h, 'Authorization:') && 0 !== stripos($h, 'Cookie:');
                  });
              }
          }
  
          return static function ($ch, string $location) use ($redirectHeaders) {
              if ($redirectHeaders && $host = parse_url($location, PHP_URL_HOST)) {
                  $requestHeaders = $redirectHeaders['host'] === $host ? $redirectHeaders['with_auth'] : $redirectHeaders['no_auth'];
                  curl_setopt($ch, CURLOPT_HTTPHEADER, $requestHeaders);
              }
  
              $url = self::parseUrl(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL));
  
              return implode('', self::resolveUrl(self::parseUrl($location), $url));
          };
      }
code_tokens: private static function createRedirectResolver ( array $ options , string $ host ) : \ Closure { $ redirectHeaders = [ ] ; if ( 0 < $ options [ 'max_redirects' ] ) { $ redirectHeaders [ 'host' ] = $ host ; $ redirectHeaders [ 'with_auth' ] = $ redirectHeaders [ 'no_auth' ] = array_filter ( $ options [ 'request_headers' ] , static function ( $ h ) { return 0 !== stripos ( $ h , 'Host:' ) ; } ) ; if ( isset ( $ options [ 'headers' ] [ 'authorization' ] ) || isset ( $ options [ 'headers' ] [ 'cookie' ] ) ) { $ redirectHeaders [ 'no_auth' ] = array_filter ( $ options [ 'request_headers' ] , static function ( $ h ) { return 0 !== stripos ( $ h , 'Authorization:' ) && 0 !== stripos ( $ h , 'Cookie:' ) ; } ) ; } } return static function ( $ ch , string $ location ) use ( $ redirectHeaders ) { if ( $ redirectHeaders && $ host = parse_url ( $ location , PHP_URL_HOST ) ) { $ requestHeaders = $ redirectHeaders [ 'host' ] === $ host ? $ redirectHeaders [ 'with_auth' ] : $ redirectHeaders [ 'no_auth' ] ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , $ requestHeaders ) ; } $ url = self :: parseUrl ( curl_getinfo ( $ ch , CURLINFO_EFFECTIVE_URL ) ) ; return implode ( '' , self :: resolveUrl ( self :: parseUrl ( $ location ) , $ url ) ) ; } ; }
docstring: Resolves relative URLs on redirects and deals with authentication headers.
  
  Work around CVE-2018-1000007: Authorization and Cookie headers should not follow redirects - fixed in Curl 7.64
docstring_tokens: Resolves relative URLs on redirects and deals with authentication headers .