Skip to content

Commit

Permalink
Allow encoding in Content-Type
Browse files Browse the repository at this point in the history
  • Loading branch information
ghalse committed Aug 15, 2023
1 parent bb42aa8 commit 25c8430
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fetchmetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 25c8430

Please sign in to comment.