WP_REST_Request::set_headers()publicWP 4.4.0

Sets headers on the request.

Method of the class: WP_REST_Request{}

No Hooks.

Return

null. Nothing (null).

Usage

$WP_REST_Request = new WP_REST_Request();
$WP_REST_Request->set_headers( $headers, $override );
$headers(array) (required)
Map of header name to value.
$override(true|false)
If true, replace the request's headers. Otherwise, merge with existing.
Default: true

Changelog

Since 4.4.0 Introduced.

WP_REST_Request::set_headers() code WP 6.5.2

public function set_headers( $headers, $override = true ) {
	if ( true === $override ) {
		$this->headers = array();
	}

	foreach ( $headers as $key => $value ) {
		$this->set_header( $key, $value );
	}
}