[wp-trac] [WordPress Trac] #51736: wp_remote_retrieve_header returns an Array for multiple headers
WordPress Trac
noreply at wordpress.org
Sun Dec 19 21:33:41 UTC 2021
#51736: wp_remote_retrieve_header returns an Array for multiple headers
----------------------------+------------------------------
Reporter: robtarr | Owner: johnjamesjacoby
Type: task (blessed) | Status: assigned
Priority: normal | Milestone: 5.9
Component: HTTP API | Version: 2.7
Severity: normal | Resolution:
Keywords: needs-patch | Focuses: docs
----------------------------+------------------------------
Comment (by felipeelia):
Adding a new parameter to specify the return would be something you'd
consider @johnjamesjacoby? Let's say `$type` that could be `'raw'`,
`'array'`, or `'string'`.
So, in `src/wp-includes/comment.php` (by line 2787) we would have the
following (returning the first value of an hipotical array returned):
{{{#!php
preg_match( '#(image|audio|video|model)/#is', wp_remote_retrieve_header(
$response, 'content-type', 'string' )
}}}
and in `tests/phpunit/tests/http/base.php`
(`test_multiple_location_headers()`) this assertion would be still valid:
{{{#!php
$this->assertIsArray( wp_remote_retrieve_header( $res, 'location' ) );
}}}
I can help crafting a diff/PR if that is helpful. Thanks!
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51736#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list