Redirector icon indicating copy to clipboard operation
Redirector copied to clipboard

[bug] Unable to trigger redirection when the Location Response Header set on the server side

Open allurx opened this issue 6 years ago • 11 comments

When the Location Response Header set by the server matches the "Include pattern" I configured, the redirection cannot be triggered. At this time, I must manually refresh the browser for the redirect to take effect.

allurx avatar Apr 09 '20 15:04 allurx

hi @einaregilsson,can you give me a feedback?

allurx avatar Apr 19 '20 02:04 allurx

Hmmm, if you get a redirect from the server it should trigger a new request by the browser and that request should be redirected I think. Are you using Chrome or Firefox?

einaregilsson avatar Apr 19 '20 09:04 einaregilsson

I am using Firefox 75.0

allurx avatar Apr 19 '20 10:04 allurx

Here is a simple URL to use to test this issue:

https://accounts.google.com/

It uses a Location response header with a 302 code.

Gitoffthelawn avatar Apr 19 '20 11:04 Gitoffthelawn

Don't really have time to work on this now, but when I get back to Redirector I'll look into it.

einaregilsson avatar Apr 19 '20 16:04 einaregilsson

Okay,looking forward to your return. :smile:

allurx avatar Apr 20 '20 01:04 allurx

I can confirm this issue using Firefox 90.0b4. Same rule works under Chrome.

Frederick888 avatar Jun 08 '21 02:06 Frederick888

Screenshot 2021-06-08 at 10 35 45

Weird, it worked for me, https://mbl.is 301 redirects to https://www.mbl.is and they were both checked by Redirector. Do you have a specific url and redirect I can test this on where it fails?

einaregilsson avatar Jun 08 '21 10:06 einaregilsson

@einaregilsson I bumped into this issue when a POST API returned 302. So to reproduce it:

<html>

<body>
    <form id="test" action="test.php" method="POST">
        <label id="test-label"></label>
        <input type="text" id="test-input" name="test-input" />
        <button id="test-button">Click</button>
    </form>
</body>

</html>

<?php
if (!empty($_POST['test-input'])) {
    header('Location: https://www.google.com/not/exist', true, 302);
}
exit;
?>

Save the script as e.g. test.php and run php -S 127.0.0.1:8080 in the same directory. Then visit http://localhost:8080/test.php.

Now in Redirector, add the following rule:

Description: Test
Include Pattern: https?://www\.google\.com/not/exist
Redirect to: https://example.com
Type: Regex

Back to test.php, fill in anything, click the button, you'd still see Google.

Exactly the same script & rule work under Chrome.

Frederick888 avatar Jun 08 '21 11:06 Frederick888

Hmmm, might be because of the POST, not the 302. Redirector doesn't handle POST requests, and although after you issue a 302 the next request would be a GET it might be related to that. Does it also not work if the original request is a GET?

einaregilsson avatar Jun 09 '21 09:06 einaregilsson

@einaregilsson It works if the original one is GET. can confirm using https://mbl.is or

<html>

<body>
    <form id="test" action="test.php" method="GET">
        <label id="test-label"></label>
        <input type="text" id="test-input" name="test-input" />
        <button id="test-button">Click</button>
    </form>
</body>

</html>

<?php
if (!empty($_GET['test-input'])) {
    header('Location: https://www.google.com/not/exist', true, 302);
}
exit;
?>

Frederick888 avatar Jun 09 '21 10:06 Frederick888