fc-thrisp-hurrata-dlm-graveyard / flotilla-defunct

A basic and extensible Go web framework
MIT License
9 stars 1 forks source link

No redirect after POST #5

Closed 1xch closed 10 years ago

1xch commented 10 years ago

A POST request will complete, but not redirect fully.

func TestPost(f *flotilla.R) {
    fmt.Printf("**successful post: Ctx**\n%+v\n", f.Ctx)
    f.Redirect(301, "/redirected/url")
}

Will result in:

[FLOTILLA] 2014/10/22 - 11:06:58 | 301 |   2.425082ms | 127.0.0.1:57081 |  POST    /posted/

and a blank page at /posted/, but no redirect to /redirected/url/.

GET requests with handlers using a redirect context function will redirect.

POST/Redirect/GET cycle is not viable here, yet.

1xch commented 10 years ago

The answer has to do with engine.responsewriter, seen before where an explicit write needs to be made so that Size no longer is -1, the default for NotWritten.

Adding

r.rw.WriteHeaderNow()

to the redirect fixes for now.