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

Sending redirect require a body #48

Closed
reikje opened this Issue Jun 19, 2013 · 6 comments

Comments

3 participants
@reikje

reikje commented Jun 19, 2013

Doing this:

render.status(HttpResponseStatus.MOVED_PERMANENTLY.getCode).header("Location", redirectUrl).toFuture

does not work because of the missing body. Responds with a 500 instead.

@capotej

This comment has been minimized.

Contributor

capotej commented Jun 19, 2013

This is how 'redirect' is defined

  def redirect(location: String, message: String = "moved") = {
    render.plain(message).status(301).header("Location", location)
  }

You explicitly want to send a blank message? For now you can do:

render.plain("").status(302).header("Location", redirectUrl)

@capotej capotej closed this Jun 19, 2013

@capotej capotej reopened this Jun 19, 2013

@twoism

This comment has been minimized.

Contributor

twoism commented Jun 19, 2013

Just a heads up. According to the RFC unless the http method is HEAD the response body should at least include a hyperlink to the redirect url. As I recall some browsers will choke if this requirement isn't satisfied.

@capotej

This comment has been minimized.

Contributor

capotej commented Jun 19, 2013

+1, added a ticket to track here #49

Also, we should add an optional argument to redirect for permanent = false to send 301 or 302

@reikje

This comment has been minimized.

reikje commented Jun 20, 2013

Alright, so this is "as designed" then I guess. I only found this while
porting an existing Finagle REST api to Finatra. In Finagle you can
redirect without a body, i.e.

Response response = Response.apply(HttpVersion.HTTP_1_1,
HttpResponseStatus.MOVED_PERMANENTLY);
response.addHeader("Location", signedGamereportUrl);
return response;

but I guess that's not according to the RFC then.

/Reik

On Wed, Jun 19, 2013 at 7:57 PM, Julio Capote notifications@github.comwrote:

+1, added a ticket to track here #49#49

Also, we should add an optional argument to redirect for permanent = falseto send 301 or 302


Reply to this email directly or view it on GitHubhttps://github.com//issues/48#issuecomment-19701589
.

@capotej

This comment has been minimized.

Contributor

capotej commented Jun 20, 2013

You can now send permanent redirects (34dd510), however this will add a message for you. If you wish to permanent redirect without a message, the workaround posted above should still work. Let me know if this satisfies your use case. Thanks!

@capotej capotej closed this Jun 20, 2013

@reikje

This comment has been minimized.

reikje commented Jun 20, 2013

Thank you, sounds great. I'am fine with the message.

On Thu, Jun 20, 2013 at 6:44 PM, Julio Capote notifications@github.comwrote:

You can now send permanent redirects, however this will add a message for
you. If you wish to permanent redirect without a message, the workaround
posted above should still work. Let me know if this satisfies your use
case. Thanks!


Reply to this email directly or view it on GitHubhttps://github.com//issues/48#issuecomment-19765754
.

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