Description

I came across this problem by accident. Suppose we have a server with a GET api, just like the following demo code. If we send get a request curl -X GET 'http://127.0.0.1:8080/api', everything goes well.

But if we construct a malicious request with a body data curl -X GET -d 'hello' 'http://127.0.0.1:8080/api', the gin server will never give response.

How to reproduce

package main

import (
    "github.com/gin-gonic/gin"
)

func main() {

    r := gin.Default()
    r.GET("/api", func(c *gin.Context) {
        c.String(200, "ok")
    })
    r.Run("127.0.0.1:8080")
}

Expectations

$ curl -X GET -d 'hello'  'http://127.0.0.1:8080/api'
ok

Actual result

$ curl -X GET -d 'hello'  'http://127.0.0.1:8080/api'
There will be no response.

Environment

  • go version: go1.17.6 darwin/arm64
  • gin version (or commit ref): v1.7.4
  • operating system: MacOS Monterey 12.2.1

Comment From: Fov6363

Not reproduce, please run curl -X GET -d 'hello' 'http://127.0.0.1:8080/api' -vv