[wp-trac] [WordPress Trac] #54556: It's impossible to get 'location' header on 302 redirect of wp_remote_post
WordPress Trac
noreply at wordpress.org
Thu Dec 2 08:13:13 UTC 2021
#54556: It's impossible to get 'location' header on 302 redirect of wp_remote_post
--------------------------+-----------------------------
Reporter: saturnix2025 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
https://wordpress.stackexchange.com/questions/398738/get-returned-url-
from-wp-remote-post-if-response-code-is-302
{{{#!php
<?php
$payload = array('body' => $payload);
$payload['redirection'] = 0;
$response = wp_remote_post( $my_url, $payload );
$redirect_to = wp_remote_retrieve_header( $reponse, 'location' );
}}}
In the above code, $redirect_to always returns an empty string when
$my_url is an URL that returns 302 redirect.
This is unexpected behavior, as $redirect_to should contain the URL
$my_url is redirecting us to.
I've tried replacing "location" with "Location" and "0" with "false" to no
avail.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54556>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list