Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. StreamContextFactory.php

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\Util

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal