mirror of
https://github.com/gin-gonic/gin.git
synced 2026-07-04 17:21:38 +08:00
Merge 7303932ab2283f14b093dea467141cdbf772323f into 5fad976b372e381312f8de69f0969f1284d229d3
This commit is contained in:
commit
003bcb05b1
3
gin.go
3
gin.go
@ -9,6 +9,7 @@ import (
|
|||||||
"html/template"
|
"html/template"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/textproto"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
@ -483,7 +484,7 @@ func (engine *Engine) validateHeader(header string) (clientIP string, valid bool
|
|||||||
}
|
}
|
||||||
items := strings.Split(header, ",")
|
items := strings.Split(header, ",")
|
||||||
for i := len(items) - 1; i >= 0; i-- {
|
for i := len(items) - 1; i >= 0; i-- {
|
||||||
ipStr := strings.TrimSpace(items[i])
|
ipStr := textproto.TrimString(items[i])
|
||||||
ip := net.ParseIP(ipStr)
|
ip := net.ParseIP(ipStr)
|
||||||
if ip == nil {
|
if ip == nil {
|
||||||
break
|
break
|
||||||
|
|||||||
3
utils.go
3
utils.go
@ -7,6 +7,7 @@ package gin
|
|||||||
import (
|
import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/textproto"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"reflect"
|
"reflect"
|
||||||
@ -107,7 +108,7 @@ func parseAccept(acceptHeader string) []string {
|
|||||||
if i := strings.IndexByte(part, ';'); i > 0 {
|
if i := strings.IndexByte(part, ';'); i > 0 {
|
||||||
part = part[:i]
|
part = part[:i]
|
||||||
}
|
}
|
||||||
if part = strings.TrimSpace(part); part != "" {
|
if part = textproto.TrimString(part); part != "" {
|
||||||
out = append(out, part)
|
out = append(out, part)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user