[wp-trac] [WordPress Trac] #60564: download_url() always returns error_code 'http_404' for any non-200 responses
WordPress Trac
noreply at wordpress.org
Fri Feb 16 20:45:22 UTC 2024
#60564: download_url() always returns error_code 'http_404' for any non-200
responses
--------------------------+-----------------------------
Reporter: hinnerk | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: HTTP API | Version: 6.4.3
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
Expected:
Return WP_Error code "http_406" if a 406 occurs while downloading the URL.
Return WP_Error code "http_500" if a 500 occurs while downloading the URL.
...
Actually doing it wrong:
download_url() always returns WP_Error code "http_404" on any non-200
status.
{{{
object(WP_Error)#11262 (3) {
["errors"]=>
array(1) {
["http_404"]=>
array(1) {
[0]=>
string(14) "Not Acceptable"
}
}
["error_data"]=>
array(1) {
["http_404"]=>
array(2) {
["code"]=>
int(406)
["body"]=>
string(0) ""
}
}
["additional_data":protected]=>
array(0) {
}
}
}}}
see https://core.trac.wordpress.org/browser/trunk/src/wp-
admin/includes/file.php#L1214
{{{#!php
<?php
if ( 200 !== $response_code ) {
// [...]
return new WP_Error( 'http_404', trim(
wp_remote_retrieve_response_message( $response ) ), $data );
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60564>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list