Created
September 3, 2014 15:55
-
-
Save OnkelTem/a426c0759280b9634642 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url_a = parse_url($base_url . drupal_encode_path($url)); | |
$fp = fsockopen($url_a['host'], 80, $errno, $errstr, 5); | |
if (!$fp) { | |
echo "$errstr ($errno)<br />\n"; | |
} else { | |
$out = "GET $url_a[path] HTTP/1.1\r\n"; | |
$out .= "Host: $url_a[host]\r\n"; | |
$out .= "Connection: Close\r\n\r\n"; | |
fwrite($fp, $out); | |
while (!feof($fp)) { | |
$s = fgets($fp, 128); | |
if (strpos($s, 'Content-Type') === 0) { | |
$result = explode(';', substr($s, 13)); | |
$content_type['mime'] = trim(array_shift($result)); | |
foreach($result as $chunk) { | |
$chunk_a = explode('=', $chunk); | |
$content_type[$chunk_a[0]] = trim($chunk_a[1]); | |
} | |
break; | |
} | |
} | |
fclose($fp); | |
} | |
$content_types[$url] = $content_type; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment