Merge branch '2.5.x-saas' of github.com:sourcefabric/Airtime into 2.5.x-saas

This commit is contained in:
Albert Santoni 2014-01-29 17:20:53 -05:00
commit d68227939f
1 changed files with 19 additions and 13 deletions

View File

@ -360,21 +360,27 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
private static function discoverStreamMime($url) private static function discoverStreamMime($url)
{ {
//TODO: What if invalid URL? try {
$headers = get_headers($url); $headers = @get_headers($url);
$headers = self::cleanHeaders($headers); $mime = null;
$content_length_found = false;
$mime = null;
$content_length_found = false; if ($headers !== false) {
foreach ($headers as $h) { $headers = self::cleanHeaders($headers);
if (preg_match("/^content-type:/i", $h)) { foreach ($headers as $h) {
list(, $value) = explode(":", $h, 2); if (preg_match("/^content-type:/i", $h)) {
$mime = trim($value); list(, $value) = explode(":", $h, 2);
} $mime = trim($value);
if (preg_match("/^content-length:/i", $h)) { }
$content_length_found = true; 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); return array($mime, $content_length_found);