Skip to content
Snippets Groups Projects
Commit b899546e authored by Rodrigo Goncalves's avatar Rodrigo Goncalves Committed by Guilherme Arthur Gerônimo
Browse files

Fix to return correctly filename and mimetype for unstructured data

parent 5a7b03ba
No related branches found
No related tags found
1 merge request!20Resolve "Data ingress for context information for tiki-wiki"
This commit is part of merge request !20. Comments created here will be created in the context of that merge request.
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment