These are chat archives for gin-gonic/gin

27th
Jul 2016
lexasa
@lexasa
Jul 27 2016 06:46

Hi everyone! I'm getting "http: invalid Read on closed Body" for every 250 requests during siege test. The is no writing before it. ```
func (h Handler) handleRTB(c gin.Context) {

var bidReq openrtb.BidRequest
if err := c.BindJSON(&bidReq); err != nil {
    log.Error(err)
    c.Writer.WriteString("{}")
    return
}

```
Any help how to fix it?

David Marchbanks
@ptdave20
Jul 27 2016 16:10
can you use the ioutils to read all the data from the request and make sure whats being submitted?
lexasa
@lexasa
Jul 27 2016 19:20
Yes, I tried to read data with ioutil. Same result.
func (h *Handler) handleRTB(c *gin.Context) {

    var bidReq openrtb.BidRequest

    if body, err := ioutil.ReadAll(c.Request.Body); err != nil {
        log.Error(err)
        c.Writer.WriteString("{}")
        return
    } else {
        if err := json.Unmarshal(body, &bidReq); err != nil {
            log.Error(err)
            c.Writer.WriteString("{}")
            return
        }
    }
I'm testing with gobench
Tried both keep-alive and close