WP_REST_Request::canonicalize_header_name( string $key ): string

Canonicalizes the header name.

Description

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.

Parameters

$keystringrequired
Header name.

Return

string Canonicalized name.

Source

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

	return $key;
}

Changelog

VersionDescription
4.4.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.