WC_API_Server::get_headers()publicWC 2.1

Extract headers from a PHP-style $_SERVER array

Метод класса: WC_API_Server{}

Хуков нет.

Возвращает

Массив. Headers extracted from the input

Использование

$WC_API_Server = new WC_API_Server();
$WC_API_Server->get_headers( $server );
$server(массив) (обязательный)
Associative array similar to $_SERVER

Список изменений

С версии 2.1 Введена.

Код WC_API_Server::get_headers() WC 8.7.0

public function get_headers( $server ) {
	$headers = array();
	// CONTENT_* headers are not prefixed with HTTP_
	$additional = array( 'CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true );

	foreach ( $server as $key => $value ) {
		if ( strpos( $key, 'HTTP_' ) === 0 ) {
			$headers[ substr( $key, 5 ) ] = $value;
		} elseif ( isset( $additional[ $key ] ) ) {
			$headers[ $key ] = $value;
		}
	}

	return $headers;
}