diff --git a/HISTORY.md b/HISTORY.md index dca1beab..77cbb6d8 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,6 +2,10 @@ **How to upgrade**: remove your `$GOPATH/src/github.com/kataras` folder, open your command-line and execute this command: `go get -u github.com/kataras/iris/iris`. +## 5.0.2 -> 5.0.3 + +- Fix `https relative redirect paths`, a very old issue, which I just saw, peaceful, again :) + ## 5.0.1 -> 5.0.2 - [geekypanda/httpcache](https://github.com/geekypanda/httpcache) has been re-written, diff --git a/README.md b/README.md index 87d29290..72bf93f3 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@
-Releases +Releases Examples @@ -825,7 +825,7 @@ I recommend writing your API tests using this new library, [httpexpect](https:// Versioning ------------ -Current: **v5.0.2** +Current: **v5.0.3** Stable: **[v4 LTS](https://github.com/kataras/iris/tree/4.0.0#versioning)** diff --git a/context.go b/context.go index bf12bcd7..ec381e59 100644 --- a/context.go +++ b/context.go @@ -474,28 +474,29 @@ func (ctx *Context) SetHeader(k string, v string) { // Redirect redirect sends a redirect response the client // accepts 2 parameters string and an optional int // first parameter is the url to redirect -// second parameter is the http status should send, default is 302 (StatusFound), you can set it to 301 (Permant redirect), if that's nessecery +// second parameter is the http status should send, default is 302 (StatusFound), +// you can set it to 301 (Permant redirect), if that's nessecery func (ctx *Context) Redirect(urlToRedirect string, statusHeader ...int) { + ctx.StopExecution() + httpStatus := StatusFound // a 'temporary-redirect-like' which works better than for our purpose if statusHeader != nil && len(statusHeader) > 0 && statusHeader[0] > 0 { httpStatus = statusHeader[0] } + + // #355 + if ctx.IsTLS() { + u := fasthttp.AcquireURI() + ctx.URI().CopyTo(u) + u.SetScheme("https") + u.Update(urlToRedirect) + ctx.SetHeader("Location", string(u.FullURI())) + fasthttp.ReleaseURI(u) + ctx.SetStatusCode(httpStatus) + return + } + ctx.RequestCtx.Redirect(urlToRedirect, httpStatus) - - /* you can use one of these if you want to customize the redirection: - 1. - u := fasthttp.AcquireURI() - ctx.URI().CopyTo(u) - u.Update(urlToRedirect) - ctx.SetHeader("Location", string(u.FullURI())) - fasthttp.ReleaseURI(u) - ctx.SetStatusCode(httpStatus) - 2. - ctx.SetHeader("Location", urlToRedirect) - ctx.SetStatusCode(httpStatus) - */ - - ctx.StopExecution() } // RedirectTo does the same thing as Redirect but instead of receiving a uri or path it receives a route name diff --git a/iris.go b/iris.go index 15ed7a51..a87762c0 100644 --- a/iris.go +++ b/iris.go @@ -80,7 +80,7 @@ const ( // IsLongTermSupport flag is true when the below version number is a long-term-support version IsLongTermSupport = false // Version is the current version number of the Iris web framework - Version = "5.0.2" + Version = "5.0.3" banner = ` _____ _ |_ _| (_)