strtoupper( (string) $method ), 'headers' => $assoc, // Matches the SDK's own default and the setting behind it. This // can run inside a checkout request on a site with no Action // Scheduler, and a tracker that holds a shopper on a blank page // is uninstalled the same day. 'timeout' => 5, // We follow nothing. A redirect from an API is a misconfiguration // and following it would repost a signed body to somewhere that // was not signed for. 'redirection' => 0, 'sslverify' => true, 'blocking' => true, ); if ( '' !== (string) $body ) { $args['body'] = (string) $body; } $response = wp_remote_request( $url, $args ); if ( is_wp_error( $response ) ) { return array( 'status' => 0, 'headers' => array(), 'body' => $response->get_error_message(), ); } $out = array(); foreach ( wp_remote_retrieve_headers( $response ) as $name => $value ) { $out[ strtolower( (string) $name ) ] = is_array( $value ) ? implode( ', ', $value ) : (string) $value; } return array( 'status' => (int) wp_remote_retrieve_response_code( $response ), 'headers' => $out, 'body' => (string) wp_remote_retrieve_body( $response ), ); } }