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

Issue #1112876 by chx: Added Support digest auth.

parent abb651cc
No related branches found
No related tags found
No related merge requests found
...@@ -31,18 +31,9 @@ class HRCurlException extends Exception {} ...@@ -31,18 +31,9 @@ class HRCurlException extends Exception {}
* @return bool|string string - the discovered feed, FALSE - if the URL is not reachable or there * @return bool|string string - the discovered feed, FALSE - if the URL is not reachable or there
*/ */
function http_request_get_common_syndication($url, $settings = NULL) { function http_request_get_common_syndication($url, $settings = NULL) {
$password = $username = NULL;
if (feeds_valid_url($url, TRUE)) {
// Handle password protected feeds.
$url_parts = parse_url($url);
if (!empty($url_parts['user'])) {
$password = $url_parts['pass'];
$username = $url_parts['user'];
}
}
$accept_invalid_cert = isset($settings['accept_invalid_cert']) ? $settings['accept_invalid_cert'] : FALSE; $accept_invalid_cert = isset($settings['accept_invalid_cert']) ? $settings['accept_invalid_cert'] : FALSE;
$download = http_request_get($url, $username, $password, $accept_invalid_cert); $download = http_request_get($url, NULL, NULL, $accept_invalid_cert);
// Cannot get the feed, return. // Cannot get the feed, return.
// http_request_get() always returns 200 even if its 304. // http_request_get() always returns 200 even if its 304.
...@@ -82,6 +73,15 @@ function http_request_get_common_syndication($url, $settings = NULL) { ...@@ -82,6 +73,15 @@ function http_request_get_common_syndication($url, $settings = NULL) {
* @return object A stdClass object that describes the data downloaded from $url. The object's * @return object A stdClass object that describes the data downloaded from $url. The object's
*/ */
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) {
if (!$username && valid_url($url, TRUE)) {
// Handle password protected feeds.
$url_parts = parse_url($url);
if (!empty($url_parts['user'])) {
$password = $url_parts['pass'];
$username = $url_parts['user'];
}
}
// Intra-pagedownload cache, avoid to download the same content twice within one page download // Intra-pagedownload cache, avoid to download the same content twice within one page download
// (it's possible, compatible and parse calls). // (it's possible, compatible and parse calls).
static $download_cache = array(); static $download_cache = array();
...@@ -152,6 +152,7 @@ function http_request_get($url, $username = NULL, $password = NULL, $accept_inva ...@@ -152,6 +152,7 @@ function http_request_get($url, $username = NULL, $password = NULL, $accept_inva
curl_setopt($download, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($download, CURLOPT_FOLLOWLOCATION, TRUE);
if (!empty($username)) { if (!empty($username)) {
curl_setopt($download, CURLOPT_USERPWD, "{$username}:{$password}"); curl_setopt($download, CURLOPT_USERPWD, "{$username}:{$password}");
curl_setopt($download, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
} }
curl_setopt($download, CURLOPT_HTTPHEADER, $headers); curl_setopt($download, CURLOPT_HTTPHEADER, $headers);
curl_setopt($download, CURLOPT_HEADER, TRUE); curl_setopt($download, CURLOPT_HEADER, TRUE);
......
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