WP_REST_Request::canonicalize_header_name()public staticWP 4.4.0

Canonicalizes the header name.

Ensures that header names are always treated the same regardless of source. Header names are always case insensitive.

Note that we treat - (dashes) and _ (underscores) as the same character, as per header parsing rules in both Apache and nginx.

Method of the class: WP_REST_Request{}

No Hooks.

Return

String. Canonicalized name.

Usage

$result = WP_REST_Request::canonicalize_header_name( $key );
$key(string) (required)
Header name.

Changelog

Since 4.4.0 Introduced.

WP_REST_Request::canonicalize_header_name() code WP 6.1.1

public static function canonicalize_header_name( $key ) {
	$key = strtolower( $key );
	$key = str_replace( '-', '_', $key );

	return $key;
}