-
Notifications
You must be signed in to change notification settings - Fork 158
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
FastBootLocation API #195
FastBootLocation API #195
Conversation
That was a canard. |
Update:
|
get | ||
} = Ember; | ||
|
||
const TEMPORARY_REDIRECT_CODE = 307; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should just use 302 here. 307 was added so that servers can require subsequent requests after redirect responses to use the same request method as the original request that resulted in the redirect. While we want the same request method to be used of course, 307 was really only added for everythong other than GET
and FastBoot is only ever dealing with GET
anyway (in fact all other request methods expect for HEAD
maybe) should actually be ignored by the FastBoot middleware - not sure whether that's actually the case yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
302 is FOUND
, whereas 307
is TEMPORARY REDIRECT
, which I'd 307 is more semantically correct. The following note is from the 302 spec (emphasis mine):
Note: RFC 1945 and RFC 2068 specify that the client is not allowed to change the method on the redirected request. However, most existing user agent implementations treat 302 as if it were a 303 response, performing a GET on the Location field-value regardless of the original request method. The status codes 303 and 307 have been added for servers that wish to make unambiguously clear which kind of reaction is expected of the client.
302 has ambiguity in its handling, whereas 307 is clear
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed on 307 - TEMPORARY REDIRECT
. If we were trying to maintain HTTP 1.0 compatibility 302 - FOUND
would make sense. As it is, 307
is a very clear spec. We could make the code configurable with a 307
default, so people can override it. Would anyone object to that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making the exact code configurable sounds fine. Didn't want to start an argument about HTTP semantics here - I think that could easily get out of control ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WIll do.
@danmcclain This issue I'm encountering with For its functionality to be maintained, it needs to:
Currently, 1 happens, but 2 does not. Any thoughts on handeling this? My thought is that if you get an Update: I looked into my implementation and cannot think of a way to do it without messing with It's definitely something we'll need to discuss at sync up. |
d584276
to
199546b
Compare
@arjansingh and I dug into this a bit today, and have determined that the issue mentioned above is not a blocker for this PR. Basically, in Ember if you do an intermediate transition during another transition you must abort the initial transition. When discovering that we also uncovered a larger issue WRT aborted transitions rejection and that error being unhandled. @tomdale - This is good to go from my perspective... |
Alright updated tests to disable the I also will update assertions for the other location tests to check for appropriate body content when ember-fastboot/fastboot#64 is released with the next fastboot beta. |
ac1f9b3
to
85418b1
Compare
response.headers.set('location', redirectURL); | ||
} | ||
|
||
response.headers.set('x-fastboot-path', path); // for testing and debugging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would only display this header when you enable it via a config flag, otherwise we leak what is running
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 We can config this.
Supports http redirection in the cases of `Route.transitionTo` and `Route.replaceWith`
@rwjblue So this is a first draft. There are a couple of issues:
replaceWith
andintermediateTransitionTo
die hard. Specifically,setURL
is not getting the path to redirect to when those two functions are called. Check the failing tests in TravisCI to see those examples.transitionTo
still renders the body. The middleware or fastboot could be modified to not include it, but a better solution would be to tell Ember to abort the page rendering. Tips on how to do that would be appreciated. I couldn't find anything straightforward in the docs.If we can solve those, I can add a few more test cases (covering
model
, andafterModel
hooks come to mind) and get this ready for submission.