0

I'm trying to send clients a 303 See Other with Location header and a response body detailing why they're being redirected (which seems allowed per RFC 2616) using Play 2.3.10:

package example;

import play.mvc.Controller;
import play.mvc.Result;
import play.mvc.Results;

public class SeeOtherExample extends Controller {

    public Result seeOtherExample() {
        response().setHeader(LOCATION, "http://example.com");
        return Results.status(SEE_OTHER, "You were redirected because...");
    }
}

But the response body comes back empty when I include the location header. Omitting the header causes the body to be returned correctly, but of course I need the header as well.

Also, it appears to be something specific about the Location header. Setting other headers do not cause the body to be omitted.

What's the best way to send back a Location header and a response body?

Community
  • 1
  • 1
Jacob Wallace
  • 887
  • 2
  • 12
  • 24
  • 2.5 omits the response body as well with a `303`. You should ask in [mailing list](https://groups.google.com/forum/#!forum/play-framework) if this is a bug and if so, report it at [github](https://github.com/playframework/playframework/issues). Or if a Play maintainer can confirm this bug here... – adis Jul 22 '16 at 20:00
  • @adis actually the code at this question works as expected (preserves the entity body) when using Play 2.5 (tested against version 2.5.4). Did not had time to test agains 2.3.10. – marcospereira Jul 25 '16 at 05:21
  • Jacob, you may want to edit your question to reference [RFC 7231](https://tools.ietf.org/html/rfc7231#section-6.4.4) which obsoletes RFC 2616. The new RFC is consistent with your question (303 may have a entity body). – marcospereira Jul 25 '16 at 05:24

0 Answers0