protected static function build_custom_headers($headers)
{
if ($headers == NULL) {
return NULL;
} elseif (is_string($headers)) {
return $headers;
} elseif ($headers == array_values($headers)) {
return implode("\n", $headers);
} else {
$join_pair = function ($key, $value) {
return $key . ": " . $value;
};
return implode("\n", array_map($join_pair, array_keys($headers), array_values($headers)));
}
}