diff --git a/fetchmetadata.php b/fetchmetadata.php index f6070da..4b45a46 100644 --- a/fetchmetadata.php +++ b/fetchmetadata.php @@ -79,12 +79,12 @@ function badGateway($message) if ($data === false) badGateway(curl_error($curl)); -if (!in_array(curl_getinfo($curl, CURLINFO_CONTENT_TYPE), $SUPPORTED_CONTENT_TYPES)) +if (!in_array(preg_replace('/\s*;.*$/', '', curl_getinfo($curl, CURLINFO_CONTENT_TYPE)), $SUPPORTED_CONTENT_TYPES)) badGateway('Got unsupported content type. Only accept: ' . implode(', ', $SUPPORTED_CONTENT_TYPES)); http_response_code(curl_getinfo($curl, CURLINFO_RESPONSE_CODE)); header('Status: ' . curl_getinfo($curl, CURLINFO_RESPONSE_CODE)); -header('Content-Type: text/plain'); /* edit wants plain text, not DOM */ +header('Content-Type: text/plain' . preg_replace('/^[^;]+/', '', curl_getinfo($curl, CURLINFO_CONTENT_TYPE))); /* edit wants plain text, not DOM; preserve encoding */ header('Content-Length: ' . curl_getinfo($curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD)); header('X-Location: ' . curl_getinfo($curl, CURLINFO_EFFECTIVE_URL)); print substr($data, curl_getinfo($curl, CURLINFO_HEADER_SIZE));