2020-04-07 13:03:04 +00:00
< ? php
2024-10-09 12:44:17 +00:00
/**
* Signature class file .
*
* @ package Activitypub
*/
2020-04-07 13:03:04 +00:00
namespace Activitypub ;
2023-10-22 22:20:53 +00:00
use WP_Error ;
use DateTime ;
use DateTimeZone ;
2023-12-08 23:23:11 +00:00
use WP_REST_Request ;
2023-10-22 22:20:53 +00:00
use Activitypub\Collection\Users ;
2020-04-07 13:03:04 +00:00
/**
2024-10-09 12:44:17 +00:00
* ActivityPub Signature Class .
2020-04-07 13:03:04 +00:00
*
* @ author Matthias Pfefferle
2023-10-22 22:20:53 +00:00
* @ author Django Doucet
2020-04-07 13:03:04 +00:00
*/
class Signature {
/**
2023-10-22 22:20:53 +00:00
* Return the public key for a given user .
*
* @ param int $user_id The WordPress User ID .
2024-10-09 12:44:17 +00:00
* @ param bool $force Optional . Force the generation of a new key pair . Default false .
2020-04-07 13:03:04 +00:00
*
2023-10-22 22:20:53 +00:00
* @ return mixed The public key .
2020-04-07 13:03:04 +00:00
*/
2023-10-22 22:20:53 +00:00
public static function get_public_key_for ( $user_id , $force = false ) {
if ( $force ) {
self :: generate_key_pair_for ( $user_id );
}
$key_pair = self :: get_keypair_for ( $user_id );
2020-04-07 13:03:04 +00:00
2023-10-22 22:20:53 +00:00
return $key_pair [ 'public_key' ];
}
/**
* Return the private key for a given user .
*
* @ param int $user_id The WordPress User ID .
2024-10-09 12:44:17 +00:00
* @ param bool $force Optional . Force the generation of a new key pair . Default false .
2023-10-22 22:20:53 +00:00
*
* @ return mixed The private key .
*/
public static function get_private_key_for ( $user_id , $force = false ) {
if ( $force ) {
self :: generate_key_pair_for ( $user_id );
2020-04-07 13:03:04 +00:00
}
2023-10-22 22:20:53 +00:00
$key_pair = self :: get_keypair_for ( $user_id );
2020-04-07 13:03:04 +00:00
2023-10-22 22:20:53 +00:00
return $key_pair [ 'private_key' ];
2020-04-07 13:03:04 +00:00
}
/**
2023-10-22 22:20:53 +00:00
* Return the key pair for a given user .
2020-04-07 13:03:04 +00:00
*
2023-10-22 22:20:53 +00:00
* @ param int $user_id The WordPress User ID .
*
* @ return array The key pair .
2020-04-07 13:03:04 +00:00
*/
2023-10-22 22:20:53 +00:00
public static function get_keypair_for ( $user_id ) {
$option_key = self :: get_signature_options_key_for ( $user_id );
2024-10-09 12:44:17 +00:00
$key_pair = \get_option ( $option_key );
2020-04-07 13:03:04 +00:00
2023-10-22 22:20:53 +00:00
if ( ! $key_pair ) {
$key_pair = self :: generate_key_pair_for ( $user_id );
2020-04-07 13:03:04 +00:00
}
2023-10-22 22:20:53 +00:00
return $key_pair ;
2020-04-07 13:03:04 +00:00
}
/**
* Generates the pair keys
*
2023-10-22 22:20:53 +00:00
* @ param int $user_id The WordPress User ID .
*
* @ return array The key pair .
2020-04-07 13:03:04 +00:00
*/
2023-10-22 22:20:53 +00:00
protected static function generate_key_pair_for ( $user_id ) {
$option_key = self :: get_signature_options_key_for ( $user_id );
2024-10-09 12:44:17 +00:00
$key_pair = self :: check_legacy_key_pair_for ( $user_id );
2023-10-22 22:20:53 +00:00
if ( $key_pair ) {
\add_option ( $option_key , $key_pair );
return $key_pair ;
}
2020-04-07 13:03:04 +00:00
$config = array (
2024-10-09 12:44:17 +00:00
'digest_alg' => 'sha512' ,
2020-04-07 13:03:04 +00:00
'private_key_bits' => 2048 ,
2020-12-25 19:23:08 +00:00
'private_key_type' => \OPENSSL_KEYTYPE_RSA ,
2020-04-07 13:03:04 +00:00
);
2024-10-09 12:44:17 +00:00
$key = \openssl_pkey_new ( $config );
2020-04-07 13:03:04 +00:00
$priv_key = null ;
2024-10-09 12:44:17 +00:00
$detail = array ();
if ( $key ) {
\openssl_pkey_export ( $key , $priv_key );
2020-04-07 13:03:04 +00:00
2024-10-09 12:44:17 +00:00
$detail = \openssl_pkey_get_details ( $key );
}
2020-04-07 13:03:04 +00:00
2024-10-09 12:44:17 +00:00
// Check if keys are valid.
2023-10-22 22:20:53 +00:00
if (
empty ( $priv_key ) || ! is_string ( $priv_key ) ||
! isset ( $detail [ 'key' ] ) || ! is_string ( $detail [ 'key' ] )
) {
return array (
'private_key' => null ,
'public_key' => null ,
);
}
$key_pair = array (
'private_key' => $priv_key ,
'public_key' => $detail [ 'key' ],
);
2024-10-09 12:44:17 +00:00
// Persist keys.
2023-10-22 22:20:53 +00:00
\add_option ( $option_key , $key_pair );
return $key_pair ;
}
/**
* Return the option key for a given user .
*
* @ param int $user_id The WordPress User ID .
*
* @ return string The option key .
*/
protected static function get_signature_options_key_for ( $user_id ) {
$id = $user_id ;
if ( $user_id > 0 ) {
$user = \get_userdata ( $user_id );
2024-10-09 12:44:17 +00:00
// Sanitize username because it could include spaces and special chars.
2023-10-22 22:20:53 +00:00
$id = sanitize_title ( $user -> user_login );
}
return 'activitypub_keypair_for_' . $id ;
2020-04-07 13:03:04 +00:00
}
2023-10-22 22:20:53 +00:00
/**
* Check if there is a legacy key pair
*
* @ param int $user_id The WordPress User ID .
*
* @ return array | bool The key pair or false .
*/
protected static function check_legacy_key_pair_for ( $user_id ) {
switch ( $user_id ) {
case 0 :
2024-10-09 12:44:17 +00:00
$public_key = \get_option ( 'activitypub_blog_user_public_key' );
2023-10-22 22:20:53 +00:00
$private_key = \get_option ( 'activitypub_blog_user_private_key' );
break ;
case - 1 :
2024-10-09 12:44:17 +00:00
$public_key = \get_option ( 'activitypub_application_user_public_key' );
2023-10-22 22:20:53 +00:00
$private_key = \get_option ( 'activitypub_application_user_private_key' );
break ;
default :
2024-10-09 12:44:17 +00:00
$public_key = \get_user_meta ( $user_id , 'magic_sig_public_key' , true );
2023-10-22 22:20:53 +00:00
$private_key = \get_user_meta ( $user_id , 'magic_sig_private_key' , true );
break ;
}
if ( ! empty ( $public_key ) && is_string ( $public_key ) && ! empty ( $private_key ) && is_string ( $private_key ) ) {
return array (
'private_key' => $private_key ,
'public_key' => $public_key ,
);
}
return false ;
}
/**
2024-10-09 12:44:17 +00:00
* Generates the Signature for an HTTP Request .
2023-10-22 22:20:53 +00:00
*
* @ param int $user_id The WordPress User ID .
* @ param string $http_method The HTTP method .
* @ param string $url The URL to send the request to .
* @ param string $date The date the request is sent .
2024-10-09 12:44:17 +00:00
* @ param string $digest Optional . The digest of the request body . Default null .
2023-10-22 22:20:53 +00:00
*
* @ return string The signature .
*/
2022-12-19 23:08:11 +00:00
public static function generate_signature ( $user_id , $http_method , $url , $date , $digest = null ) {
2023-10-22 22:20:53 +00:00
$user = Users :: get_by_id ( $user_id );
$key = self :: get_private_key_for ( $user -> get__id () );
2020-04-07 13:03:04 +00:00
$url_parts = \wp_parse_url ( $url );
$host = $url_parts [ 'host' ];
$path = '/' ;
2024-10-09 12:44:17 +00:00
// Add path.
2020-04-07 13:03:04 +00:00
if ( ! empty ( $url_parts [ 'path' ] ) ) {
$path = $url_parts [ 'path' ];
}
2024-10-09 12:44:17 +00:00
// Add query.
2020-04-07 13:03:04 +00:00
if ( ! empty ( $url_parts [ 'query' ] ) ) {
$path .= '?' . $url_parts [ 'query' ];
}
2023-10-22 22:20:53 +00:00
$http_method = \strtolower ( $http_method );
2020-12-25 19:23:08 +00:00
if ( ! empty ( $digest ) ) {
2023-10-22 22:20:53 +00:00
$signed_string = " (request-target): $http_method $path\nhost : $host\ndate : $date\ndigest : $digest " ;
2020-12-25 19:23:08 +00:00
} else {
2022-12-19 23:08:11 +00:00
$signed_string = " (request-target): $http_method $path\nhost : $host\ndate : $date " ;
2020-12-25 19:23:08 +00:00
}
2020-04-07 13:03:04 +00:00
$signature = null ;
2020-12-25 19:23:08 +00:00
\openssl_sign ( $signed_string , $signature , $key , \OPENSSL_ALGO_SHA256 );
2024-10-09 12:44:17 +00:00
$signature = \base64_encode ( $signature ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
2020-04-07 13:03:04 +00:00
2023-10-22 22:20:53 +00:00
$key_id = $user -> get_url () . '#main-key' ;
2020-04-07 13:03:04 +00:00
2020-12-25 19:23:08 +00:00
if ( ! empty ( $digest ) ) {
return \sprintf ( 'keyId="%s",algorithm="rsa-sha256",headers="(request-target) host date digest",signature="%s"' , $key_id , $signature );
} else {
return \sprintf ( 'keyId="%s",algorithm="rsa-sha256",headers="(request-target) host date",signature="%s"' , $key_id , $signature );
}
2020-04-07 13:03:04 +00:00
}
2023-10-22 22:20:53 +00:00
/**
* Verifies the http signatures
*
2023-12-08 23:23:11 +00:00
* @ param WP_REST_Request | array $request The request object or $_SERVER array .
2023-10-22 22:20:53 +00:00
*
2024-10-09 12:44:17 +00:00
* @ return bool | WP_Error A boolean or WP_Error .
2023-10-22 22:20:53 +00:00
*/
public static function verify_http_signature ( $request ) {
2024-10-09 12:44:17 +00:00
if ( is_object ( $request ) ) { // REST Request object.
// Check if route starts with "index.php".
2023-10-22 22:20:53 +00:00
if ( str_starts_with ( $request -> get_route (), '/index.php' ) || ! rest_get_url_prefix () ) {
$route = $request -> get_route ();
} else {
$route = '/' . rest_get_url_prefix () . '/' . ltrim ( $request -> get_route (), '/' );
}
2024-10-09 12:44:17 +00:00
// Fix route for subdirectory installs.
2023-10-22 22:20:53 +00:00
$path = \wp_parse_url ( \get_home_url (), PHP_URL_PATH );
if ( \is_string ( $path ) ) {
$path = trim ( $path , '/' );
}
if ( $path ) {
$route = '/' . $path . $route ;
}
2024-10-09 12:44:17 +00:00
$headers = $request -> get_headers ();
2023-10-22 22:20:53 +00:00
$headers [ '(request-target)' ][ 0 ] = strtolower ( $request -> get_method () ) . ' ' . $route ;
} else {
2024-10-09 12:44:17 +00:00
$request = self :: format_server_request ( $request );
$headers = $request [ 'headers' ]; // $_SERVER array
2023-10-22 22:20:53 +00:00
$headers [ '(request-target)' ][ 0 ] = strtolower ( $headers [ 'request_method' ][ 0 ] ) . ' ' . $headers [ 'request_uri' ][ 0 ];
}
if ( ! isset ( $headers [ 'signature' ] ) ) {
2023-12-08 23:23:11 +00:00
return new WP_Error ( 'activitypub_signature' , __ ( 'Request not signed' , 'activitypub' ), array ( 'status' => 401 ) );
2023-10-22 22:20:53 +00:00
}
if ( array_key_exists ( 'signature' , $headers ) ) {
$signature_block = self :: parse_signature_header ( $headers [ 'signature' ][ 0 ] );
} elseif ( array_key_exists ( 'authorization' , $headers ) ) {
$signature_block = self :: parse_signature_header ( $headers [ 'authorization' ][ 0 ] );
}
if ( ! isset ( $signature_block ) || ! $signature_block ) {
2023-12-08 23:23:11 +00:00
return new WP_Error ( 'activitypub_signature' , __ ( 'Incompatible request signature. keyId and signature are required' , 'activitypub' ), array ( 'status' => 401 ) );
2023-10-22 22:20:53 +00:00
}
$signed_headers = $signature_block [ 'headers' ];
if ( ! $signed_headers ) {
$signed_headers = array ( 'date' );
}
$signed_data = self :: get_signed_data ( $signed_headers , $signature_block , $headers );
if ( ! $signed_data ) {
2023-12-08 23:23:11 +00:00
return new WP_Error ( 'activitypub_signature' , __ ( 'Signed request date outside acceptable time window' , 'activitypub' ), array ( 'status' => 401 ) );
2023-10-22 22:20:53 +00:00
}
$algorithm = self :: get_signature_algorithm ( $signature_block );
if ( ! $algorithm ) {
2023-12-08 23:23:11 +00:00
return new WP_Error ( 'activitypub_signature' , __ ( 'Unsupported signature algorithm (only rsa-sha256 and hs2019 are supported)' , 'activitypub' ), array ( 'status' => 401 ) );
2023-10-22 22:20:53 +00:00
}
if ( \in_array ( 'digest' , $signed_headers , true ) && isset ( $body ) ) {
if ( is_array ( $headers [ 'digest' ] ) ) {
$headers [ 'digest' ] = $headers [ 'digest' ][ 0 ];
}
2024-02-08 12:31:25 +00:00
$hashalg = 'sha256' ;
$digest = explode ( '=' , $headers [ 'digest' ], 2 );
2023-10-22 22:20:53 +00:00
if ( 'SHA-256' === $digest [ 0 ] ) {
$hashalg = 'sha256' ;
}
if ( 'SHA-512' === $digest [ 0 ] ) {
$hashalg = 'sha512' ;
}
if ( \base64_encode ( \hash ( $hashalg , $body , true ) ) !== $digest [ 1 ] ) { // phpcs:ignore
2023-12-08 23:23:11 +00:00
return new WP_Error ( 'activitypub_signature' , __ ( 'Invalid Digest header' , 'activitypub' ), array ( 'status' => 401 ) );
2023-10-22 22:20:53 +00:00
}
}
$public_key = self :: get_remote_key ( $signature_block [ 'keyId' ] );
if ( \is_wp_error ( $public_key ) ) {
return $public_key ;
}
$verified = \openssl_verify ( $signed_data , $signature_block [ 'signature' ], $public_key , $algorithm ) > 0 ;
if ( ! $verified ) {
2023-12-08 23:23:11 +00:00
return new WP_Error ( 'activitypub_signature' , __ ( 'Invalid signature' , 'activitypub' ), array ( 'status' => 401 ) );
2023-10-22 22:20:53 +00:00
}
return $verified ;
}
/**
2024-10-09 12:44:17 +00:00
* Get public key from key_id .
2023-10-22 22:20:53 +00:00
*
* @ param string $key_id The URL to the public key .
*
2023-12-08 23:23:11 +00:00
* @ return WP_Error | string The public key or WP_Error .
2023-10-22 22:20:53 +00:00
*/
2024-10-09 12:44:17 +00:00
public static function get_remote_key ( $key_id ) {
$actor = get_remote_metadata_by_actor ( strip_fragment_from_url ( $key_id ) );
2023-10-22 22:20:53 +00:00
if ( \is_wp_error ( $actor ) ) {
2023-12-08 23:23:11 +00:00
return new WP_Error (
'activitypub_no_remote_profile_found' ,
__ ( 'No Profile found or Profile not accessible' , 'activitypub' ),
array ( 'status' => 401 )
);
2023-10-22 22:20:53 +00:00
}
if ( isset ( $actor [ 'publicKey' ][ 'publicKeyPem' ] ) ) {
2024-10-09 12:44:17 +00:00
return \rtrim ( $actor [ 'publicKey' ][ 'publicKeyPem' ] );
2023-10-22 22:20:53 +00:00
}
2023-12-08 23:23:11 +00:00
return new WP_Error (
'activitypub_no_remote_key_found' ,
__ ( 'No Public-Key found' , 'activitypub' ),
array ( 'status' => 401 )
);
2023-10-22 22:20:53 +00:00
}
/**
2024-10-09 12:44:17 +00:00
* Gets the signature algorithm from the signature header .
2023-10-22 22:20:53 +00:00
*
2024-10-09 12:44:17 +00:00
* @ param array $signature_block The signature block .
2023-10-22 22:20:53 +00:00
*
* @ return string The signature algorithm .
*/
public static function get_signature_algorithm ( $signature_block ) {
if ( $signature_block [ 'algorithm' ] ) {
switch ( $signature_block [ 'algorithm' ] ) {
case 'rsa-sha-512' :
2024-10-09 12:44:17 +00:00
return 'sha512' ; // hs2019 https://datatracker.ietf.org/doc/html/draft-cavage-http-signatures-12.
2023-10-22 22:20:53 +00:00
default :
return 'sha256' ;
}
}
return false ;
}
/**
2024-10-09 12:44:17 +00:00
* Parses the Signature header .
2023-10-22 22:20:53 +00:00
*
* @ param string $signature The signature header .
*
2024-10-09 12:44:17 +00:00
* @ return array Signature parts .
2023-10-22 22:20:53 +00:00
*/
public static function parse_signature_header ( $signature ) {
2024-10-09 12:44:17 +00:00
$parsed_header = array ();
$matches = array ();
2023-10-22 22:20:53 +00:00
if ( \preg_match ( '/keyId="(.*?)"/ism' , $signature , $matches ) ) {
$parsed_header [ 'keyId' ] = trim ( $matches [ 1 ] );
}
2024-05-09 15:26:55 +00:00
if ( \preg_match ( '/created=["|\']*([0-9]*)["|\']*/ism' , $signature , $matches ) ) {
2023-10-22 22:20:53 +00:00
$parsed_header [ '(created)' ] = trim ( $matches [ 1 ] );
}
2024-05-09 15:26:55 +00:00
if ( \preg_match ( '/expires=["|\']*([0-9]*)["|\']*/ism' , $signature , $matches ) ) {
2023-10-22 22:20:53 +00:00
$parsed_header [ '(expires)' ] = trim ( $matches [ 1 ] );
}
if ( \preg_match ( '/algorithm="(.*?)"/ism' , $signature , $matches ) ) {
$parsed_header [ 'algorithm' ] = trim ( $matches [ 1 ] );
}
if ( \preg_match ( '/headers="(.*?)"/ism' , $signature , $matches ) ) {
$parsed_header [ 'headers' ] = \explode ( ' ' , trim ( $matches [ 1 ] ) );
}
if ( \preg_match ( '/signature="(.*?)"/ism' , $signature , $matches ) ) {
2024-10-09 12:44:17 +00:00
$parsed_header [ 'signature' ] = \base64_decode ( preg_replace ( '/\s+/' , '' , trim ( $matches [ 1 ] ) ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode
2023-10-22 22:20:53 +00:00
}
if ( ( $parsed_header [ 'signature' ] ) && ( $parsed_header [ 'algorithm' ] ) && ( ! $parsed_header [ 'headers' ] ) ) {
$parsed_header [ 'headers' ] = array ( 'date' );
}
return $parsed_header ;
}
/**
2024-10-09 12:44:17 +00:00
* Gets the header data from the included pseudo headers .
2023-10-22 22:20:53 +00:00
*
* @ param array $signed_headers The signed headers .
2024-10-09 12:44:17 +00:00
* @ param array $signature_block The signature block .
* @ param array $headers The HTTP headers .
2023-10-22 22:20:53 +00:00
*
* @ return string signed headers for comparison
*/
public static function get_signed_data ( $signed_headers , $signature_block , $headers ) {
$signed_data = '' ;
2024-10-09 12:44:17 +00:00
2023-10-22 22:20:53 +00:00
// This also verifies time-based values by returning false if any of these are out of range.
foreach ( $signed_headers as $header ) {
if ( 'host' === $header ) {
if ( isset ( $headers [ 'x_original_host' ] ) ) {
$signed_data .= $header . ': ' . $headers [ 'x_original_host' ][ 0 ] . " \n " ;
continue ;
}
}
if ( '(request-target)' === $header ) {
$signed_data .= $header . ': ' . $headers [ $header ][ 0 ] . " \n " ;
continue ;
}
if ( str_contains ( $header , '-' ) ) {
$signed_data .= $header . ': ' . $headers [ str_replace ( '-' , '_' , $header ) ][ 0 ] . " \n " ;
continue ;
}
if ( '(created)' === $header ) {
if ( ! empty ( $signature_block [ '(created)' ] ) && \intval ( $signature_block [ '(created)' ] ) > \time () ) {
2024-10-09 12:44:17 +00:00
// Created in the future.
2023-10-22 22:20:53 +00:00
return false ;
}
2024-05-09 15:26:55 +00:00
if ( ! array_key_exists ( '(created)' , $headers ) ) {
$signed_data .= $header . ': ' . $signature_block [ '(created)' ] . " \n " ;
continue ;
}
2023-10-22 22:20:53 +00:00
}
if ( '(expires)' === $header ) {
if ( ! empty ( $signature_block [ '(expires)' ] ) && \intval ( $signature_block [ '(expires)' ] ) < \time () ) {
2024-10-09 12:44:17 +00:00
// Expired in the past.
2023-10-22 22:20:53 +00:00
return false ;
}
2024-05-09 15:26:55 +00:00
if ( ! array_key_exists ( '(expires)' , $headers ) ) {
$signed_data .= $header . ': ' . $signature_block [ '(expires)' ] . " \n " ;
continue ;
}
2023-10-22 22:20:53 +00:00
}
if ( 'date' === $header ) {
2024-10-09 12:44:17 +00:00
// Allow a bit of leeway for misconfigured clocks.
2023-10-22 22:20:53 +00:00
$d = new DateTime ( $headers [ $header ][ 0 ] );
$d -> setTimeZone ( new DateTimeZone ( 'UTC' ) );
$c = $d -> format ( 'U' );
2024-10-09 12:44:17 +00:00
$dplus = time () + ( 3 * HOUR_IN_SECONDS );
2023-10-22 22:20:53 +00:00
$dminus = time () - ( 3 * HOUR_IN_SECONDS );
2020-04-07 13:03:04 +00:00
2023-10-22 22:20:53 +00:00
if ( $c > $dplus || $c < $dminus ) {
2024-10-09 12:44:17 +00:00
// Time out of range.
2023-10-22 22:20:53 +00:00
return false ;
}
}
$signed_data .= $header . ': ' . $headers [ $header ][ 0 ] . " \n " ;
}
return \rtrim ( $signed_data , " \n " );
2020-04-07 13:03:04 +00:00
}
2020-12-25 19:23:08 +00:00
2023-10-22 22:20:53 +00:00
/**
2024-10-09 12:44:17 +00:00
* Generates the digest for an HTTP Request .
2023-10-22 22:20:53 +00:00
*
* @ param string $body The body of the request .
*
* @ return string The digest .
*/
2020-12-25 19:23:08 +00:00
public static function generate_digest ( $body ) {
2024-10-09 12:44:17 +00:00
$digest = \base64_encode ( \hash ( 'sha256' , $body , true ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
2023-10-22 22:20:53 +00:00
return " SHA-256= $digest " ;
}
/**
* Formats the $_SERVER to resemble the WP_REST_REQUEST array ,
2024-10-09 12:44:17 +00:00
* for use with verify_http_signature () .
2023-10-22 22:20:53 +00:00
*
2024-10-09 12:44:17 +00:00
* @ param array $server The $_SERVER array .
2023-10-22 22:20:53 +00:00
*
* @ return array $request The formatted request array .
*/
public static function format_server_request ( $server ) {
$request = array ();
foreach ( $server as $param_key => $param_val ) {
$req_param = strtolower ( $param_key );
if ( 'REQUEST_URI' === $req_param ) {
$request [ 'headers' ][ 'route' ][] = $param_val ;
} else {
2024-10-09 12:44:17 +00:00
$header_key = str_replace (
2023-10-22 22:20:53 +00:00
'http_' ,
'' ,
$req_param
);
$request [ 'headers' ][ $header_key ][] = \wp_unslash ( $param_val );
}
}
return $request ;
2020-12-25 19:23:08 +00:00
}
2020-04-07 13:03:04 +00:00
}