WP_REST_Server::send_header() WordPress Method

The WP_REST_Server::send_header() method is used to send a HTTP header for a REST response. The method takes two arguments: the header name and the header value.

WP_REST_Server::send_header( string $key, string $value ) #

Sends an HTTP header.


Parameters

$key

(string)(Required)Header key.

$value

(string)(Required)Header value.


Top ↑

Source

File: wp-includes/rest-api/class-wp-rest-server.php

	public function send_header( $key, $value ) {
		/*
		 * Sanitize as per RFC2616 (Section 4.2):
		 *
		 * Any LWS that occurs between field-content MAY be replaced with a
		 * single SP before interpreting the field value or forwarding the
		 * message downstream.
		 */
		$value = preg_replace( '/\s+/', ' ', $value );
		header( sprintf( '%s: %s', $key, $value ) );
	}


Top ↑

Changelog

Changelog
VersionDescription
4.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.