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

Handling redirections #187

Open
warpech opened this issue Dec 11, 2017 · 4 comments
Open

Handling redirections #187

warpech opened this issue Dec 11, 2017 · 4 comments

Comments

@warpech
Copy link
Contributor

warpech commented Dec 11, 2017

@Mihaiii created an issue in Starcounter/Home#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

@miyconst
Copy link

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
Copy link

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.

@alshakero
Copy link
Collaborator

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.

@warpech
Copy link
Contributor Author

warpech commented Dec 12, 2017

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

@warpech warpech added this to the Palindrom nice-to-have features milestone Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants