WP_HTTP_Requests_Response::header() WordPress Method
The WP_HTTP_Requests_Response::header() method is used to get the value of a header from the HTTP response.
WP_HTTP_Requests_Response::header( string $key, string $value, bool $replace = true ) #
Sets a single HTTP header.
Contents
Parameters
- $key
(string)(Required)Header name.
- $value
(string)(Required)Header value.
- $replace
(bool)(Optional) Whether to replace an existing header of the same name.
Default value: true
Source
File: wp-includes/class-wp-http-requests-response.php
public function header( $key, $value, $replace = true ) { if ( $replace ) { unset( $this->response->headers[ $key ] ); } $this->response->headers[ $key ] = $value; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
4.6.0 | Introduced. |