[wp-trac] [WordPress Trac] #40153: Filter for wp_safe_remote_get in download_url
WordPress Trac
noreply at wordpress.org
Sun Oct 6 11:07:04 UTC 2024
#40153: Filter for wp_safe_remote_get in download_url
-------------------------+------------------------------
Reporter: realloc | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 4.8
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
-------------------------+------------------------------
Comment (by threadi):
I also stumbled across this today because I want to access an Auth Basic
protected URL. My solution:
{{{
add_filter( 'http_request_args', array( $this, 'set_download_url_header' )
);
$file = download_url( $this->get_url() );
remove_filter( 'http_request_args', array( $this,
'set_download_url_header' ) );
}}}
In {{{set_download_url_header()}}} I add the Auth Basic header, which then
works without any problems:
{{{
public function set_download_url_header( array $parsed_args ): array {
return array_merge( $parsed_args, array( 'header' => array(
'Authorization' => 'Basic ...' ) ) );
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40153#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list