Skip to content
Snippets Groups Projects
Commit c318d95e authored by Chris Leppanen's avatar Chris Leppanen
Browse files

Fix doc strings.

parent b83c0967
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
* @file * @file
* Download via HTTP. * 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 {} ...@@ -26,9 +27,14 @@ class HRCurlException extends Exception {}
* Discover RSS or atom feeds at the given URL. If document in given URL is an * 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. * HTML document, function attempts to discover RSS or Atom feeds.
* *
* @param $url * @param string $url
* @param null $settings * The url of the feed to retrieve.
* @return bool|string string - the discovered feed, FALSE - if the URL is not reachable or there * @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) { function http_request_get_common_syndication($url, $settings = NULL) {
...@@ -63,16 +69,26 @@ 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. * Get the content from the given URL.
* *
* @param $url * @param string $url
* A valid URL (not only web URLs). * A valid URL (not only web URLs).
* @param $username * @param string $username
* If the URL use authentication, here you can supply the username for this. * If the URL uses authentication, supply the username.
* @param $password * @param string $password
* If the URL use authentication, here you can supply the password for this. * If the URL uses authentication, supply the password.
* @param bool $accept_invalid_cert * @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) { 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)) { if (!$username && valid_url($url, TRUE)) {
// Handle password protected feeds. // Handle password protected feeds.
$url_parts = parse_url($url); $url_parts = parse_url($url);
...@@ -82,12 +98,6 @@ function http_request_get($url, $username = NULL, $password = NULL, $accept_inva ...@@ -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(); $curl = http_request_use_curl();
// Only download and parse data if really needs refresh. // Only download and parse data if really needs refresh.
...@@ -275,7 +285,8 @@ function http_request_is_feed($content_type, $data) { ...@@ -275,7 +285,8 @@ function http_request_is_feed($content_type, $data) {
return TRUE; 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; return FALSE;
} }
...@@ -301,7 +312,8 @@ function http_request_find_feeds($html) { ...@@ -301,7 +312,8 @@ function http_request_find_feeds($html) {
preg_match_all(HTTP_REQUEST_PCRE_TAG_ATTRIBUTES, $link_tag, $attributes, PREG_SET_ORDER); preg_match_all(HTTP_REQUEST_PCRE_TAG_ATTRIBUTES, $link_tag, $attributes, PREG_SET_ORDER);
foreach ($attributes as $attribute) { 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])) { if (!empty($attribute[1]) && !empty($attribute[2])) {
$candidate[drupal_strtolower($attribute[1])] = drupal_strtolower(decode_entities($attribute[2])); $candidate[drupal_strtolower($attribute[1])] = drupal_strtolower(decode_entities($attribute[2]));
} }
...@@ -324,13 +336,12 @@ function http_request_find_feeds($html) { ...@@ -324,13 +336,12 @@ function http_request_find_feeds($html) {
* Create an absolute url. * Create an absolute url.
* *
* @param string $url * @param string $url
* The href to transform. * The href to transform.
* * @param string $base_url
* @param $base_url * The url to be used as the base for a relative $url.
* The url to be used as the base for a relative $url.
* *
* @return string * @return string
* an absolute url * An absolute url
*/ */
function http_request_create_absolute_url($url, $base_url) { function http_request_create_absolute_url($url, $base_url) {
$url = trim($url); $url = trim($url);
...@@ -341,7 +352,8 @@ function http_request_create_absolute_url($url, $base_url) { ...@@ -341,7 +352,8 @@ function http_request_create_absolute_url($url, $base_url) {
// Turn relative url into absolute. // Turn relative url into absolute.
if (valid_url($url, FALSE)) { 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); $parsed_url = parse_url($base_url);
$path = dirname($parsed_url['path']); $path = dirname($parsed_url['path']);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment