Skip to content
Snippets Groups Projects

Resolve "Data ingress for context information for tiki-wiki"

1 file
+ 21
0
Compare changes
  • Side-by-side
  • Inline
+ 21
0
@@ -31,6 +31,22 @@ function context($url, $domain, $content) {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$headers = [];
curl_setopt($ch, CURLOPT_HEADERFUNCTION,
function($curl, $header) use (&$headers)
{
$len = strlen($header);
$header = explode(':', $header, 2);
if (count($header) < 2) // ignore invalid headers
return $len;
$key = strtolower(trim(array_shift($header)));
$headers[$key] = implode($header);
return $len;
}
);
$response = curl_exec($ch);
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
@@ -40,6 +56,11 @@ function context($url, $domain, $content) {
$response = '{"errors": ["SmartDataContext API not available"]}';
}
if (array_key_exists("content-disposition", $headers)) {
header("Content-Type: " . $headers['content-type']);
header("content-disposition: " . $headers['content-disposition']);
}
http_response_code($http_status);
return $response;
}
Loading