WP_HTTP_Requests_Response::header
Sets a single HTTP header.
Method of the class: WP_HTTP_Requests_Response{}
No Hooks.
Returns
null. Nothing (null).
Usage
$WP_HTTP_Requests_Response = new WP_HTTP_Requests_Response(); $WP_HTTP_Requests_Response->header( $key, $value, $replace );
- $key(string) (required)
- Header name.
- $value(string) (required)
- Header value.
- $replace(true|false)
- Whether to replace an existing header of the same name.
Default:true
Changelog
| Since 4.6.0 | Introduced. |
WP_HTTP_Requests_Response::header() WP HTTP Requests Response::header code WP 6.9.1
public function header( $key, $value, $replace = true ) {
if ( $replace ) {
unset( $this->response->headers[ $key ] );
}
$this->response->headers[ $key ] = $value;
}