Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow browser-compatible handling for 302 #178

Closed
rmccue opened this issue Oct 9, 2015 · 2 comments
Closed

Allow browser-compatible handling for 302 #178

rmccue opened this issue Oct 9, 2015 · 2 comments
Milestone

Comments

@rmccue
Copy link
Collaborator

rmccue commented Oct 9, 2015

Right now, 302s are handled the same as 307s: a POST will redirect to a new URL as a POST. Browsers usually treat 302s as a 303 however: a POST will redirect to a new URL as a GET instead.

I'm tossing up between changing behaviour, and adding a new flag. To ponder...

@rmccue
Copy link
Collaborator Author

rmccue commented Jul 27, 2016

This is possible with #205:

$options['hooks']->register( 'requests.before_redirect', 'browser_redirect_compatibility' );

function browser_redirect_compatibility( $location, $headers, $data, &$options, $original ) {
        // Browser compat
        if ( $original->status_code === 302 ) {
                $options['type'] = Requests::GET;
        }
}

@rmccue rmccue closed this as completed Jul 27, 2016
@asesidaa
Copy link

asesidaa commented Sep 4, 2024

Hi, any plan to integrate this as a built-in function? Or maybe add this as an example in documentation. I believe this function is quite useful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants