mirror of
https://github.com/kataras/iris.git
synced 2025-03-15 06:46:26 +01:00
This commit is contained in:
parent
9ef6ac30cb
commit
6cc038b3b3
20
http.go
20
http.go
|
@ -3,11 +3,6 @@ package iris
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"github.com/iris-contrib/letsencrypt"
|
|
||||||
"github.com/kataras/go-errors"
|
|
||||||
"github.com/kataras/iris/utils"
|
|
||||||
"github.com/valyala/fasthttp"
|
|
||||||
"github.com/valyala/fasthttp/fasthttpadaptor"
|
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -17,6 +12,12 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/iris-contrib/letsencrypt"
|
||||||
|
"github.com/kataras/go-errors"
|
||||||
|
"github.com/kataras/iris/utils"
|
||||||
|
"github.com/valyala/fasthttp"
|
||||||
|
"github.com/valyala/fasthttp/fasthttpadaptor"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -1147,7 +1148,6 @@ func (mux *serveMux) BuildHandler() HandlerFunc {
|
||||||
pathLen := len(reqPath)
|
pathLen := len(reqPath)
|
||||||
|
|
||||||
if pathLen > 1 {
|
if pathLen > 1 {
|
||||||
|
|
||||||
if reqPath[pathLen-1] == '/' {
|
if reqPath[pathLen-1] == '/' {
|
||||||
reqPath = reqPath[:pathLen-1] //remove the last /
|
reqPath = reqPath[:pathLen-1] //remove the last /
|
||||||
} else {
|
} else {
|
||||||
|
@ -1157,8 +1157,12 @@ func (mux *serveMux) BuildHandler() HandlerFunc {
|
||||||
|
|
||||||
context.Request.URI().SetPath(reqPath)
|
context.Request.URI().SetPath(reqPath)
|
||||||
urlToRedirect := utils.BytesToString(context.Request.RequestURI())
|
urlToRedirect := utils.BytesToString(context.Request.RequestURI())
|
||||||
|
statisForRedirect := StatusMovedPermanently // StatusMovedPermanently, this document is obselte, clients caches this, so no performance difference to the next call
|
||||||
context.Redirect(urlToRedirect, StatusMovedPermanently) // StatusMovedPermanently
|
if bytes.Equal(tree.method, MethodPostBytes) ||
|
||||||
|
bytes.Equal(tree.method, MethodPutBytes) || bytes.Equal(tree.method, MethodDeleteBytes) {
|
||||||
|
statisForRedirect = StatusTemporaryRedirect // To mantain POST data
|
||||||
|
}
|
||||||
|
context.Redirect(urlToRedirect, statisForRedirect)
|
||||||
// RFC2616 recommends that a short note "SHOULD" be included in the
|
// RFC2616 recommends that a short note "SHOULD" be included in the
|
||||||
// response because older user agents may not understand 301/307.
|
// response because older user agents may not understand 301/307.
|
||||||
// Shouldn't send the response for POST or HEAD; that leaves GET.
|
// Shouldn't send the response for POST or HEAD; that leaves GET.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user