From c318d95e0356936345cc4d6970b6462899099a06 Mon Sep 17 00:00:00 2001 From: Chris Leppanen <chris.leppanen@gmail.com> Date: Mon, 23 Jul 2012 12:27:21 -0700 Subject: [PATCH] Fix doc strings. --- libraries/http_request.inc | 62 +++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/libraries/http_request.inc b/libraries/http_request.inc index 392d9f79..b61b1ce8 100644 --- a/libraries/http_request.inc +++ b/libraries/http_request.inc @@ -4,7 +4,8 @@ * @file * Download via HTTP. * - * Support caching, HTTP Basic Authentication, detection of RSS/Atom feeds, redirects. + * Support caching, HTTP Basic Authentication, detection of RSS/Atom feeds, + * redirects. */ /** @@ -26,9 +27,14 @@ class HRCurlException extends Exception {} * Discover RSS or atom feeds at the given URL. If document in given URL is an * HTML document, function attempts to discover RSS or Atom feeds. * - * @param $url - * @param null $settings - * @return bool|string string - the discovered feed, FALSE - if the URL is not reachable or there + * @param string $url + * The url of the feed to retrieve. + * @param array $settings + * An optional array of settings. Valid options are: accept_invalid_cert. + * + * @return bool|string + * The discovered feed, or FALSE if the URL is not reachable or there was an + * error. */ function http_request_get_common_syndication($url, $settings = NULL) { @@ -63,16 +69,26 @@ function http_request_get_common_syndication($url, $settings = NULL) { /** * Get the content from the given URL. * - * @param $url - * A valid URL (not only web URLs). - * @param $username - * If the URL use authentication, here you can supply the username for this. - * @param $password - * If the URL use authentication, here you can supply the password for this. + * @param string $url + * A valid URL (not only web URLs). + * @param string $username + * If the URL uses authentication, supply the username. + * @param string $password + * If the URL uses authentication, supply the password. * @param bool $accept_invalid_cert - * @return object A stdClass object that describes the data downloaded from $url. The object's + * Whether to accept invalid certificates. + + * @return stdClass + * An object that describes the data downloaded from $url. */ function http_request_get($url, $username = NULL, $password = NULL, $accept_invalid_cert = FALSE) { + // Intra-pagedownload cache, avoid to download the same content twice within + // one page download (it's possible, compatible and parse calls). + static $download_cache = array(); + if (isset($download_cache[$url])) { + return $download_cache[$url]; + } + if (!$username && valid_url($url, TRUE)) { // Handle password protected feeds. $url_parts = parse_url($url); @@ -82,12 +98,6 @@ function http_request_get($url, $username = NULL, $password = NULL, $accept_inva } } - // Intra-pagedownload cache, avoid to download the same content twice within one page download - // (it's possible, compatible and parse calls). - static $download_cache = array(); - if (isset($download_cache[$url])) { - return $download_cache[$url]; - } $curl = http_request_use_curl(); // Only download and parse data if really needs refresh. @@ -275,7 +285,8 @@ function http_request_is_feed($content_type, $data) { return TRUE; } - // @TODO: Sometimes the content-type can be text/html but still be a valid feed. + // @TODO: Sometimes the content-type can be text/html but still be a valid + // feed. return FALSE; } @@ -301,7 +312,8 @@ function http_request_find_feeds($html) { preg_match_all(HTTP_REQUEST_PCRE_TAG_ATTRIBUTES, $link_tag, $attributes, PREG_SET_ORDER); foreach ($attributes as $attribute) { - // Find the key value pairs, attribute[1] is key and attribute[2] is the value. + // Find the key value pairs, attribute[1] is key and attribute[2] is the + // value. if (!empty($attribute[1]) && !empty($attribute[2])) { $candidate[drupal_strtolower($attribute[1])] = drupal_strtolower(decode_entities($attribute[2])); } @@ -324,13 +336,12 @@ function http_request_find_feeds($html) { * Create an absolute url. * * @param string $url - * The href to transform. - * - * @param $base_url - * The url to be used as the base for a relative $url. + * The href to transform. + * @param string $base_url + * The url to be used as the base for a relative $url. * * @return string - * an absolute url + * An absolute url */ function http_request_create_absolute_url($url, $base_url) { $url = trim($url); @@ -341,7 +352,8 @@ function http_request_create_absolute_url($url, $base_url) { // Turn relative url into absolute. if (valid_url($url, FALSE)) { - // Produces variables $scheme, $host, $user, $pass, $path, $query and $fragment. + // Produces variables $scheme, $host, $user, $pass, $path, $query and + // $fragment. $parsed_url = parse_url($base_url); $path = dirname($parsed_url['path']); -- GitLab