- With issues:
- Use the search tool before opening a new issue.
- Please provide source code and commit sha if you found a bug.
- Review existing issues and provide feedback or react to them.
Description
With the go upgrade, the semicolons in query param are not support and output sys log tips, in some case we also need support it.
http: URL query contains semicolon, which is no longer a supported separator; parts of the query may be stripped when parsed; see golang.org/issue/25192
How to reproduce
package main
import (
"github.com/gin-gonic/gin"
)
func main() {
g := gin.Default()
g.GET("/hello", func(c *gin.Context) {
c.String(200, "Hello query: %v", c.Request.URL.Query())
})
g.Run(":9000")
}
Expectations
$ curl http://localhost:9000/hello?a;b=123&c=456
Hello query: map[a:[] b:[123] c:[456]]
Actual result
$ curl -i http://localhost:9000/hello/world
Hello query: map[c:[456]]
Idea with issue
func main() {
g := gin.Default()
g.GET("/hello", func(c *gin.Context) {
if strings.Contains(c.Request.URL.RawQuery, ";") {
c.Request.URL.RawQuery = strings.ReplaceAll(c.Request.URL.RawQuery, ";", "&")
}
c.String(200, "Hello query: %v", c.Request.URL.Query())
})
g.Run(":9000")
}
Also will output the log: http: URL query contains semicolon, which is no longer a supported separator; parts of the query may be stripped when parsed; see golang.org/issue/25192
How deal or some setting like: https://github.com/golang/go/blob/ecc268aa26b81cb53f2f6f62ea9d074a610771fe/src/net/http/server.go#L2955
Environment
- go version: 1.18.3
- gin version (or commit ref): 1.18.1
- operating system: Mac Darwin
Comment From: menduo
works for me:
engine := gin.New()
server := &http.Server{
Addr: fmt.Sprintf("%s:%d", host, port),
Handler: http.AllowQuerySemicolons(engine),
IdleTimeout: 120 * time.Second,
}
server.ListenAndServe()
Comment From: xwi88
works for me:
```go engine := gin.New()
server := &http.Server{ Addr: fmt.Sprintf("%s:%d", host, port), Handler: http.AllowQuerySemicolons(engine), IdleTimeout: 120 * time.Second, }
server.ListenAndServe() ```
Thks, so cool.