On this page
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
$keystring Required-
Header name.
Return
string Canonicalized name.
Source
File: wp-includes/rest-api/class-wp-rest-request.php. View all references
public static function canonicalize_header_name( $key ) {
$key = strtolower( $key );
$key = str_replace( '-', '_', $key );
return $key;
}
Related
Used By
| Used By | Description |
|---|---|
| WP_REST_Request::get_header_as_array() wp-includes/rest-api/class-wp-rest-request.php | Retrieves header values from the request. |
| WP_REST_Request::set_header() wp-includes/rest-api/class-wp-rest-request.php | Sets the header on request. |
| WP_REST_Request::add_header() wp-includes/rest-api/class-wp-rest-request.php | Appends a header value for the given header. |
| WP_REST_Request::remove_header() wp-includes/rest-api/class-wp-rest-request.php | Removes all values for a header. |
| WP_REST_Request::get_header() wp-includes/rest-api/class-wp-rest-request.php | Retrieves the given header from the request. |
Changelog
| Version | Description |
|---|---|
| 4.4.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_request/canonicalize_header_name