WordPress\AiClient\Providers\Http\Collections
HeadersCollection::set
Sets a header value, replacing any existing value.
Метод класса: HeadersCollection{}
Хуков нет.
Возвращает
void. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->set( $name, $value ): void;
- $name(строка) (обязательный)
- The header name.
- $value(строка|list
) (обязательный) - The header value(s).
Список изменений
| С версии 0.1.0 | Введена. |
Код HeadersCollection::set() HeadersCollection::set WP 7.1.2
private function set(string $name, $value): void
{
if (is_array($value)) {
$normalizedValues = array_values($value);
} else {
// Split comma-separated string into array
$normalizedValues = array_map('trim', explode(',', $value));
}
$lowerName = strtolower($name);
// If header exists with different casing, remove the old casing
if (isset($this->headersMap[$lowerName])) {
$oldName = $this->headersMap[$lowerName];
if ($oldName !== $name) {
unset($this->headers[$oldName]);
}
}
// Always use the new casing
$this->headers[$name] = $normalizedValues;
$this->headersMap[$lowerName] = $name;
}