WP_REST_Request::add_header()publicWP 4.4.0

Appends a header value for the given header.

Method of the class: WP_REST_Request{}

No Hooks.

Return

null. Nothing (null).

Usage

$WP_REST_Request = new WP_REST_Request();
$WP_REST_Request->add_header( $key, $value );
$key(string) (required)
Header name.
$value(string) (required)
Header value, or list of values.

Changelog

Since 4.4.0 Introduced.

WP_REST_Request::add_header() code WP 6.6.2

public function add_header( $key, $value ) {
	$key   = $this->canonicalize_header_name( $key );
	$value = (array) $value;

	if ( ! isset( $this->headers[ $key ] ) ) {
		$this->headers[ $key ] = array();
	}

	$this->headers[ $key ] = array_merge( $this->headers[ $key ], $value );
}