Opened 3 years ago
Last modified 3 years ago
#54556 new defect (bug)
It's impossible to get 'location' header on 302 redirect of wp_remote_post
Reported by: | saturnix2025 | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | reporter-feedback |
Focuses: | Cc: |
Description
<?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.
Change History (2)
#2
in reply to:
↑ 1
@
3 years ago
Replying to costdev:
Hi @saturnix2025, thanks for opening this ticket and welcome to Trac!
Trac is for reporting issues with WordPress Core - so let's see if that's where this issue lies.
- What version of WordPress are you using?
- What is the output of
var_dump( $response );
?
Unfortunately I don't know, as this is shared hosting with no access to a dev console.
Version is 5.8.2
Note: See
TracTickets for help on using
tickets.
Hi @saturnix2025, thanks for opening this ticket and welcome to Trac!
Trac is for reporting issues with WordPress Core - so let's see if that's where this issue lies.
var_dump( $response );
?