Opened 2 years ago
Last modified 14 months ago
#60564 new defect (bug)
download_url() always returns error_code 'http_404' for any non-200 responses
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | 6.4.3 |
| Component: | HTTP API | Keywords: | has-patch |
| Focuses: | Cc: |
Description
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 if ( 200 !== $response_code ) { // [...] return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ), $data ); }
Attachments (1)
Change History (4)
#2
@
14 months ago
- Keywords has-patch added
Hi @vedantgandhi28 Thanks a lot for the patch, looks great, straightforward and correct!
This ticket was mentioned in PR #8187 on WordPress/wordpress-develop by @vedantgandhi28.
14 months ago
#3
Trac Ticket - https://core.trac.wordpress.org/ticket/60564
Note: See
TracTickets for help on using
tickets.
Hi @hinnerk I have added a patch that addresses the above issue. Can you have a look at it once and review it? Thank you