- 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
The requests to http://127.0.0.1:8080/aaa block each other, but the requests to http://127.0.0.1:8080/bbb are not affected. Why? Is this to restrict duplicate requests?
Demo:
http://127.0.0.1:8080/aaa
http://127.0.0.1:8080/aaa
http://127.0.0.1:8080/bbb
http://127.0.0.1:8080/bbb
http://127.0.0.1:8080/bbb
http://127.0.0.1:8080/bbb
Console Output:
777.1
777.2
777.2
777.2
777.2
777.1
How to reproduce
package main
import (
"fmt"
"net/http"
"time"
"github.com/gin-gonic/gin"
)
func handler(c *gin.Context) {
fmt.Println(777.1)
time.Sleep(10 * time.Second)
c.String(http.StatusOK, "Sleep")
}
func handler2(c *gin.Context) {
fmt.Println(777.2)
c.String(http.StatusOK, "OK")
}
func main() {
router := gin.Default()
router.GET("/aaa", handler)
router.GET("/bbb", handler2)
err := router.Run(":8080")
if err != nil {
fmt.Println(err)
}
}
Environment
- go version: go version go1.20.3 darwin/amd64
- gin version (or commit ref): github.com/gin-gonic/gin v1.9.1
- operating system: macos 12.6.2 (cpu: i5 4690T mem:16G)
The same issue exists on Linux as well.
Comment From: fanybook
The issue was resolved after modifying the route.
Demo:
http://127.0.0.1:8080/aaa
http://127.0.0.1:8080/aaa2
http://127.0.0.1:8080/aaa3
http://127.0.0.1:8080/bbb
http://127.0.0.1:8080/bbb
http://127.0.0.1:8080/bbb
http://127.0.0.1:8080/bbb
Console Output:
777.1
777.1
777.1
777.2
777.2
777.2
777.2
package main
import (
"fmt"
"net/http"
"time"
"github.com/gin-gonic/gin"
)
func handler(c *gin.Context) {
fmt.Println(777.1)
time.Sleep(10 * time.Second)
c.String(http.StatusOK, "Sleep")
}
func handler2(c *gin.Context) {
fmt.Println(777.2)
c.String(http.StatusOK, "OK")
}
func main() {
router := gin.Default()
router.GET("/aaa", handler)
router.GET("/bbb", handler2)
router.GET("/aaa2", handler)
router.GET("/aaa3", handler)
err := router.Run(":8080")
if err != nil {
fmt.Println(err)
}
}
Comment From: fanybook
The issue was resolved after modifying the query of url.
Demo:
http://127.0.0.1:8080/aaa?a=1
http://127.0.0.1:8080/aaa?a=2
http://127.0.0.1:8080/aaa?a=3
http://127.0.0.1:8080/bbb
http://127.0.0.1:8080/bbb
http://127.0.0.1:8080/bbb
http://127.0.0.1:8080/bbb
Console Output:
777.1
777.1
777.1
777.2
777.2
777.2
777.2
package main
import (
"fmt"
"net/http"
"time"
"github.com/gin-gonic/gin"
)
func handler(c *gin.Context) {
fmt.Println(777.1)
time.Sleep(10 * time.Second)
c.String(http.StatusOK, "Sleep")
}
func handler2(c *gin.Context) {
fmt.Println(777.2)
c.String(http.StatusOK, "OK")
}
func main() {
router := gin.Default()
router.GET("/aaa", handler)
router.GET("/bbb", handler2)
err := router.Run(":8080")
if err != nil {
fmt.Println(err)
}
}
Comment From: fanybook
Postman doesn't have this issue, it may just be a problem of Chrome