CC-5672: Webstream warnings on SaaS
Don't parse/use header info if get_headers returns false
This commit is contained in:
parent
c9d98e4e10
commit
7a04f7d98e
|
@ -360,21 +360,27 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
|
||||
private static function discoverStreamMime($url)
|
||||
{
|
||||
//TODO: What if invalid URL?
|
||||
$headers = get_headers($url);
|
||||
try {
|
||||
$headers = @get_headers($url);
|
||||
|
||||
$headers = self::cleanHeaders($headers);
|
||||
|
||||
$mime = null;
|
||||
$content_length_found = false;
|
||||
foreach ($headers as $h) {
|
||||
if (preg_match("/^content-type:/i", $h)) {
|
||||
list(, $value) = explode(":", $h, 2);
|
||||
$mime = trim($value);
|
||||
}
|
||||
if (preg_match("/^content-length:/i", $h)) {
|
||||
$content_length_found = true;
|
||||
$mime = null;
|
||||
$content_length_found = false;
|
||||
|
||||
if ($headers !== false) {
|
||||
$headers = self::cleanHeaders($headers);
|
||||
foreach ($headers as $h) {
|
||||
if (preg_match("/^content-type:/i", $h)) {
|
||||
list(, $value) = explode(":", $h, 2);
|
||||
$mime = trim($value);
|
||||
}
|
||||
if (preg_match("/^content-length:/i", $h)) {
|
||||
$content_length_found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
Logging::info("Invalid stream URL");
|
||||
Logging::info($e->getMessage());
|
||||
}
|
||||
|
||||
return array($mime, $content_length_found);
|
||||
|
|
Loading…
Reference in New Issue