function StreamContextFactory::fixHttpHeaderField
A bug in PHP prevents the headers from correctly being sent when a content-type header is present and NOT at the end of the array
This method fixes the array by moving the content-type header to the end
@link https://bugs.php.net/bug.php?id=61548
Parameters
string|string[] $header:
Return value
string[]
1 call to StreamContextFactory::fixHttpHeaderField()
- StreamContextFactory::getContext in vendor/
composer/ composer/ src/ Composer/ Util/ StreamContextFactory.php - Creates a context supporting HTTP proxies
File
-
vendor/
composer/ composer/ src/ Composer/ Util/ StreamContextFactory.php, line 244
Class
- StreamContextFactory
- Allows the creation of a basic context supporting http proxy
Namespace
Composer\UtilCode
private static function fixHttpHeaderField($header) : array {
if (!is_array($header)) {
$header = explode("\r\n", $header);
}
uasort($header, static function ($el) : int {
return stripos($el, 'content-type') === 0 ? 1 : -1;
});
return $header;
}