original_string: public function fetchURL($url, $followRedirects = true, $username = null, $password = null, $headers = array())
      {
  
          if (function_exists('curl_init')) {
  
              $contents = $this->curlRequest($url, false, $followRedirects, $username, $password, $headers);
  
              return $contents;
  
          } else {
  
              if ($this->userAgent != null) {
                  $opts = array(
                      'http'=> array(
                      'user_agent'=> $this->userAgent,
                      'max_redirects' => $this->redirects,              // stop after 10 redirects
                    )
                  );
  
              }
  
              if ($username && $password) {
                  $opts = ($opts) ? $opts : array('http' => array());
                  $opts['http']['header'] =
                      array('Authorization: Basic '
                          . base64_encode("$username:$password"));
              }
  
              if ($headers) {
                  $opts['http']['header'] =$headers;
              }
  
              $context = ($opts) ? stream_context_create($opts) : null;
  
              unset($opts);
  
              $contents = @file_get_contents($url, false, $context);
  
              if ($contents === false)
                  throw new HttpRequestException("Unknown error fetching URL '".$url."'");
  
              unset($context);
              unset($url);
  
              return $contents;
          }
      }
code: public function fetchURL($url, $followRedirects = true, $username = null, $password = null, $headers = array())
      {
  
          if (function_exists('curl_init')) {
  
              $contents = $this->curlRequest($url, false, $followRedirects, $username, $password, $headers);
  
              return $contents;
  
          } else {
  
              if ($this->userAgent != null) {
                  $opts = array(
                      'http'=> array(
                      'user_agent'=> $this->userAgent,
                      'max_redirects' => $this->redirects,              // stop after 10 redirects
                    )
                  );
  
              }
  
              if ($username && $password) {
                  $opts = ($opts) ? $opts : array('http' => array());
                  $opts['http']['header'] =
                      array('Authorization: Basic '
                          . base64_encode("$username:$password"));
              }
  
              if ($headers) {
                  $opts['http']['header'] =$headers;
              }
  
              $context = ($opts) ? stream_context_create($opts) : null;
  
              unset($opts);
  
              $contents = @file_get_contents($url, false, $context);
  
              if ($contents === false)
                  throw new HttpRequestException("Unknown error fetching URL '".$url."'");
  
              unset($context);
              unset($url);
  
              return $contents;
          }
      }
code_tokens: public function fetchURL ( $ url , $ followRedirects = true , $ username = null , $ password = null , $ headers = array ( ) ) { if ( function_exists ( 'curl_init' ) ) { $ contents = $ this -> curlRequest ( $ url , false , $ followRedirects , $ username , $ password , $ headers ) ; return $ contents ; } else { if ( $ this -> userAgent != null ) { $ opts = array ( 'http' => array ( 'user_agent' => $ this -> userAgent , 'max_redirects' => $ this -> redirects , // stop after 10 redirects ) ) ; } if ( $ username && $ password ) { $ opts = ( $ opts ) ? $ opts : array ( 'http' => array ( ) ) ; $ opts [ 'http' ] [ 'header' ] = array ( 'Authorization: Basic ' . base64_encode ( "$username:$password" ) ) ; } if ( $ headers ) { $ opts [ 'http' ] [ 'header' ] = $ headers ; } $ context = ( $ opts ) ? stream_context_create ( $ opts ) : null ; unset ( $ opts ) ; $ contents = @ file_get_contents ( $ url , false , $ context ) ; if ( $ contents === false ) throw new HttpRequestException ( "Unknown error fetching URL '" . $ url . "'" ) ; unset ( $ context ) ; unset ( $ url ) ; return $ contents ; } }
docstring: Fetch the contents of a URL
  
  @param string $url Fully-qualified URL to request
  @param bool   $followRedirects If true, follow redirects to default max of 5
  @param string $username Username to use in http authentication header
  @param string $password Password to use in http authentication header
  @param array  $headers  Array of http headers to append to the existing headers list
  
  @return string Contents of the HTTP response body
  @throws HttpRequestException If contents cannot be fetched
docstring_tokens: Fetch the contents of a URL