Palindrom icon indicating copy to clipboard operation
Palindrom copied to clipboard

Handling redirections

Open warpech opened this issue 8 years ago • 4 comments

@Mihaiii created an issue in https://github.com/Starcounter/Home/issues/272 that shows how developers can be confused by Palindrom's handling of the response header for the patch request.

  1. When Palindrom receives Location header in the response to the application/json-patch+json request, should it change the URL in the address bar to the value of that header?
  2. If the answer to the above question is yes, should Palindrom issue an HTTP GET application/json-patch+json request to that location, similarly how it does with <palindrom-redirect>?
  3. @alshakero Can Palindrom actually read the Location header in XHR callback in all browsers or is it among the headers obscured for security reasons?

cc @miyconst

warpech avatar Dec 11 '17 17:12 warpech

If the answer to the above question is yes, should Palindrom issue an HTTP GET application/json-patch+json request to that location, similarly how it does with <palindrom-redirect>?

Investigating the original issue I found that browser automatically sends request to the new location, not sure how Palindrom can intercept this.

miyconst avatar Dec 11 '17 17:12 miyconst

When Palindrom receives Location header in the response to the...

I think, the decisive factor here is the response status code, not the header. It should be 301 or 302 which means that resource has been moved.

Anyway, I am not sure what should be the correct behavior.

miyconst avatar Dec 11 '17 17:12 miyconst

When Palindrom receives Location header in the response to the application/json-patch+json request, should it change the URL in the address bar to the value of that header?

Apparently, Palindrom will never receive this header. The browser redirects when it sees it on a lower level. even when status is 200. I tested this:

Paste this:

<?php
    header("Location: https://www.youtube.com/embed/UgUgz4T3_wc", true, 200);
?>

here: http://phpfiddle.org/# (doesn't support permalinks).


If the answer to the above question is yes, should Palindrom issue an HTTP GET application/json-patch+json request to that location, similarly how it does with ?

I don't think Palindrom in relevant here. When you access http://someStarCounterApp.com and you see Location header you'd redirect before any JS is executed. I hope I understand the issue correctly.


@alshakero Can Palindrom actually read the Location header in XHR callback in all browsers or is it among the headers obscured for security reasons?

Apparently not.

alshakero avatar Dec 11 '17 18:12 alshakero

I am not giving up on it that easily :) Can Palindrom obtain the URL from xhr.responseURL then?

warpech avatar Dec 12 '17 16:12 warpech